From 2fd7561a6dba7ff629f5940074ecb6660a7cebce Mon Sep 17 00:00:00 2001 From: ccwnc Date: Thu, 11 Apr 2024 17:16:11 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=93=B1=EB=A1=9D=20=EB=B0=8F=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=8A=A4?= =?UTF-8?q?=ED=82=A4=EB=A7=88=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/activities/schema.ts | 39 +++++++++++++++++++ src/components/createPage/PostForm/index.tsx | 2 +- src/components/editPage/EditForm/index.tsx | 2 +- src/constants/postForm.ts | 40 -------------------- 4 files changed, 41 insertions(+), 42 deletions(-) create mode 100644 src/apis/activities/schema.ts diff --git a/src/apis/activities/schema.ts b/src/apis/activities/schema.ts new file mode 100644 index 00000000..a724b1b9 --- /dev/null +++ b/src/apis/activities/schema.ts @@ -0,0 +1,39 @@ +import { z } from 'zod'; + +const POST_SCHEMA_DEFAULT = z.object({ + price: z.string(), + title: z.string().min(1), + description: z.string().min(5), +}); + +export const PostSchema = [ + POST_SCHEMA_DEFAULT.extend({ + headcount: z.string().min(1), + address: z.string().min(1), + discord: z.string().min(1), + date: z.string().min(1), + startTime: z.string().min(1), + endTime: z.string().min(1), + bannerImageUrl: z.string().optional(), + subImageUrls: z.string().optional(), + }), + + POST_SCHEMA_DEFAULT.extend({ + headcount: z.string().min(1), + discord: z.string().min(1), + date: z.string().min(1), + startTime: z.string().min(1), + endTime: z.string().min(1), + }), + + POST_SCHEMA_DEFAULT.extend({ + discord: z.string().min(1), + bannerImageUrl: z.string().optional(), + subImageUrls: z.string().optional(), + }), + + POST_SCHEMA_DEFAULT.extend({ + bannerImageUrl: z.string().optional(), + subImageUrls: z.string().optional(), + }), +]; diff --git a/src/components/createPage/PostForm/index.tsx b/src/components/createPage/PostForm/index.tsx index 3bdbe850..3881a4e4 100644 --- a/src/components/createPage/PostForm/index.tsx +++ b/src/components/createPage/PostForm/index.tsx @@ -11,6 +11,7 @@ import { useDaumPostcodePopup } from 'react-daum-postcode'; import { FormProvider, useForm } from 'react-hook-form'; import Activities from '@/apis/activities'; +import { PostSchema } from '@/apis/activities/schema'; import { ADDRESS_CUSTOM_THEME, ADDRESS_POPUP_SIZE, @@ -20,7 +21,6 @@ import { PAGE_PATHS, PAGE_PATHS_MAINLIST_BY_CATEGORY, PRICE_RADIO_LIST, - PostSchema, SCRIPT_URL, recruitmentTypes, } from '@/constants'; diff --git a/src/components/editPage/EditForm/index.tsx b/src/components/editPage/EditForm/index.tsx index 50afdff2..ba2c70e4 100644 --- a/src/components/editPage/EditForm/index.tsx +++ b/src/components/editPage/EditForm/index.tsx @@ -8,6 +8,7 @@ import { useDaumPostcodePopup } from 'react-daum-postcode'; import { FormProvider, useForm } from 'react-hook-form'; import Activities from '@/apis/activities'; +import { PostSchema } from '@/apis/activities/schema'; import { MyActivities } from '@/apis/myActivities'; import { ADDRESS_CUSTOM_THEME, @@ -17,7 +18,6 @@ import { DEFAULT_API_DATA_BANNER_IMAGE, PAGE_PATHS, PRICE_RADIO_LIST, - PostSchema, SCRIPT_URL, recruitmentTypes, } from '@/constants'; diff --git a/src/constants/postForm.ts b/src/constants/postForm.ts index 1bd54154..97b66373 100644 --- a/src/constants/postForm.ts +++ b/src/constants/postForm.ts @@ -1,5 +1,3 @@ -import { z } from 'zod'; - import { POST_TYPES } from './postTypes'; export const PRICE_RADIO_LIST = [ @@ -9,44 +7,6 @@ export const PRICE_RADIO_LIST = [ { id: POST_TYPES['game-strategy'], label: POST_TYPES['game-strategy'], value: 3 }, ]; -const POST_SCHEMA_DEFAULT = z.object({ - price: z.string(), - title: z.string().min(1), - description: z.string().min(5), -}); - -export const PostSchema = [ - POST_SCHEMA_DEFAULT.extend({ - headcount: z.string().min(1), - address: z.string().min(1), - discord: z.string().min(1), - date: z.string().min(1), - startTime: z.string().min(1), - endTime: z.string().min(1), - bannerImageUrl: z.string().optional(), - subImageUrls: z.string().optional(), - }), - - POST_SCHEMA_DEFAULT.extend({ - headcount: z.string().min(1), - discord: z.string().min(1), - date: z.string().min(1), - startTime: z.string().min(1), - endTime: z.string().min(1), - }), - - POST_SCHEMA_DEFAULT.extend({ - discord: z.string().min(1), - bannerImageUrl: z.string().optional(), - subImageUrls: z.string().optional(), - }), - - POST_SCHEMA_DEFAULT.extend({ - bannerImageUrl: z.string().optional(), - subImageUrls: z.string().optional(), - }), -]; - export const SCRIPT_URL = '//t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js'; export const ADDRESS_POPUP_SIZE = {