From 7319a4b2872fa3d2e145780ff3845e522d291811 Mon Sep 17 00:00:00 2001
From: s7tya <53410646+s7tya@users.noreply.github.com>
Date: Thu, 11 Apr 2024 15:29:44 +0900
Subject: [PATCH 01/14] update
---
.vscode/settings.json | 7 +-
panda.config.ts | 3 +
src/app/committee/forms/new/page.tsx | 149 +++++++++++++++++++++++++++
src/lib/textUtils.ts | 35 +++++++
4 files changed, 191 insertions(+), 3 deletions(-)
create mode 100644 src/app/committee/forms/new/page.tsx
create mode 100644 src/lib/textUtils.ts
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 31f2c9f3..234fb89f 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,7 +1,8 @@
{
"editor.formatOnSave": true,
- "editor.defaultFormatter": "esbenp.prettier-vscode",
-
"editor.tabSize": 2,
- "files.insertFinalNewline": true
+ "files.insertFinalNewline": true,
+ "[typescriptreact]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ }
}
diff --git a/panda.config.ts b/panda.config.ts
index ed752dde..7eb747a0 100644
--- a/panda.config.ts
+++ b/panda.config.ts
@@ -22,6 +22,9 @@ export default defineConfig({
orange: { value: "#ed6d1f" },
purple: { value: "#60C" },
},
+ tsukuba: {
+ purple: { value: "#60C" },
+ }
},
},
},
diff --git a/src/app/committee/forms/new/page.tsx b/src/app/committee/forms/new/page.tsx
new file mode 100644
index 00000000..ac838b4b
--- /dev/null
+++ b/src/app/committee/forms/new/page.tsx
@@ -0,0 +1,149 @@
+"use client";
+
+import { getProjectAttributeText, getProjectCategoryText } from "@/lib/textUtils";
+import { projectAttributes, projectCategories } from "@/lib/valibot";
+import { css } from "@styled-system/css";
+import { stack, visuallyHidden } from "@styled-system/patterns";
+import { NextPage } from "next";
+import { FC } from "react";
+import { useForm } from "react-hook-form";
+
+const sectionTitleStyle = css({
+ fontSize: "xl",
+ fontWeight: "bold",
+});
+
+const descriptionStyle = css({
+ fontSize: "sm",
+ color: "gray.600",
+});
+
+const checkboxStyle = css({
+ py: 1,
+ px: 4,
+ rounded: "full",
+ background: "gray.200",
+ color: "gray.500",
+ fontSize: "sm",
+ fontWeight: "bold",
+ "&:has(:checked)": {
+ background: "tsukuba.purple",
+ color: "white",
+ },
+});
+
+const checkboxGrpupStyle = css({
+ display: "flex",
+ flexWrap: "wrap",
+ gap: 1,
+});
+
+const textInputStyle = css({
+ border: "1px solid token(colors.gray.400)",
+ background: "gray.100",
+ rounded: "sm",
+ width: "full",
+ padding: 2,
+});
+
+const Divider: FC = () => {
+ return
;
+};
+
+const CreateFormPage: NextPage = () => {
+ const { register } = useForm();
+
+ return (
+
+ );
+};
+
+export default CreateFormPage;
diff --git a/src/lib/textUtils.ts b/src/lib/textUtils.ts
new file mode 100644
index 00000000..fe7ad4f2
--- /dev/null
+++ b/src/lib/textUtils.ts
@@ -0,0 +1,35 @@
+import { ProjectAttribute, ProjectCategory } from "./valibot";
+
+export const getProjectCategoryText = (category: ProjectCategory) => {
+ switch (category) {
+ case "general":
+ return "普通企画";
+ case "foods_with_kitchen":
+ return "調理企画(仕込場必要)";
+ case "foods_without_kitchen":
+ return "調理企画(仕込場不要)";
+ case "foods_without_cooking":
+ return "既製食品販売企画";
+ case "stage_1a":
+ return "ステージ企画(1Aステージ)";
+ case "stage_united":
+ return "ステージ企画(UNITEDステージ)";
+ case "stage_university_hall":
+ return "ステージ企画(大学会館ステージ)";
+ }
+}
+
+export const getProjectAttributeText = (attribute: ProjectAttribute) => {
+ switch (attribute) {
+ case "academic":
+ return "学術参加枠"
+ case "art":
+ return "芸術祭参加枠"
+ case "official":
+ return "委員会企画"
+ case "inside":
+ return "屋内企画"
+ case "outside":
+ return "屋外企画"
+ }
+}
From 9b9d12e22ab2f86862b778b19a5cb03749c31140 Mon Sep 17 00:00:00 2001
From: s7tya <53410646+s7tya@users.noreply.github.com>
Date: Fri, 12 Apr 2024 13:29:40 +0900
Subject: [PATCH 02/14] =?UTF-8?q?=E5=9E=8B=E5=AE=9A=E7=BE=A9=E3=82=92?=
=?UTF-8?q?=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/lib/valibot.ts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lib/valibot.ts b/src/lib/valibot.ts
index 52f1f4de..e8179cec 100644
--- a/src/lib/valibot.ts
+++ b/src/lib/valibot.ts
@@ -59,7 +59,7 @@ export const projectCategories = [
"stage_1a",
"stage_university_hall",
"stage_united",
-];
+] as const;
export type ProjectCategory = (typeof projectCategories)[number];
const projectCategorySchema = union(
@@ -67,7 +67,7 @@ const projectCategorySchema = union(
"いずれかの企画区分を選択してください",
);
-export const projectAttributes = ["academic", "art", "official", "inside", "outside"];
+export const projectAttributes = ["academic", "art", "official", "inside", "outside"] as const;
export type ProjectAttribute = (typeof projectAttributes)[number];
export const projectPlaces = ["outside", "inside", "stage"];
From 7adc8d23f44c26b83b1e286a5f7330bb1b06741d Mon Sep 17 00:00:00 2001
From: s7tya <53410646+s7tya@users.noreply.github.com>
Date: Fri, 12 Apr 2024 16:38:34 +0900
Subject: [PATCH 03/14] =?UTF-8?q?=E7=94=B3=E8=AB=8B=E3=82=92=E4=BD=9C?=
=?UTF-8?q?=E6=88=90=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
panda.config.ts | 2 +-
.../committee/forms/new/FormFieldEditor.tsx | 15 ++
src/app/committee/forms/new/page.tsx | 161 ++++++++++++++++--
src/lib/textUtils.ts | 14 +-
4 files changed, 167 insertions(+), 25 deletions(-)
create mode 100644 src/app/committee/forms/new/FormFieldEditor.tsx
diff --git a/panda.config.ts b/panda.config.ts
index 7eb747a0..49a3bdeb 100644
--- a/panda.config.ts
+++ b/panda.config.ts
@@ -24,7 +24,7 @@ export default defineConfig({
},
tsukuba: {
purple: { value: "#60C" },
- }
+ },
},
},
},
diff --git a/src/app/committee/forms/new/FormFieldEditor.tsx b/src/app/committee/forms/new/FormFieldEditor.tsx
new file mode 100644
index 00000000..8d1b55ec
--- /dev/null
+++ b/src/app/committee/forms/new/FormFieldEditor.tsx
@@ -0,0 +1,15 @@
+import { FC } from "react";
+import { type FormField } from "./page";
+
+export const FormFieldEditor: FC<{ field: FormField }> = ({ field }) => {
+ switch (field.type) {
+ case "string":
+ return ;
+ case "int":
+ return ;
+ case "choose_one":
+ return ;
+ case "choose_many":
+ return ;
+ }
+};
diff --git a/src/app/committee/forms/new/page.tsx b/src/app/committee/forms/new/page.tsx
index ac838b4b..7ca96a92 100644
--- a/src/app/committee/forms/new/page.tsx
+++ b/src/app/committee/forms/new/page.tsx
@@ -1,12 +1,15 @@
"use client";
+import { client } from "@/lib/openapi";
import { getProjectAttributeText, getProjectCategoryText } from "@/lib/textUtils";
-import { projectAttributes, projectCategories } from "@/lib/valibot";
+import { ProjectAttribute, ProjectCategory, projectAttributes, projectCategories } from "@/lib/valibot";
import { css } from "@styled-system/css";
import { stack, visuallyHidden } from "@styled-system/patterns";
+import dayjs from "dayjs";
import { NextPage } from "next";
import { FC } from "react";
-import { useForm } from "react-hook-form";
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { FormFieldEditor } from "./FormFieldEditor";
const sectionTitleStyle = css({
fontSize: "xl",
@@ -50,8 +53,73 @@ const Divider: FC = () => {
return ;
};
+export type FormField = {
+ name: string;
+ description: string;
+ required: boolean;
+} & (
+ | {
+ type: "int";
+ min: number;
+ max: number;
+ }
+ | {
+ type: "string";
+ minLength: number;
+ maxLength: number;
+ allowNewline: boolean;
+ }
+ | {
+ type: "choose_one";
+ options: string[];
+ }
+ | {
+ type: "choose_many";
+ minSelection: number;
+ maxSelection: number;
+ options: string[];
+ }
+ | {
+ type: "file";
+ extensions: string[];
+ limit: number;
+ }
+);
+
+type CreateFormInput = {
+ starts_at: string;
+ ends_at: string;
+ title: string;
+ description: string;
+ categories: ProjectCategory[];
+ attributes: ProjectAttribute[];
+ attachments: string[];
+ items: FormField[];
+};
+
const CreateFormPage: NextPage = () => {
- const { register } = useForm();
+ const { register, control, handleSubmit } = useForm({
+ defaultValues: {
+ categories: [],
+ attributes: [],
+ attachments: [],
+ },
+ });
+ const { fields, append } = useFieldArray({ name: "items", control });
+
+ const onSubmit = handleSubmit((data) => {
+ const body = {
+ ...data,
+ attributes: data.attributes.length === 0 ? [...projectAttributes] : data.attributes,
+ categories: data.categories.length === 0 ? [...projectCategories] : data.categories,
+ starts_at: data.starts_at === "" ? dayjs().toISOString() : data.starts_at,
+ ends_at: dayjs(data.ends_at).toISOString(),
+ };
+
+ client.POST("/forms", {
+ body,
+ });
+ });
return (
@@ -106,11 +213,11 @@ const CreateFormPage: NextPage = () => {
@@ -133,14 +240,34 @@ const CreateFormPage: NextPage = () => {
-
+
+ {fields.map((field, index) => {
+ return ;
+ })}
+
+
+
);
diff --git a/src/lib/textUtils.ts b/src/lib/textUtils.ts
index fe7ad4f2..01659938 100644
--- a/src/lib/textUtils.ts
+++ b/src/lib/textUtils.ts
@@ -17,19 +17,19 @@ export const getProjectCategoryText = (category: ProjectCategory) => {
case "stage_university_hall":
return "ステージ企画(大学会館ステージ)";
}
-}
+};
export const getProjectAttributeText = (attribute: ProjectAttribute) => {
switch (attribute) {
case "academic":
- return "学術参加枠"
+ return "学術参加枠";
case "art":
- return "芸術祭参加枠"
+ return "芸術祭参加枠";
case "official":
- return "委員会企画"
+ return "委員会企画";
case "inside":
- return "屋内企画"
+ return "屋内企画";
case "outside":
- return "屋外企画"
+ return "屋外企画";
}
-}
+};
From 7a6fba60b8c09aca3aadfa85831428a95e532cae Mon Sep 17 00:00:00 2001
From: s7tya <53410646+s7tya@users.noreply.github.com>
Date: Fri, 12 Apr 2024 17:02:17 +0900
Subject: [PATCH 04/14] =?UTF-8?q?=E3=83=86=E3=82=AD=E3=82=B9=E3=83=88?=
=?UTF-8?q?=E9=A0=85=E7=9B=AE=E3=82=92=E3=82=B5=E3=83=9D=E3=83=BC=E3=83=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../committee/forms/new/FormFieldEditor.tsx | 41 ++++++++++++++++---
src/app/committee/forms/new/page.tsx | 20 ++++-----
2 files changed, 45 insertions(+), 16 deletions(-)
diff --git a/src/app/committee/forms/new/FormFieldEditor.tsx b/src/app/committee/forms/new/FormFieldEditor.tsx
index 8d1b55ec..3696013c 100644
--- a/src/app/committee/forms/new/FormFieldEditor.tsx
+++ b/src/app/committee/forms/new/FormFieldEditor.tsx
@@ -1,15 +1,44 @@
import { FC } from "react";
-import { type FormField } from "./page";
+import { CreateFormInput, type FormField } from "./page";
+import { UseFormRegister } from "react-hook-form";
-export const FormFieldEditor: FC<{ field: FormField }> = ({ field }) => {
+export const FormFieldEditor: FC<{ field: FormField; index: number; register: UseFormRegister }> = ({
+ field,
+ index,
+ register,
+}) => {
switch (field.type) {
case "string":
- return ;
+ return (
+
+ );
case "int":
- return ;
+ return <>>;
case "choose_one":
- return ;
+ return <>>;
case "choose_many":
- return ;
+ return <>>;
}
};
diff --git a/src/app/committee/forms/new/page.tsx b/src/app/committee/forms/new/page.tsx
index 7ca96a92..ed2428b6 100644
--- a/src/app/committee/forms/new/page.tsx
+++ b/src/app/committee/forms/new/page.tsx
@@ -65,9 +65,9 @@ export type FormField = {
}
| {
type: "string";
- minLength: number;
- maxLength: number;
- allowNewline: boolean;
+ min_length: number;
+ max_length: number;
+ allow_newline: boolean;
}
| {
type: "choose_one";
@@ -75,8 +75,8 @@ export type FormField = {
}
| {
type: "choose_many";
- minSelection: number;
- maxSelection: number;
+ min_selection: number;
+ max_selection: number;
options: string[];
}
| {
@@ -86,7 +86,7 @@ export type FormField = {
}
);
-type CreateFormInput = {
+export type CreateFormInput = {
starts_at: string;
ends_at: string;
title: string;
@@ -248,9 +248,9 @@ const CreateFormPage: NextPage = () => {
description: "",
required: false,
type: "string",
- minLength: 0,
- maxLength: 0,
- allowNewline: false,
+ min_length: 0,
+ max_length: 0,
+ allow_newline: false,
});
}}>
テキスト項目
@@ -263,7 +263,7 @@ const CreateFormPage: NextPage = () => {
{fields.map((field, index) => {
- return ;
+ return ;
})}
From 9bac1849915fd48479444a7dca1f0caf11f1483c Mon Sep 17 00:00:00 2001
From: s7tya <53410646+s7tya@users.noreply.github.com>
Date: Fri, 12 Apr 2024 17:22:54 +0900
Subject: [PATCH 05/14] =?UTF-8?q?=E3=81=A1=E3=82=87=E3=81=A3=E3=81=A8?=
=?UTF-8?q?=E3=81=A0=E3=81=91=E3=83=95=E3=82=A9=E3=83=BC=E3=83=A0=E3=82=92?=
=?UTF-8?q?=E3=82=B9=E3=82=BF=E3=82=A4=E3=83=AA=E3=83=B3=E3=82=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../committee/forms/new/FormFieldEditor.tsx | 95 +++++++++++++------
src/app/committee/forms/new/page.tsx | 2 +-
2 files changed, 65 insertions(+), 32 deletions(-)
diff --git a/src/app/committee/forms/new/FormFieldEditor.tsx b/src/app/committee/forms/new/FormFieldEditor.tsx
index 3696013c..a42851ae 100644
--- a/src/app/committee/forms/new/FormFieldEditor.tsx
+++ b/src/app/committee/forms/new/FormFieldEditor.tsx
@@ -1,44 +1,77 @@
import { FC } from "react";
-import { CreateFormInput, type FormField } from "./page";
+import { CreateFormInput, textInputStyle, type FormField } from "./page";
import { UseFormRegister } from "react-hook-form";
+import { checkboxFormStyle } from "@/components/formFields/styles";
+import { css } from "@styled-system/css";
export const FormFieldEditor: FC<{ field: FormField; index: number; register: UseFormRegister }> = ({
field,
index,
register,
}) => {
- switch (field.type) {
- case "string":
- return (
-
+ );
};
diff --git a/src/app/committee/forms/new/page.tsx b/src/app/committee/forms/new/page.tsx
index ed2428b6..bc17d9c3 100644
--- a/src/app/committee/forms/new/page.tsx
+++ b/src/app/committee/forms/new/page.tsx
@@ -41,7 +41,7 @@ const checkboxGrpupStyle = css({
gap: 1,
});
-const textInputStyle = css({
+export const textInputStyle = css({
border: "1px solid token(colors.gray.400)",
background: "gray.100",
rounded: "sm",
From df336cb60d91fd48c8a2bafe92e933875167f2d1 Mon Sep 17 00:00:00 2001
From: s7tya <53410646+s7tya@users.noreply.github.com>
Date: Fri, 12 Apr 2024 17:39:05 +0900
Subject: [PATCH 06/14] fix export
---
.../committee/forms/new/FormFieldEditor.tsx | 3 +-
src/app/committee/forms/new/page.tsx | 39 +------------------
src/app/committee/forms/new/styles.ts | 39 +++++++++++++++++++
3 files changed, 42 insertions(+), 39 deletions(-)
create mode 100644 src/app/committee/forms/new/styles.ts
diff --git a/src/app/committee/forms/new/FormFieldEditor.tsx b/src/app/committee/forms/new/FormFieldEditor.tsx
index a42851ae..c5440be6 100644
--- a/src/app/committee/forms/new/FormFieldEditor.tsx
+++ b/src/app/committee/forms/new/FormFieldEditor.tsx
@@ -1,8 +1,9 @@
import { FC } from "react";
-import { CreateFormInput, textInputStyle, type FormField } from "./page";
+import { CreateFormInput, type FormField } from "./page";
import { UseFormRegister } from "react-hook-form";
import { checkboxFormStyle } from "@/components/formFields/styles";
import { css } from "@styled-system/css";
+import { textInputStyle } from "./styles";
export const FormFieldEditor: FC<{ field: FormField; index: number; register: UseFormRegister }> = ({
field,
diff --git a/src/app/committee/forms/new/page.tsx b/src/app/committee/forms/new/page.tsx
index bc17d9c3..f144d221 100644
--- a/src/app/committee/forms/new/page.tsx
+++ b/src/app/committee/forms/new/page.tsx
@@ -10,44 +10,7 @@ import { NextPage } from "next";
import { FC } from "react";
import { Controller, useFieldArray, useForm } from "react-hook-form";
import { FormFieldEditor } from "./FormFieldEditor";
-
-const sectionTitleStyle = css({
- fontSize: "xl",
- fontWeight: "bold",
-});
-
-const descriptionStyle = css({
- fontSize: "sm",
- color: "gray.600",
-});
-
-const checkboxStyle = css({
- py: 1,
- px: 4,
- rounded: "full",
- background: "gray.200",
- color: "gray.500",
- fontSize: "sm",
- fontWeight: "bold",
- "&:has(:checked)": {
- background: "tsukuba.purple",
- color: "white",
- },
-});
-
-const checkboxGrpupStyle = css({
- display: "flex",
- flexWrap: "wrap",
- gap: 1,
-});
-
-export const textInputStyle = css({
- border: "1px solid token(colors.gray.400)",
- background: "gray.100",
- rounded: "sm",
- width: "full",
- padding: 2,
-});
+import { sectionTitleStyle, descriptionStyle, checkboxGrpupStyle, checkboxStyle, textInputStyle } from "./styles";
const Divider: FC = () => {
return ;
diff --git a/src/app/committee/forms/new/styles.ts b/src/app/committee/forms/new/styles.ts
new file mode 100644
index 00000000..c2ae281a
--- /dev/null
+++ b/src/app/committee/forms/new/styles.ts
@@ -0,0 +1,39 @@
+import { css } from "@styled-system/css";
+
+export const sectionTitleStyle = css({
+ fontSize: "xl",
+ fontWeight: "bold",
+});
+
+export const descriptionStyle = css({
+ fontSize: "sm",
+ color: "gray.600",
+});
+
+export const checkboxStyle = css({
+ py: 1,
+ px: 4,
+ rounded: "full",
+ background: "gray.200",
+ color: "gray.500",
+ fontSize: "sm",
+ fontWeight: "bold",
+ "&:has(:checked)": {
+ background: "tsukuba.purple",
+ color: "white",
+ },
+});
+
+export const checkboxGrpupStyle = css({
+ display: "flex",
+ flexWrap: "wrap",
+ gap: 1,
+});
+
+export const textInputStyle = css({
+ border: "1px solid token(colors.gray.400)",
+ background: "gray.100",
+ rounded: "sm",
+ width: "full",
+ padding: 2,
+});
From 2b5c9430b867385a80304886eda0325350ccc581 Mon Sep 17 00:00:00 2001
From: s7tya <53410646+s7tya@users.noreply.github.com>
Date: Fri, 12 Apr 2024 17:55:21 +0900
Subject: [PATCH 07/14] update styles
---
src/app/committee/forms/new/page.tsx | 35 ++++++++++++++++++++++------
src/components/Button.tsx | 3 ++-
2 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/src/app/committee/forms/new/page.tsx b/src/app/committee/forms/new/page.tsx
index f144d221..3847b7cb 100644
--- a/src/app/committee/forms/new/page.tsx
+++ b/src/app/committee/forms/new/page.tsx
@@ -11,6 +11,7 @@ import { FC } from "react";
import { Controller, useFieldArray, useForm } from "react-hook-form";
import { FormFieldEditor } from "./FormFieldEditor";
import { sectionTitleStyle, descriptionStyle, checkboxGrpupStyle, checkboxStyle, textInputStyle } from "./styles";
+import { Button } from "@/components/Button";
const Divider: FC = () => {
return ;
@@ -202,8 +203,19 @@ const CreateFormPage: NextPage = () => {
-
+
{fields.map((field, index) => {
return
;
})}
diff --git a/src/components/Button.tsx b/src/components/Button.tsx
index b9b3eefd..ae3662a7 100644
--- a/src/components/Button.tsx
+++ b/src/components/Button.tsx
@@ -3,7 +3,7 @@ import { ButtonHTMLAttributes, FC } from "react";
interface Props extends ButtonHTMLAttributes
{
color: "primary" | "secondary" | "blue";
- size?: "medium" | "big";
+ size?: "y" | "medium" | "big";
className?: string;
children: React.ReactNode;
}
@@ -49,6 +49,7 @@ export const Button: FC = ({ color, size = "medium", className, children,
},
},
size: {
+ y: { paddngIline: 0, paddingBlock: 1 },
medium: { paddingInline: 9, paddingBlock: 1 },
big: { paddingInline: 12, paddingBlock: 2 },
},
From 307ed86a971dfe64c6356ecdc8e03276b12efde6 Mon Sep 17 00:00:00 2001
From: s7tya <53410646+s7tya@users.noreply.github.com>
Date: Sat, 13 Apr 2024 02:16:19 +0900
Subject: [PATCH 08/14] fix
---
src/app/committee/news/[news_id]/edit/EditNewsForm.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/app/committee/news/[news_id]/edit/EditNewsForm.tsx b/src/app/committee/news/[news_id]/edit/EditNewsForm.tsx
index afe8a00a..86ccd0dd 100644
--- a/src/app/committee/news/[news_id]/edit/EditNewsForm.tsx
+++ b/src/app/committee/news/[news_id]/edit/EditNewsForm.tsx
@@ -65,7 +65,7 @@ export const EditNewsForm: FC<{
title: data.title,
body: data.body,
categories: categories as components["schemas"]["ProjectCategory"][],
- attributes: projectAttributes as components["schemas"]["ProjectAttribute"][],
+ attributes: projectAttributes as unknown as components["schemas"]["ProjectAttribute"][],
attachments: [],
},
})
From 6b1584779ebf2a6891c40c14a0e8fc0e16cdea59 Mon Sep 17 00:00:00 2001
From: s7tya <53410646+s7tya@users.noreply.github.com>
Date: Sat, 13 Apr 2024 03:00:11 +0900
Subject: [PATCH 09/14] fix openapi
---
schema.yml | 838 ++++++++++++++++++++++++------------------------
src/schema.d.ts | 12 +-
2 files changed, 422 insertions(+), 428 deletions(-)
diff --git a/schema.yml b/schema.yml
index 4b13e42c..53a21774 100644
--- a/schema.yml
+++ b/schema.yml
@@ -1,7 +1,7 @@
openapi: 3.1.0
info:
title: Sohosai Online System
- version: '1.0'
+ version: "1.0"
servers:
- url: http://localhost:3000
security:
@@ -28,7 +28,7 @@ paths:
get:
summary: サーバーの状態を確認する
responses:
- '200':
+ "200":
description: OK
/projects:
get:
@@ -37,32 +37,32 @@ paths:
- projects
- committee
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
type: array
items:
- $ref: '#/components/schemas/ProjectSummary'
- '401':
+ $ref: "#/components/schemas/ProjectSummary"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
post:
summary: 企画の作成
tags:
@@ -72,86 +72,86 @@ paths:
content:
application/json:
schema:
- $ref: '#/components/schemas/CreateProject'
+ $ref: "#/components/schemas/CreateProject"
responses:
- '201':
+ "201":
description: Created
content:
application/json:
schema:
- $ref: '#/components/schemas/CreatedProject'
- '400':
+ $ref: "#/components/schemas/CreatedProject"
+ "400":
description: Bad Request
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '422':
+ $ref: "#/components/schemas/Error"
+ "422":
description: Unprocessable Entity
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/projects/export:
get:
summary: 企画一覧のエクスポート
tags:
- committee
responses:
- '200':
+ "200":
description: OK
content:
text/csv:
schema:
type: string
- '401':
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/projects/me:
get:
summary: 自分が企画責任者・副企画責任者になっている企画の取得
tags:
- projects
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
- $ref: '#/components/schemas/Project'
- '401':
+ $ref: "#/components/schemas/Project"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/projects/{project_id}:
get:
summary: 特定のIDの企画の取得
@@ -165,36 +165,36 @@ paths:
type: string
required: true
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
- $ref: '#/components/schemas/Project'
- '401':
+ $ref: "#/components/schemas/Project"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
put:
summary: 特定のIDの企画の更新
tags:
@@ -211,46 +211,46 @@ paths:
content:
application/json:
schema:
- $ref: '#/components/schemas/UpdateProject'
+ $ref: "#/components/schemas/UpdateProject"
responses:
- '200':
+ "200":
description: OK
- '400':
+ "400":
description: Bad Request
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '401':
+ $ref: "#/components/schemas/Error"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '422':
+ $ref: "#/components/schemas/Error"
+ "422":
description: Unprocessable Entity
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
delete:
summary: 特定のIDの企画の削除
tags:
@@ -263,32 +263,32 @@ paths:
schema:
type: string
responses:
- '200':
+ "200":
description: OK
- '401':
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/users:
get:
summary: ユーザー一覧の取得
@@ -296,32 +296,32 @@ paths:
- users
- committee
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
type: array
items:
- $ref: '#/components/schemas/UserSummary'
- '401':
+ $ref: "#/components/schemas/UserSummary"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
post:
summary: ユーザーの作成
tags:
@@ -331,80 +331,80 @@ paths:
content:
application/json:
schema:
- $ref: '#/components/schemas/CreateUser'
+ $ref: "#/components/schemas/CreateUser"
responses:
- '201':
+ "201":
description: Created
content:
application/json:
schema:
- $ref: '#/components/schemas/CreatedUser'
- '400':
+ $ref: "#/components/schemas/CreatedUser"
+ "400":
description: Bad Request
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '422':
+ $ref: "#/components/schemas/Error"
+ "422":
description: Unprocessable Entity
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/users/export:
get:
summary: ユーザー一覧のエクスポート
tags:
- committee
responses:
- '200':
+ "200":
description: OK
content:
text/csv:
schema:
type: string
- '401':
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/users/me:
get:
summary: 自分のユーザーの取得
tags:
- users
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
- $ref: '#/components/schemas/User'
- '401':
+ $ref: "#/components/schemas/User"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/users/{user_id}:
get:
summary: 特定のIDのユーザーの取得
@@ -418,36 +418,36 @@ paths:
type: string
required: true
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
- $ref: '#/components/schemas/User'
- '401':
+ $ref: "#/components/schemas/User"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
put:
summary: 特定のIDのユーザーの更新
tags:
@@ -464,46 +464,46 @@ paths:
content:
application/json:
schema:
- $ref: '#/components/schemas/UpdateUser'
+ $ref: "#/components/schemas/UpdateUser"
responses:
- '200':
+ "200":
description: OK
- '400':
+ "400":
description: Bad Request
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '401':
+ $ref: "#/components/schemas/Error"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '422':
+ $ref: "#/components/schemas/Error"
+ "422":
description: Unprocessable Entity
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
delete:
summary: 特定のIDのユーザーの削除
tags:
@@ -516,36 +516,36 @@ paths:
schema:
type: string
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '401':
+ $ref: "#/components/schemas/Error"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/news:
get:
summary: ニュース一覧の取得
@@ -553,26 +553,26 @@ paths:
- news
- committee
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
type: array
items:
- $ref: '#/components/schemas/NewsSummary'
- '401':
+ $ref: "#/components/schemas/NewsSummary"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
post:
summary: ニュースの作成
tags:
@@ -583,44 +583,44 @@ paths:
content:
application/json:
schema:
- $ref: '#/components/schemas/CreateNews'
+ $ref: "#/components/schemas/CreateNews"
responses:
- '201':
+ "201":
description: Created
content:
application/json:
schema:
- $ref: '#/components/schemas/CreatedNews'
- '400':
+ $ref: "#/components/schemas/CreatedNews"
+ "400":
description: Bad Request
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '401':
+ $ref: "#/components/schemas/Error"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '422':
+ $ref: "#/components/schemas/Error"
+ "422":
description: Unprocessable Entity
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/news/{news_id}:
get:
summary: 特定のIDのニュースの取得
@@ -633,30 +633,30 @@ paths:
schema:
type: string
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
- $ref: '#/components/schemas/News'
- '401':
+ $ref: "#/components/schemas/News"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
put:
summary: 特定のIDのニュースの更新
tags:
@@ -673,46 +673,46 @@ paths:
content:
application/json:
schema:
- $ref: '#/components/schemas/UpdateNews'
+ $ref: "#/components/schemas/UpdateNews"
responses:
- '200':
+ "200":
description: OK
- '400':
+ "400":
description: Bad Request
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '401':
+ $ref: "#/components/schemas/Error"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '422':
+ $ref: "#/components/schemas/Error"
+ "422":
description: Unprocessable Entity
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
delete:
summary: 特定のIDのニュースの削除
tags:
@@ -725,32 +725,32 @@ paths:
schema:
type: string
responses:
- '200':
+ "200":
description: OK
- '401':
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/files:
get:
summary: ニュースの添付ファイル一覧の取得
@@ -758,32 +758,32 @@ paths:
- files
- committee
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
type: array
items:
- $ref: '#/components/schemas/FileInfo'
- '401':
+ $ref: "#/components/schemas/FileInfo"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
post:
summary: ファイルの作成
tags:
@@ -802,44 +802,44 @@ paths:
content:
multipart/form-data:
schema:
- $ref: '#/components/schemas/CreateFile'
+ $ref: "#/components/schemas/CreateFile"
responses:
- '201':
+ "201":
description: Created
content:
application/json:
schema:
- $ref: '#/components/schemas/CreatedFile'
- '400':
+ $ref: "#/components/schemas/CreatedFile"
+ "400":
description: Bad Request
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '401':
+ $ref: "#/components/schemas/Error"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '422':
+ $ref: "#/components/schemas/Error"
+ "422":
description: Unprocessable Entity
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/files/{file_id}:
get:
summary: 特定のIDのファイルの取得
@@ -852,30 +852,30 @@ paths:
schema:
type: string
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
- $ref: '#/components/schemas/File'
- '401':
+ $ref: "#/components/schemas/File"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
delete:
summary: 特定のIDのファイルの削除
tags:
@@ -888,26 +888,26 @@ paths:
schema:
type: string
responses:
- '200':
+ "200":
description: OK
- '401':
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/invitations:
get:
summary: 招待一覧の取得
@@ -915,32 +915,32 @@ paths:
- invitations
- committee
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
type: array
items:
- $ref: '#/components/schemas/Invitation'
- '401':
+ $ref: "#/components/schemas/Invitation"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
post:
summary: 招待の作成
tags:
@@ -951,44 +951,44 @@ paths:
content:
application/json:
schema:
- $ref: '#/components/schemas/CreateInvitation'
+ $ref: "#/components/schemas/CreateInvitation"
responses:
- '201':
+ "201":
description: Created
content:
application/json:
schema:
- $ref: '#/components/schemas/CreatedInvitation'
- '400':
+ $ref: "#/components/schemas/CreatedInvitation"
+ "400":
description: Bad Request
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '401':
+ $ref: "#/components/schemas/Error"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '422':
+ $ref: "#/components/schemas/Error"
+ "422":
description: Unprocessable Entity
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/invitations/{invitation_id}:
get:
summary: 特定のIDの招待の取得
@@ -1002,36 +1002,36 @@ paths:
schema:
type: string
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
- $ref: '#/components/schemas/Invitation'
- '401':
+ $ref: "#/components/schemas/Invitation"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
post:
summary: 特定のIDの招待の受諾
tags:
@@ -1043,32 +1043,32 @@ paths:
schema:
type: string
responses:
- '200':
+ "200":
description: OK
- '401':
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
delete:
summary: 招待の削除
tags:
@@ -1081,32 +1081,32 @@ paths:
schema:
type: string
responses:
- '200':
+ "200":
description: OK
- '401':
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/forms:
get:
summary: 申請一覧の取得
@@ -1119,38 +1119,38 @@ paths:
type: string
required: false
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
type: array
items:
- $ref: '#/components/schemas/FormSummary'
- '401':
+ $ref: "#/components/schemas/FormSummary"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
post:
summary: 申請の作成
tags:
@@ -1161,44 +1161,44 @@ paths:
content:
application/json:
schema:
- $ref: '#/components/schemas/CreateForm'
+ $ref: "#/components/schemas/CreateForm"
responses:
- '201':
+ "201":
description: Created
content:
application/json:
schema:
- $ref: '#/components/schemas/CreatedForm'
- '400':
+ $ref: "#/components/schemas/CreatedForm"
+ "400":
description: Bad Request
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '401':
+ $ref: "#/components/schemas/Error"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '422':
+ $ref: "#/components/schemas/Error"
+ "422":
description: Unprocessable Entity
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/forms/{form_id}:
get:
summary: 特定のIDの申請を取得
@@ -1211,30 +1211,30 @@ paths:
type: string
required: true
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
- $ref: '#/components/schemas/Form'
- '401':
+ $ref: "#/components/schemas/Form"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
put:
summary: 特定のIDの申請を更新
tags:
@@ -1251,46 +1251,46 @@ paths:
content:
application/json:
schema:
- $ref: '#/components/schemas/UpdateForm'
+ $ref: "#/components/schemas/UpdateForm"
responses:
- '200':
+ "200":
description: OK
- '400':
+ "400":
description: Bad Request
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '401':
+ $ref: "#/components/schemas/Error"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '422':
+ $ref: "#/components/schemas/Error"
+ "422":
description: Unprocessable Entity
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
delete:
summary: 特定のIDの申請を削除
tags:
@@ -1303,32 +1303,32 @@ paths:
type: string
required: true
responses:
- '200':
+ "200":
description: OK
- '401':
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/form-answers:
get:
summary: 申請の回答一覧を取得
@@ -1346,38 +1346,38 @@ paths:
type: string
required: false
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
type: array
items:
- $ref: '#/components/schemas/FormAnswerSummary'
- '401':
+ $ref: "#/components/schemas/FormAnswerSummary"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
post:
summary: 申請の回答を作成
tags:
@@ -1387,50 +1387,50 @@ paths:
content:
application/json:
schema:
- $ref: '#/components/schemas/CreateFormAnswer'
+ $ref: "#/components/schemas/CreateFormAnswer"
responses:
- '201':
+ "201":
description: Created
content:
application/json:
schema:
- $ref: '#/components/schemas/CreatedFormAnswer'
- '400':
+ $ref: "#/components/schemas/CreatedFormAnswer"
+ "400":
description: Bad Request
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '401':
+ $ref: "#/components/schemas/Error"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '422':
+ $ref: "#/components/schemas/Error"
+ "422":
description: Unprocessable Entity
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/form-answers/{form_answer_id}:
get:
summary: 申請の回答を取得
@@ -1443,38 +1443,38 @@ paths:
type: string
required: true
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
type: array
items:
- $ref: '#/components/schemas/FormAnswer'
- '401':
+ $ref: "#/components/schemas/FormAnswer"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
put:
summary: 申請の回答を更新
tags:
@@ -1490,70 +1490,70 @@ paths:
content:
application/json:
schema:
- $ref: '#/components/schemas/UpdateFormAnswer'
+ $ref: "#/components/schemas/UpdateFormAnswer"
responses:
- '200':
+ "200":
description: OK
- '400':
+ "400":
description: Bad Request
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '401':
+ $ref: "#/components/schemas/Error"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '403':
+ $ref: "#/components/schemas/Error"
+ "403":
description: Forbidden
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '404':
+ $ref: "#/components/schemas/Error"
+ "404":
description: Not Found
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '422':
+ $ref: "#/components/schemas/Error"
+ "422":
description: Unprocessable Entity
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
/project-application-period:
get:
summary: 企画募集期間を取得する
tags:
- projects
responses:
- '200':
+ "200":
description: OK
content:
application/json:
schema:
- $ref: '#/components/schemas/ProjectApplicationPeriod'
- '401':
+ $ref: "#/components/schemas/ProjectApplicationPeriod"
+ "401":
description: Unauthorized
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
- '500':
+ $ref: "#/components/schemas/Error"
+ "500":
description: Internal Server Error
content:
application/json:
schema:
- $ref: '#/components/schemas/Error'
+ $ref: "#/components/schemas/Error"
components:
securitySchemes:
Bearer:
@@ -1593,11 +1593,11 @@ components:
type: string
example: そぽたん焼き
category:
- $ref: '#/components/schemas/ProjectCategory'
+ $ref: "#/components/schemas/ProjectCategory"
attributes:
type: array
items:
- $ref: '#/components/schemas/ProjectAttribute'
+ $ref: "#/components/schemas/ProjectAttribute"
owner_id:
type: string
format: uuid
@@ -1638,11 +1638,11 @@ components:
type: string
example: そぽたんあいこうかい
category:
- $ref: '#/components/schemas/ProjectCategory'
+ $ref: "#/components/schemas/ProjectCategory"
attributes:
type: array
items:
- $ref: '#/components/schemas/ProjectAttribute'
+ $ref: "#/components/schemas/ProjectAttribute"
required:
- title
- kana_title
@@ -1680,11 +1680,11 @@ components:
type: string
example: そぽたんあいこうかい
category:
- $ref: '#/components/schemas/ProjectCategory'
+ $ref: "#/components/schemas/ProjectCategory"
attributes:
type: array
items:
- $ref: '#/components/schemas/ProjectAttribute'
+ $ref: "#/components/schemas/ProjectAttribute"
owner_id:
type: string
format: uuid
@@ -1745,12 +1745,12 @@ components:
type: string
example: そぽたんあいこうかい
category:
- $ref: '#/components/schemas/ProjectCategory'
+ $ref: "#/components/schemas/ProjectCategory"
example: foods_with_kitchen
attributes:
type: array
items:
- $ref: '#/components/schemas/ProjectAttribute'
+ $ref: "#/components/schemas/ProjectAttribute"
remarks:
type: string
nullable: true
@@ -1779,7 +1779,7 @@ components:
type: string
format: email
role:
- $ref: '#/components/schemas/UserRole'
+ $ref: "#/components/schemas/UserRole"
required:
- id
- name
@@ -1828,7 +1828,7 @@ components:
phone_number:
type: string
role:
- $ref: '#/components/schemas/UserRole'
+ $ref: "#/components/schemas/UserRole"
owned_project_id:
type: string
nullable: true
@@ -1867,7 +1867,7 @@ components:
phone_number:
type: string
role:
- $ref: '#/components/schemas/UserRole'
+ $ref: "#/components/schemas/UserRole"
required:
- name
- kana_name
@@ -1885,11 +1885,11 @@ components:
categories:
type: array
items:
- $ref: '#/components/schemas/ProjectCategory'
+ $ref: "#/components/schemas/ProjectCategory"
attributes:
type: array
items:
- $ref: '#/components/schemas/ProjectAttribute'
+ $ref: "#/components/schemas/ProjectAttribute"
updated_at:
type: string
format: date-time
@@ -1914,11 +1914,11 @@ components:
categories:
type: array
items:
- $ref: '#/components/schemas/ProjectCategory'
+ $ref: "#/components/schemas/ProjectCategory"
attributes:
type: array
items:
- $ref: '#/components/schemas/ProjectAttribute'
+ $ref: "#/components/schemas/ProjectAttribute"
required:
- title
- body
@@ -1951,11 +1951,11 @@ components:
categories:
type: array
items:
- $ref: '#/components/schemas/ProjectCategory'
+ $ref: "#/components/schemas/ProjectCategory"
attributes:
type: array
items:
- $ref: '#/components/schemas/ProjectAttribute'
+ $ref: "#/components/schemas/ProjectAttribute"
created_at:
type: string
format: date-time
@@ -1990,11 +1990,11 @@ components:
categories:
type: array
items:
- $ref: '#/components/schemas/ProjectCategory'
+ $ref: "#/components/schemas/ProjectCategory"
attributes:
type: array
items:
- $ref: '#/components/schemas/ProjectAttribute'
+ $ref: "#/components/schemas/ProjectAttribute"
required:
- title
- body
@@ -2148,21 +2148,21 @@ components:
starts_at:
type: string
format: date-time
- example: '2024-03-16T09:00:00Z'
+ example: "2024-03-16T09:00:00Z"
ends_at:
type: string
format: date-time
- example: '2024-03-20T18:00:00Z'
+ example: "2024-03-20T18:00:00Z"
categories:
type: array
description: 対象となる企画区分
items:
- $ref: '#/components/schemas/ProjectCategory'
+ $ref: "#/components/schemas/ProjectCategory"
attributes:
type: array
description: 対象となる企画属性
items:
- $ref: '#/components/schemas/ProjectAttribute'
+ $ref: "#/components/schemas/ProjectAttribute"
answer_id:
type: string
format: uuid
@@ -2174,7 +2174,7 @@ components:
updated_at:
type: string
format: date-time
- example: '2024-03-15T14:45:00Z'
+ example: "2024-03-15T14:45:00Z"
required:
- id
- title
@@ -2199,10 +2199,11 @@ components:
type: string
description:
type: string
+ nullable: true
required:
type: boolean
type:
- $ref: '#/components/schemas/FormItemType'
+ $ref: "#/components/schemas/FormItemType"
min:
type: integer
nullable: true
@@ -2241,7 +2242,6 @@ components:
nullable: true
required:
- name
- - description
- required
- type
CreateForm:
@@ -2256,23 +2256,23 @@ components:
starts_at:
type: string
format: date-time
- example: '2024-03-16T09:00:00Z'
+ example: "2024-03-16T09:00:00Z"
ends_at:
type: string
format: date-time
- example: '2024-03-20T18:00:00Z'
+ example: "2024-03-20T18:00:00Z"
categories:
type: array
items:
- $ref: '#/components/schemas/ProjectCategory'
+ $ref: "#/components/schemas/ProjectCategory"
attributes:
type: array
items:
- $ref: '#/components/schemas/ProjectAttribute'
+ $ref: "#/components/schemas/ProjectAttribute"
items:
type: array
items:
- $ref: '#/components/schemas/NewFormItem'
+ $ref: "#/components/schemas/NewFormItem"
attachments:
type: array
items:
@@ -2308,7 +2308,7 @@ components:
required:
type: boolean
type:
- $ref: '#/components/schemas/FormItemType'
+ $ref: "#/components/schemas/FormItemType"
min:
type: integer
nullable: true
@@ -2412,23 +2412,23 @@ components:
starts_at:
type: string
format: date-time
- example: '2024-03-16T09:00:00Z'
+ example: "2024-03-16T09:00:00Z"
ends_at:
type: string
format: date-time
- example: '2024-03-20T18:00:00Z'
+ example: "2024-03-20T18:00:00Z"
categories:
type: array
items:
- $ref: '#/components/schemas/ProjectCategory'
+ $ref: "#/components/schemas/ProjectCategory"
attributes:
type: array
items:
- $ref: '#/components/schemas/ProjectAttribute'
+ $ref: "#/components/schemas/ProjectAttribute"
items:
type: array
items:
- $ref: '#/components/schemas/FormItem'
+ $ref: "#/components/schemas/FormItem"
attachments:
type: array
items:
@@ -2445,11 +2445,11 @@ components:
created_at:
type: string
format: date-time
- example: '2024-03-15T10:30:00Z'
+ example: "2024-03-15T10:30:00Z"
updated_at:
type: string
format: date-time
- example: '2024-03-15T14:45:00Z'
+ example: "2024-03-15T14:45:00Z"
deleted_at:
type: string
format: date-time
@@ -2479,23 +2479,23 @@ components:
starts_at:
type: string
format: date-time
- example: '2024-03-16T09:00:00Z'
+ example: "2024-03-16T09:00:00Z"
ends_at:
type: string
format: date-time
- example: '2024-03-20T18:00:00Z'
+ example: "2024-03-20T18:00:00Z"
categories:
type: array
items:
- $ref: '#/components/schemas/ProjectCategory'
+ $ref: "#/components/schemas/ProjectCategory"
attributes:
type: array
items:
- $ref: '#/components/schemas/ProjectAttribute'
+ $ref: "#/components/schemas/ProjectAttribute"
items:
type: array
items:
- $ref: '#/components/schemas/NewFormItem'
+ $ref: "#/components/schemas/NewFormItem"
attachments:
type: array
items:
@@ -2543,7 +2543,7 @@ components:
type: string
format: uuid
type:
- $ref: '#/components/schemas/FormItemType'
+ $ref: "#/components/schemas/FormItemType"
value: {}
required:
- item_id
@@ -2556,7 +2556,7 @@ components:
type: string
format: uuid
items:
- $ref: '#/components/schemas/FormAnswerItem'
+ $ref: "#/components/schemas/FormAnswerItem"
required:
- form_id
- items
@@ -2585,7 +2585,7 @@ components:
form_title:
type: string
items:
- $ref: '#/components/schemas/FormAnswerItem'
+ $ref: "#/components/schemas/FormAnswerItem"
created_at:
type: string
format: date-time
@@ -2609,7 +2609,7 @@ components:
type: object
properties:
items:
- $ref: '#/components/schemas/FormAnswerItem'
+ $ref: "#/components/schemas/FormAnswerItem"
required:
- items
ProjectApplicationPeriod:
diff --git a/src/schema.d.ts b/src/schema.d.ts
index cb849314..7213ea95 100644
--- a/src/schema.d.ts
+++ b/src/schema.d.ts
@@ -3,6 +3,7 @@
* Do not make direct changes to the file.
*/
+
export interface paths {
"/health": {
/** サーバーの状態を確認する */
@@ -1509,14 +1510,7 @@ export type webhooks = Record;
export interface components {
schemas: {
/** @enum {string} */
- ProjectCategory:
- | "general"
- | "foods_with_kitchen"
- | "foods_without_kitchen"
- | "foods_without_cooking"
- | "stage_1a"
- | "stage_university_hall"
- | "stage_united";
+ ProjectCategory: "general" | "foods_with_kitchen" | "foods_without_kitchen" | "foods_without_cooking" | "stage_1a" | "stage_university_hall" | "stage_united";
/** @enum {string} */
ProjectAttribute: "academic" | "art" | "official" | "inside" | "outside";
ProjectSummary: {
@@ -1784,7 +1778,7 @@ export interface components {
FormItemType: "string" | "int" | "choose_one" | "choose_many" | "file";
NewFormItem: {
name: string;
- description: string;
+ description?: string | null;
required: boolean;
type: components["schemas"]["FormItemType"];
min?: number | null;
From 698c7024ee21a19afe7078c8080b4aeb235ffa45 Mon Sep 17 00:00:00 2001
From: s7tya <53410646+s7tya@users.noreply.github.com>
Date: Sat, 13 Apr 2024 03:22:58 +0900
Subject: [PATCH 10/14] =?UTF-8?q?=E3=81=A8=E3=82=8A=E3=81=82=E3=81=88?=
=?UTF-8?q?=E3=81=9A=E3=83=AD=E3=82=B8=E3=83=83=E3=82=AF=E3=82=92=E5=AE=9F?=
=?UTF-8?q?=E8=A3=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../committee/forms/new/FormFieldEditor.tsx | 203 ++++++++++++++----
src/app/committee/forms/new/page.tsx | 79 +++++--
2 files changed, 218 insertions(+), 64 deletions(-)
diff --git a/src/app/committee/forms/new/FormFieldEditor.tsx b/src/app/committee/forms/new/FormFieldEditor.tsx
index c5440be6..44b3dab9 100644
--- a/src/app/committee/forms/new/FormFieldEditor.tsx
+++ b/src/app/committee/forms/new/FormFieldEditor.tsx
@@ -1,15 +1,33 @@
import { FC } from "react";
-import { CreateFormInput, type FormField } from "./page";
-import { UseFormRegister } from "react-hook-form";
+import { CreateFormInput, FormFieldType, type FormField } from "./page";
+import { UseFieldArrayMove, UseFormRegister } from "react-hook-form";
import { checkboxFormStyle } from "@/components/formFields/styles";
import { css } from "@styled-system/css";
import { textInputStyle } from "./styles";
+import { hstack } from "@styled-system/patterns";
-export const FormFieldEditor: FC<{ field: FormField; index: number; register: UseFormRegister }> = ({
- field,
- index,
- register,
-}) => {
+const getFieldTypeText = (type: FormFieldType): string => {
+ switch (type) {
+ case "string":
+ return "テキスト";
+ case "int":
+ return "数値";
+ case "choose_one":
+ return "ドロップダウン";
+ case "choose_many":
+ return "チェックボックス";
+ default:
+ return "unreachable";
+ }
+};
+
+export const FormFieldEditor: FC<{
+ field: FormField;
+ index: number;
+ register: UseFormRegister;
+ remove: () => void;
+ move: UseFieldArrayMove;
+}> = ({ field, index, register, remove, move }) => {
return (
+
{
+ move(index, index - 1);
+ }}>
+ ^
+
+
+
+
+
+
+
+
+
+
+
+
+
{(() => {
switch (field.type) {
case "string":
return (
<>
-
テキスト項目
-
-
+
+
+
+
+
-
+ >
+ );
+ case "int":
+ return (
+ <>
+
+
+
+
+
-
-
-
-
-
-
-
>
);
- case "int":
- return <>>;
case "choose_one":
return <>>;
case "choose_many":
- return <>>;
+ return (
+ <>
+
+ >
+ );
}
})()}
+
+ {
+
{
+ move(index, index + 1);
+ }}>
+ v
+
+ }
);
};
diff --git a/src/app/committee/forms/new/page.tsx b/src/app/committee/forms/new/page.tsx
index 3847b7cb..d3652d30 100644
--- a/src/app/committee/forms/new/page.tsx
+++ b/src/app/committee/forms/new/page.tsx
@@ -19,19 +19,19 @@ const Divider: FC = () => {
export type FormField = {
name: string;
- description: string;
+ description?: string;
required: boolean;
} & (
| {
type: "int";
- min: number;
- max: number;
+ min?: number;
+ max?: number;
}
| {
type: "string";
- min_length: number;
- max_length: number;
- allow_newline: boolean;
+ min_length?: number;
+ max_length?: number;
+ allow_newline?: boolean;
}
| {
type: "choose_one";
@@ -39,8 +39,8 @@ export type FormField = {
}
| {
type: "choose_many";
- min_selection: number;
- max_selection: number;
+ min_selection?: number;
+ max_selection?: number;
options: string[];
}
| {
@@ -50,6 +50,9 @@ export type FormField = {
}
);
+type ExtractFormFieldType
= T extends { type: infer U } ? U : never;
+export type FormFieldType = ExtractFormFieldType;
+
export type CreateFormInput = {
starts_at: string;
ends_at: string;
@@ -69,7 +72,7 @@ const CreateFormPage: NextPage = () => {
attachments: [],
},
});
- const { fields, append } = useFieldArray({ name: "items", control });
+ const { fields, append, remove, move } = useFieldArray({ name: "items", control });
const onSubmit = handleSubmit((data) => {
const body = {
@@ -220,23 +223,54 @@ const CreateFormPage: NextPage = () => {
onClick={() => {
append({
name: "",
- description: "",
required: false,
type: "string",
- min_length: 0,
- max_length: 0,
- allow_newline: false,
});
}}>
テキスト項目
-
+ {
+ append({
+ name: "",
+ required: false,
+ type: "int",
+ });
+ }}>
+ 数値項目
+
+ {
+ append({
+ name: "",
+ type: "choose_many",
+ required: false,
+ options: [],
+ });
+ }}>
チェックボックス項目
-
+ {
+ append({
+ name: "",
+ type: "choose_one",
+ required: false,
+ options: [],
+ });
+ }}>
ドロップダウン項目
-
+ {}}>
ファイル項目
@@ -247,7 +281,18 @@ const CreateFormPage: NextPage = () => {
gap: 4,
})}>
{fields.map((field, index) => {
- return
;
+ return (
+
{
+ remove(index);
+ }}
+ />
+ );
})}
From dc1f4e7aaf3a153337b4b18c57a628e0549c1c67 Mon Sep 17 00:00:00 2001
From: s7tya <53410646+s7tya@users.noreply.github.com>
Date: Sat, 13 Apr 2024 04:02:24 +0900
Subject: [PATCH 11/14] =?UTF-8?q?=E3=82=A2=E3=82=A4=E3=82=B3=E3=83=B3?=
=?UTF-8?q?=E3=82=92=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../committee/forms/new/FormFieldEditor.tsx | 40 +++++++++++++++----
src/components/assets/pulldownMenu.svg | 2 +-
2 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/src/app/committee/forms/new/FormFieldEditor.tsx b/src/app/committee/forms/new/FormFieldEditor.tsx
index 44b3dab9..69229908 100644
--- a/src/app/committee/forms/new/FormFieldEditor.tsx
+++ b/src/app/committee/forms/new/FormFieldEditor.tsx
@@ -4,7 +4,11 @@ import { UseFieldArrayMove, UseFormRegister } from "react-hook-form";
import { checkboxFormStyle } from "@/components/formFields/styles";
import { css } from "@styled-system/css";
import { textInputStyle } from "./styles";
-import { hstack } from "@styled-system/patterns";
+import { hstack, stack } from "@styled-system/patterns";
+
+import pulldownMenu from "@/components/assets/pulldownMenu.svg";
+import trashOutline from "@/components/assets/TrashOutline.svg";
+import Image from "next/image";
const getFieldTypeText = (type: FormFieldType): string => {
switch (type) {
@@ -30,17 +34,28 @@ export const FormFieldEditor: FC<{
}> = ({ field, index, register, remove, move }) => {
return (
{
move(index, index - 1);
- }}>
- ^
+ }}
+ className={css({
+ justifySelf: "center",
+ })}>
+
-
{getFieldTypeText(field.type)}項目
+
+ {getFieldTypeText(field.type)}項目
+
@@ -178,8 +199,11 @@ export const FormFieldEditor: FC<{
type="button"
onClick={() => {
move(index, index + 1);
- }}>
- v
+ }}
+ className={css({
+ justifySelf: "center",
+ })}>
+
}
diff --git a/src/components/assets/pulldownMenu.svg b/src/components/assets/pulldownMenu.svg
index 98e0b1a1..3fba2dd9 100644
--- a/src/components/assets/pulldownMenu.svg
+++ b/src/components/assets/pulldownMenu.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
From aef3c5e0d5cfc39c76f1f63fabcc7ed8c520a697 Mon Sep 17 00:00:00 2001
From: s7tya <53410646+s7tya@users.noreply.github.com>
Date: Sat, 13 Apr 2024 04:04:22 +0900
Subject: [PATCH 12/14] format
---
src/schema.d.ts | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/schema.d.ts b/src/schema.d.ts
index 7213ea95..c10cb88f 100644
--- a/src/schema.d.ts
+++ b/src/schema.d.ts
@@ -3,7 +3,6 @@
* Do not make direct changes to the file.
*/
-
export interface paths {
"/health": {
/** サーバーの状態を確認する */
@@ -1510,7 +1509,14 @@ export type webhooks = Record
;
export interface components {
schemas: {
/** @enum {string} */
- ProjectCategory: "general" | "foods_with_kitchen" | "foods_without_kitchen" | "foods_without_cooking" | "stage_1a" | "stage_university_hall" | "stage_united";
+ ProjectCategory:
+ | "general"
+ | "foods_with_kitchen"
+ | "foods_without_kitchen"
+ | "foods_without_cooking"
+ | "stage_1a"
+ | "stage_university_hall"
+ | "stage_united";
/** @enum {string} */
ProjectAttribute: "academic" | "art" | "official" | "inside" | "outside";
ProjectSummary: {
From a43d2e8036366e8b7ade72fd0c5646a1f1cbbc3f Mon Sep 17 00:00:00 2001
From: s7tya <53410646+s7tya@users.noreply.github.com>
Date: Sun, 14 Apr 2024 23:56:39 +0900
Subject: [PATCH 13/14] fix
---
src/app/committee/news/[news_id]/edit/EditNewsForm.tsx | 2 +-
src/app/committee/news/new/NewNewsForm.tsx | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/app/committee/news/[news_id]/edit/EditNewsForm.tsx b/src/app/committee/news/[news_id]/edit/EditNewsForm.tsx
index 86ccd0dd..0182f09c 100644
--- a/src/app/committee/news/[news_id]/edit/EditNewsForm.tsx
+++ b/src/app/committee/news/[news_id]/edit/EditNewsForm.tsx
@@ -65,7 +65,7 @@ export const EditNewsForm: FC<{
title: data.title,
body: data.body,
categories: categories as components["schemas"]["ProjectCategory"][],
- attributes: projectAttributes as unknown as components["schemas"]["ProjectAttribute"][],
+ attributes: [...projectAttributes] as components["schemas"]["ProjectAttribute"][],
attachments: [],
},
})
diff --git a/src/app/committee/news/new/NewNewsForm.tsx b/src/app/committee/news/new/NewNewsForm.tsx
index c3621c23..c26d216b 100644
--- a/src/app/committee/news/new/NewNewsForm.tsx
+++ b/src/app/committee/news/new/NewNewsForm.tsx
@@ -34,7 +34,7 @@ export const NewNewsForm = () => {
title: data.title,
body: data.body,
categories: categories as components["schemas"]["ProjectCategory"][],
- attributes: projectAttributes as components["schemas"]["ProjectAttribute"][],
+ attributes: [...projectAttributes] as components["schemas"]["ProjectAttribute"][],
attachments: [],
},
})
From d514251831cbe9bb3a3c6ec59a8a06661a6f48f6 Mon Sep 17 00:00:00 2001
From: s7tya <53410646+s7tya@users.noreply.github.com>
Date: Mon, 15 Apr 2024 01:16:58 +0900
Subject: [PATCH 14/14] fix
---
.../committee/forms/new/FormFieldEditor.tsx | 14 ++++++-
src/app/committee/forms/new/page.tsx | 39 +++++++++++++++----
2 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/src/app/committee/forms/new/FormFieldEditor.tsx b/src/app/committee/forms/new/FormFieldEditor.tsx
index 69229908..23261090 100644
--- a/src/app/committee/forms/new/FormFieldEditor.tsx
+++ b/src/app/committee/forms/new/FormFieldEditor.tsx
@@ -166,10 +166,22 @@ export const FormFieldEditor: FC<{
>
);
case "choose_one":
- return <>>;
+ return (
+ <>
+
+
+
+
+ >
+ );
case "choose_many":
return (
<>
+
+
+
+
+
diff --git a/src/app/committee/forms/new/page.tsx b/src/app/committee/forms/new/page.tsx
index d3652d30..bc32003b 100644
--- a/src/app/committee/forms/new/page.tsx
+++ b/src/app/committee/forms/new/page.tsx
@@ -12,6 +12,8 @@ import { Controller, useFieldArray, useForm } from "react-hook-form";
import { FormFieldEditor } from "./FormFieldEditor";
import { sectionTitleStyle, descriptionStyle, checkboxGrpupStyle, checkboxStyle, textInputStyle } from "./styles";
import { Button } from "@/components/Button";
+import { useRouter } from "next/navigation";
+import toast from "react-hot-toast";
const Divider: FC = () => {
return
;
@@ -35,13 +37,13 @@ export type FormField = {
}
| {
type: "choose_one";
- options: string[];
+ options: string;
}
| {
type: "choose_many";
min_selection?: number;
max_selection?: number;
- options: string[];
+ options: string;
}
| {
type: "file";
@@ -65,6 +67,8 @@ export type CreateFormInput = {
};
const CreateFormPage: NextPage = () => {
+ const router = useRouter();
+
const { register, control, handleSubmit } = useForm
({
defaultValues: {
categories: [],
@@ -81,11 +85,32 @@ const CreateFormPage: NextPage = () => {
categories: data.categories.length === 0 ? [...projectCategories] : data.categories,
starts_at: data.starts_at === "" ? dayjs().toISOString() : data.starts_at,
ends_at: dayjs(data.ends_at).toISOString(),
+ items: [
+ ...data.items.map((item) => {
+ if (item.type !== "choose_many" && item.type !== "choose_one") {
+ return item;
+ }
+
+ return {
+ ...item,
+ options: item.options.split("\n"),
+ };
+ }),
+ ],
};
- client.POST("/forms", {
- body,
- });
+ client
+ .POST("/forms", {
+ body,
+ })
+ .then((res) => {
+ if (!res.error) {
+ toast.success("申請を作成しました");
+ router.push("/committee/forms");
+ } else {
+ toast.error("申請の作成に失敗しました");
+ }
+ });
});
return (
@@ -251,7 +276,7 @@ const CreateFormPage: NextPage = () => {
name: "",
type: "choose_many",
required: false,
- options: [],
+ options: "",
});
}}>
チェックボックス項目
@@ -265,7 +290,7 @@ const CreateFormPage: NextPage = () => {
name: "",
type: "choose_one",
required: false,
- options: [],
+ options: "",
});
}}>
ドロップダウン項目