From a12390672ae17b9902af85d4590d5c549c6403bd Mon Sep 17 00:00:00 2001 From: bicochan Date: Wed, 7 May 2025 15:50:23 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D/=EC=88=98=EC=A0=95=20=EC=9C=A0=ED=9A=A8=EC=84=B1=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=20=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pst/bbsnotice/[bbsId]/register/page.tsx | 10 +++++++- .../ui/management-authority-dialog.tsx | 2 +- .../src/entities/post/api/post-service.ts | 24 +++++++++++-------- .../src/entities/post/model/post-interface.ts | 3 +-- .../entities/posting/ui/posting-dialog.tsx | 2 +- .../src/pages/notice/ui/create-page.tsx | 4 ++-- .../src/pages/notice/ui/modify-page.tsx | 9 +++++-- 7 files changed, 35 insertions(+), 19 deletions(-) diff --git a/apps/common/features/app/(with-base-layout)/pst/bbsnotice/[bbsId]/register/page.tsx b/apps/common/features/app/(with-base-layout)/pst/bbsnotice/[bbsId]/register/page.tsx index e4c9b57b1..f4357d80d 100644 --- a/apps/common/features/app/(with-base-layout)/pst/bbsnotice/[bbsId]/register/page.tsx +++ b/apps/common/features/app/(with-base-layout)/pst/bbsnotice/[bbsId]/register/page.tsx @@ -1,2 +1,10 @@ import { CreatePage } from "@/pages/notice"; -export default CreatePage; + +export default async function PstBbsNoticeRegisterPage({ + params, +}: { + params: Promise<{ bbsId: string }>; +}) { + const { bbsId } = await params; + return ; +} diff --git a/apps/common/features/src/entities/menu-authority/ui/management-authority-dialog.tsx b/apps/common/features/src/entities/menu-authority/ui/management-authority-dialog.tsx index a6d4d2128..d0b27b52c 100644 --- a/apps/common/features/src/entities/menu-authority/ui/management-authority-dialog.tsx +++ b/apps/common/features/src/entities/menu-authority/ui/management-authority-dialog.tsx @@ -15,7 +15,7 @@ import { DialogTrigger, } from "@common/components"; import { ENDPOINT } from "@/shared/config"; -import { useAlertStore } from "@/shared/lib/use-alert-store"; +import { useAlertStore } from "@/shared/lib"; import { menuAuthorityFormSchema, type MenuAuthorityFormData, diff --git a/apps/common/features/src/entities/post/api/post-service.ts b/apps/common/features/src/entities/post/api/post-service.ts index 0d0b442aa..dd145de23 100644 --- a/apps/common/features/src/entities/post/api/post-service.ts +++ b/apps/common/features/src/entities/post/api/post-service.ts @@ -1,13 +1,15 @@ import { client } from "@/shared/api"; import { ENDPOINT } from "@/shared/config"; -import type { - Post, - PostInfo, - PostList, - PostParams, - PostService, - PostFormData, - PostUpdateFormData, +import { + postFormSchema, + postUpdateFormSchema, + type Post, + type PostInfo, + type PostList, + type PostParams, + type PostService, + type PostFormData, + type PostUpdateFormData, } from "../model/post-interface"; export class PostApiService implements PostService { @@ -30,9 +32,10 @@ export class PostApiService implements PostService { } public async createPost(data: PostFormData): Promise { + const validatedData = postFormSchema.parse(data); const response = await client.post( `${ENDPOINT.BOARD_SERVICE.POSTS_USER}`, - data, + validatedData, ); return response.data; } @@ -42,9 +45,10 @@ export class PostApiService implements PostService { pstNo: string, data: PostUpdateFormData, ): Promise { + const validatedData = postUpdateFormSchema.parse(data); const response = await client.put( `${ENDPOINT.BOARD_SERVICE.POSTS_USER}/${bbsId}/${pstNo}`, - data, + validatedData, ); return response.data; } diff --git a/apps/common/features/src/entities/post/model/post-interface.ts b/apps/common/features/src/entities/post/model/post-interface.ts index 00b8cc403..338cb2b3f 100644 --- a/apps/common/features/src/entities/post/model/post-interface.ts +++ b/apps/common/features/src/entities/post/model/post-interface.ts @@ -41,7 +41,7 @@ export interface PostInfo extends Post { export const postFormSchema = z.object({ bbsId: z.number(), - pstTtl: z.string(), + pstTtl: z.string().nonempty(), pstCn: z.string().nullish(), rfrncUrl: z.string().nullish(), popupYn: z.string().nullish(), @@ -56,7 +56,6 @@ export const postFormSchema = z.object({ export const postUpdateFormSchema = postFormSchema.omit({ bbsId: true, - pstPswd: true, parentPstNo: true, }); diff --git a/apps/common/features/src/entities/posting/ui/posting-dialog.tsx b/apps/common/features/src/entities/posting/ui/posting-dialog.tsx index b0e155c44..3cf0eaeeb 100644 --- a/apps/common/features/src/entities/posting/ui/posting-dialog.tsx +++ b/apps/common/features/src/entities/posting/ui/posting-dialog.tsx @@ -28,6 +28,7 @@ import { import { CodeSelect } from "@/entities/code/@x/posting"; import { SiteApi, type Site } from "@/entities/site/@x/posting"; import type { PageableList } from "@/shared/model"; +import { useAlertStore } from "@/shared/lib"; import { ENDPOINT } from "@/shared/config"; import { PostingApi } from "../api/posting-service"; import { @@ -36,7 +37,6 @@ import { type PostingType, type PostPayload, } from "../model/posting-interface"; -import { useAlertStore } from "@/shared/lib/use-alert-store"; type DateRange = { from: string; diff --git a/apps/common/features/src/pages/notice/ui/create-page.tsx b/apps/common/features/src/pages/notice/ui/create-page.tsx index b79d5235f..91bf36301 100644 --- a/apps/common/features/src/pages/notice/ui/create-page.tsx +++ b/apps/common/features/src/pages/notice/ui/create-page.tsx @@ -9,7 +9,7 @@ import { PostApi, postFormSchema, type PostFormData } from "@/entities/post"; import { useAlertStore, useUserStore } from "@/shared/lib"; import { NoticeLayout } from "./notice-layout"; -function CreatePage() { +function CreatePage({ bbsId }: { bbsId: string }) { const router = useRouter(); const { userInfo } = useUserStore((state) => state); const { setMessage: alert } = useAlertStore((state) => state); @@ -24,7 +24,7 @@ function CreatePage() { const form = useForm({ resolver: zodResolver(postFormSchema), values: { - bbsId: 0, + bbsId: parseInt(bbsId), pstTtl: "", wrtrNm: userInfo?.userName ?? "", pstPswd: userInfo?.userUnqId ?? "", diff --git a/apps/common/features/src/pages/notice/ui/modify-page.tsx b/apps/common/features/src/pages/notice/ui/modify-page.tsx index 10f3c19ed..7049de20f 100644 --- a/apps/common/features/src/pages/notice/ui/modify-page.tsx +++ b/apps/common/features/src/pages/notice/ui/modify-page.tsx @@ -10,11 +10,12 @@ import { type PostUpdateFormData, } from "@/entities/post"; import { ENDPOINT } from "@/shared/config"; -import { useAlertStore } from "@/shared/lib/use-alert-store"; +import { useAlertStore, useUserStore } from "@/shared/lib"; import { NoticeLayout } from "./notice-layout"; function ModifyPage({ bbsId, pstNo }: { bbsId: string; pstNo: string }) { const { setMessage: alert } = useAlertStore((state) => state); + const { userInfo } = useUserStore((state) => state); const { data: postInfo } = useQuery({ queryKey: [ENDPOINT.BOARD_SERVICE.POSTS_USER, bbsId, pstNo], @@ -31,7 +32,11 @@ function ModifyPage({ bbsId, pstNo }: { bbsId: string; pstNo: string }) { const form = useForm({ resolver: zodResolver(postUpdateFormSchema), - values: postInfo, + values: { + ...postInfo, + pstTtl: postInfo?.pstTtl ?? "", + pstPswd: userInfo?.userUnqId ?? "", + }, }); return (