From e9e0a574da770eabf70cb1866c0c51e1036dca54 Mon Sep 17 00:00:00 2001 From: bicochan Date: Tue, 10 Jun 2025 17:37:57 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=84=A4=EB=AC=B8=20=EA=B2=B0=EA=B3=BC?= =?UTF-8?q?=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=B6=94=EA=B0=80=20=EC=9E=91?= =?UTF-8?q?=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../survey/model/question-table-columns.tsx | 2 +- .../pages/survey/model/survey-interface.ts | 2 +- .../pages/survey/ui/question-add-dialog.tsx | 8 ++++- apps/cs/src/pages/survey/ui/question-form.tsx | 6 ++-- .../pages/survey/ui/user-survey-article.tsx | 2 +- .../pages/survey/ui/user-survey-result.tsx | 33 ++++++++++--------- .../src/shared/lib/use-mutation-wrapper.tsx | 11 ++++--- 7 files changed, 36 insertions(+), 28 deletions(-) diff --git a/apps/cs/src/pages/survey/model/question-table-columns.tsx b/apps/cs/src/pages/survey/model/question-table-columns.tsx index 39cf4b902..357b25adb 100644 --- a/apps/cs/src/pages/survey/model/question-table-columns.tsx +++ b/apps/cs/src/pages/survey/model/question-table-columns.tsx @@ -12,7 +12,7 @@ import { ArticleManagementDialog } from "../ui/article-management-dialog"; const QUESTION_TYPE = { RADIO: "객관식", - CHECK: "다중응답", + CHECKBOX: "다중응답", INPUT: "주관식", } as const; diff --git a/apps/cs/src/pages/survey/model/survey-interface.ts b/apps/cs/src/pages/survey/model/survey-interface.ts index 030a4ff7b..b7d8f6027 100644 --- a/apps/cs/src/pages/survey/model/survey-interface.ts +++ b/apps/cs/src/pages/survey/model/survey-interface.ts @@ -3,7 +3,7 @@ import type { PageableList, PageableParams } from "@/shared/model"; export const QUESTION_TYPE_CODE = { RADIO: "RADIO", - CHECK: "CHECK", + CHECKBOX: "CHECKBOX", INPUT: "INPUT", } as const; diff --git a/apps/cs/src/pages/survey/ui/question-add-dialog.tsx b/apps/cs/src/pages/survey/ui/question-add-dialog.tsx index 643e788af..4af6e6a4f 100644 --- a/apps/cs/src/pages/survey/ui/question-add-dialog.tsx +++ b/apps/cs/src/pages/survey/ui/question-add-dialog.tsx @@ -1,3 +1,4 @@ +import { useEffect } from "react"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { useQueryClient } from "@tanstack/react-query"; @@ -11,6 +12,7 @@ import { DialogTitle, DialogTrigger, } from "@common/components"; +import { ENDPOINT } from "@/shared/config"; import { useAlertStore, useMutationWrapper } from "@/shared/lib"; import { questionFormSchema, @@ -18,7 +20,6 @@ import { } from "../model/survey-interface"; import { QuestionForm } from "./question-form"; import { SurveyApi } from "../api/survey-service"; -import { ENDPOINT } from "@/shared/config"; type QuestionAddDialogProps = { srvySn: number; @@ -46,11 +47,16 @@ function QuestionAddDialog({ onOpenChange?.(false); }, }); + const form = useForm({ resolver: zodResolver(questionFormSchema), defaultValues: { maxChcCnt: 0, etcAnsYn: "N" }, }); + useEffect(() => { + if (!open) form.reset({ maxChcCnt: 0, etcAnsYn: "N" }); + }, [open]); + return ( diff --git a/apps/cs/src/pages/survey/ui/question-form.tsx b/apps/cs/src/pages/survey/ui/question-form.tsx index b722a4802..3ea196f8c 100644 --- a/apps/cs/src/pages/survey/ui/question-form.tsx +++ b/apps/cs/src/pages/survey/ui/question-form.tsx @@ -76,7 +76,7 @@ function QuestionForm({ form, actionSlot, handleSave }: QuestionFormProps) { @@ -107,7 +107,7 @@ function QuestionForm({ form, actionSlot, handleSave }: QuestionFormProps) { /> - {qstnTypeCd === "CHECK" && ( + {qstnTypeCd === "CHECKBOX" && ( 최대선택갯수 @@ -134,7 +134,7 @@ function QuestionForm({ form, actionSlot, handleSave }: QuestionFormProps) { )} - {(qstnTypeCd === "RADIO" || qstnTypeCd === "CHECK") && ( + {(qstnTypeCd === "RADIO" || qstnTypeCd === "CHECKBOX") && ( 기타답변여부 diff --git a/apps/cs/src/pages/survey/ui/user-survey-article.tsx b/apps/cs/src/pages/survey/ui/user-survey-article.tsx index 77644b944..066066c86 100644 --- a/apps/cs/src/pages/survey/ui/user-survey-article.tsx +++ b/apps/cs/src/pages/survey/ui/user-survey-article.tsx @@ -210,7 +210,7 @@ function UserSurveyArticle({ srvySn }: { srvySn: string }) { articles={item.articles} /> )} - {item.qstnTypeCd === "CHECK" && ( + {item.qstnTypeCd === "CHECKBOX" && ( )} - {item.qstnTypeCd === "CHECK" && ( + {item.qstnTypeCd === "CHECKBOX" && ( )} {item.qstnTypeCd === "INPUT" && ( @@ -181,7 +181,7 @@ function WithPieChartResult({ }, ], }; - const options = { + const options: ChartOptions<"pie"> = { plugins: { legend: { position: "right", @@ -197,12 +197,9 @@ function WithPieChartResult({ {data?.qstnCn} -
+
- } - /> +
@@ -247,12 +244,19 @@ function WithBarChartResult({ }, ], }; - const options = { + const options: ChartOptions<"bar"> = { plugins: { legend: { position: "bottom", }, }, + layout: { + padding: { + top: 40, + bottom: 20, + }, + }, + maintainAspectRatio: false, }; return ( @@ -263,12 +267,9 @@ function WithBarChartResult({ {data?.qstnCn} -
+
- } - /> +
@@ -301,7 +302,7 @@ function InputResult({ index: number; }) { return ( - <> +

{index + 1} @@ -328,7 +329,7 @@ function InputResult({

))} - + ); } diff --git a/apps/cs/src/shared/lib/use-mutation-wrapper.tsx b/apps/cs/src/shared/lib/use-mutation-wrapper.tsx index 171517845..ce119d2a7 100644 --- a/apps/cs/src/shared/lib/use-mutation-wrapper.tsx +++ b/apps/cs/src/shared/lib/use-mutation-wrapper.tsx @@ -17,11 +17,12 @@ export const useMutationWrapper = < let errorMessage = ""; if (error instanceof AxiosError) { - if (error.response?.status) errorMessage += `status: ${error.status}\n`; - if (error.response?.data.message) - errorMessage += `${error.response?.data.message}\n`; - if (error.response?.data.errors[0].message) - errorMessage += `${error.response?.data.errors[0].message}\n`; + if (error.response?.status) + errorMessage += `status: ${error.response.status}\n`; + if (error.response?.data?.message) + errorMessage += `${error.response.data.message}\n`; + if (error.response?.data?.errors[0]?.message) + errorMessage += `${error.response.data.errors[0].message}\n`; } alert(`[Error] ${errorMessage}`);