diff --git a/components/form-contents/InputKnowing.tsx b/components/form-contents/InputKnowing.tsx index 7808ce5..efa523d 100644 --- a/components/form-contents/InputKnowing.tsx +++ b/components/form-contents/InputKnowing.tsx @@ -35,10 +35,16 @@ const InputKnowing = () => { { @@ -57,12 +63,18 @@ const InputKnowing = () => { { diff --git a/pages/surveys/hooks/useSurveyForm.ts b/pages/surveys/hooks/useSurveyForm.ts index 36c224a..bae5059 100644 --- a/pages/surveys/hooks/useSurveyForm.ts +++ b/pages/surveys/hooks/useSurveyForm.ts @@ -2,10 +2,33 @@ import { useForm } from 'react-hook-form' import { z } from 'zod' import { zodResolver } from '@hookform/resolvers/zod' +export const period = [ + '', + 'ALL', + 'SIX_MONTHS', + 'ONE_YEAR', + 'FOUR_YEARS', + 'INFINITE', +] as const + +export const route = [ + '', + 'ALL', + 'ELEMENTARY_SCHOOL', + 'MIDDLE_AND_HIGH_SCHOOL', + 'UNIVERSITY', + 'WORK', + 'SOCIAL', + 'ETC', +] as const + const FormSchema = z.object({ - name: z.string().min(2).max(6), - knowingRoute: z.string(), - knowingPeriod: z.string(), + name: z + .string() + .min(2, { message: '2-6자로 입력해주세요' }) + .max(6, { message: '2-6자로 입력해주세요' }), + knowingRoute: z.enum(route), + knowingPeriod: z.enum(period), }) export type FormValues = z.infer diff --git a/pages/surveys/index.tsx b/pages/surveys/index.tsx index fa65bf8..38de993 100644 --- a/pages/surveys/index.tsx +++ b/pages/surveys/index.tsx @@ -5,6 +5,7 @@ import { FunnelProvider } from '@/contexts/useFunnelContext' import InputName from '@/components/form-contents/InputName' import InputKnowing from '@/components/form-contents/InputKnowing' import useSurveyForm from './hooks/useSurveyForm' +import { ReactNode } from 'react' const { Funnel, Step, useFunnel } = createFunnel([ 'inputName', @@ -17,7 +18,16 @@ const Page = () => { const form = useSurveyForm() return ( - <> + toPrevStep(), + }, + }} + > { - - ) -} - -Page.getLayout = () => { - //eslint-disable-next-line - const { toPrevStep } = useFunnel() - return ( - toPrevStep(), - }, - }} - > - ) } + +Page.getLayout = (page: ReactNode) => page export default Page