From edddd70996b05c4e091b6aa0af6c7f3ef7e690ee Mon Sep 17 00:00:00 2001 From: Masaya Tojo Date: Mon, 2 Sep 2024 00:42:51 +0900 Subject: react-query で取得した値でセレクトボックスを出すところまで実装 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/signUpSchema.ts | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/signUpSchema.ts') diff --git a/src/signUpSchema.ts b/src/signUpSchema.ts index 4d8b71f..3b75ba1 100644 --- a/src/signUpSchema.ts +++ b/src/signUpSchema.ts @@ -11,7 +11,7 @@ const form1SchemaWithoutRefine = z.object({ tel3: z.string(), }) -const addRefine = (schema: Form1) => ( +const addTelRefine = (schema: Form1Data) => ( schema.refine( ({ tel1, tel2, tel3 }) => (tel1.length > 0 && tel2.length > 0 && tel3.length > 0), { @@ -30,9 +30,6 @@ const addRefine = (schema: Form1) => ( } )) - -export type Form1 = z.infer - export const form2Schema = z.object({ email: z.string().min(1, { message: '必須項目です' }).email({ message: 'メールアドレスを入力してください' }), password: z.string() @@ -41,11 +38,24 @@ export const form2Schema = z.object({ .max(128, { message: '128文字以下で入力してください' }) }) -export type Form2 = z.infer +const favLangSchema = z.object({ + name: z.string() +}) + +export const form3Schema = z.object({ + // favLangs: z.array(favLangSchema), + hasGitHubRepo: z.boolean(), + gitHubUsername: z.string(), + repoName: z.string(), +}) -const formSchemaWithoutRefine = form1SchemaWithoutRefine.merge(form2Schema) +const formSchemaWithoutRefine = form1SchemaWithoutRefine.merge(form2Schema).merge(form3Schema) +export const form1Schema = addTelRefine(form1SchemaWithoutRefine) +export const formSchema = addTelRefine(formSchemaWithoutRefine) -export type Form = z.infer +export type Form1Data = z.infer +export type Form2Data = z.infer +export type Form3Data = z.infer +export type FormData = z.infer -export const form1Schema = addRefine(form1SchemaWithoutRefine) -export const formSchema = addRefine(formSchemaWithoutRefine) +export const displayTel = ({ tel1, tel2, tel3 }: Form1Data) => (`${tel1}-${tel2}-${tel3}`) -- cgit v1.2.3