diff --git a/apps/common/features/src/widgets/post/api/post-evaluation-service.ts b/apps/common/features/src/widgets/post/api/post-evaluation-service.ts new file mode 100644 index 000000000..9258ba299 --- /dev/null +++ b/apps/common/features/src/widgets/post/api/post-evaluation-service.ts @@ -0,0 +1,14 @@ +import { client } from "@/shared/api"; +import { ENDPOINT } from "@/shared/config"; +import type { + PostEvaluationPayload, + PostEvaluationService, +} from "../model/post-evaluation-interface"; + +export class PostEvaluationApiService implements PostEvaluationService { + public async postEvaluation(payload: PostEvaluationPayload) { + await client.post(ENDPOINT.BOARD_SERVICE.POST_EVALUATION, payload); + } +} + +export const PostEvaluationApi = new PostEvaluationApiService(); diff --git a/apps/common/features/src/widgets/post/model/post-evaluation-interface.ts b/apps/common/features/src/widgets/post/model/post-evaluation-interface.ts new file mode 100644 index 000000000..c99249d6a --- /dev/null +++ b/apps/common/features/src/widgets/post/model/post-evaluation-interface.ts @@ -0,0 +1,10 @@ +export interface PostEvaluationPayload { + pstNo: number; + evlIp?: string; + evlDt?: string; + evlScr: number; +} + +export interface PostEvaluationService { + postEvaluation: (payload: PostEvaluationPayload) => Promise; +} diff --git a/apps/common/features/src/widgets/post/ui/post.tsx b/apps/common/features/src/widgets/post/ui/post.tsx index 8033938cf..7c1c4c3b6 100644 --- a/apps/common/features/src/widgets/post/ui/post.tsx +++ b/apps/common/features/src/widgets/post/ui/post.tsx @@ -5,7 +5,13 @@ import Image from "next/image"; import { useEffect, useState } from "react"; import { useRouter } from "next/navigation"; import { useMutation, useQuery } from "@tanstack/react-query"; -import { Button, Skeleton } from "@common/components"; +import { + Button, + Label, + RadioGroup, + RadioGroupItem, + Skeleton, +} from "@common/components"; import { AttachmentApi } from "@/entities/attachment"; import { PostApi } from "@/entities/post"; import { @@ -17,6 +23,7 @@ import { import { ENDPOINT } from "@/shared/config"; import { PostAction } from "./post-action"; import { PostComment } from "./post-comment"; +import { PostEvaluationApi } from "../api/post-evaluation-service"; function Post({ bbsId, pstNo }: { bbsId: string; pstNo: string }) { const router = useRouter(); @@ -26,6 +33,7 @@ function Post({ bbsId, pstNo }: { bbsId: string; pstNo: string }) { const bbsInfo = useMenuStore((state) => state.bbsInfo); const [filename, setFilename] = useState(""); + const [evlScr, setEvlScr] = useState(5); const { data: postData } = useQuery({ queryKey: [ENDPOINT.BOARD_SERVICE.POSTS_USER, bbsId, pstNo], @@ -73,6 +81,17 @@ function Post({ bbsId, pstNo }: { bbsId: string; pstNo: string }) { }, }); + const { mutate: postEvaluation } = useMutation({ + mutationFn: (evlScr: number) => + PostEvaluationApi.postEvaluation({ + pstNo: parseInt(pstNo), + evlScr, + }), + onSuccess: () => { + alert("게시물 평가가 완료되었습니다."); + }, + }); + const handleDelete = async () => { let pstPswd = ""; if (userInfo?.userUnqId) { @@ -194,6 +213,53 @@ function Post({ bbsId, pstNo }: { bbsId: string; pstNo: string }) { ) )} + {bbsInfo?.dgstfnEvlUseYn === "Y" && ( + <> +
+
+

+ 이 페이지에서 제공하는 +
+ 정보에 대하여 만족하시나요? +

+
+ setEvlScr(parseInt(value))} + className="flex items-center space-x-4" + > +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+ + )}