임동욱 임동욱 08-21
fix: 퀴즈 수정이 포인트를 지우지 않게 한다
백엔드 UPDATE가 `QUIZ_POINT = #{quizPoint}`로 무조건 덮어쓰는데 화면이 그 값을 보내지 않아,
퀴즈를 한 번 수정하면 포인트가 NULL이 됐다. 기획에 입력 칸이 없는 값이라 화면에는 두지 않고
hidden으로 실어 그대로 돌려보낸다.

값이 없을 때는 키 자체를 빼서 보낸다 — 빈 문자열을 보내면 INT 컬럼에 ''가 들어간다.

확인(임시 프로브): 수정은 `quizPoint:"10"`이 실리고, 등록은 그 키가 빠진다.

Co-Authored-By: Claude Opus 5 
@b9569123e8a7cf4e71d06b757535fc45cec362a9
app/(protected)/(basic)/contents/_actions.ts
--- app/(protected)/(basic)/contents/_actions.ts
+++ app/(protected)/(basic)/contents/_actions.ts
@@ -173,6 +173,7 @@
   return {
     schoolCode: readString(formData, 'schoolCode'),
     grades: readGrades(formData),
+    points: readString(formData, 'quizPoint'),
     level: readString(formData, 'level'),
     keywords: readKeywords(formData),
     question: readString(formData, 'question'),
app/(protected)/(basic)/contents/quizzes/_components/quiz-form.tsx
--- app/(protected)/(basic)/contents/quizzes/_components/quiz-form.tsx
+++ app/(protected)/(basic)/contents/quizzes/_components/quiz-form.tsx
@@ -69,6 +69,8 @@
         className={styles.form}
       >
         {isEdit && <input type="hidden" name="quizSn" value={item.quizSn} />}
+        {/* 화면에 입력 칸이 없는 값이라 그대로 돌려보내 지워지지 않게 한다(도메인 주석 참조). */}
+        <input type="hidden" name="quizPoint" value={item?.points ?? ''} />
 
         {isEdit && (
           <ContentFormRow label="콘텐츠ID">
lib/data/repositories/content-quiz-repository.ts
--- lib/data/repositories/content-quiz-repository.ts
+++ lib/data/repositories/content-quiz-repository.ts
@@ -210,6 +210,8 @@
 }
 
 type QuizWritePayload = {
+  /** 값이 있을 때만 실어 보낸다 — 비어 있는 채로 보내면 백엔드가 NULL로 덮어쓴다. */
+  quizPoint?: string;
   quizTitle: string;
   quizLev: string;
   quizQuestion: string;
@@ -226,6 +228,7 @@
  */
 function buildQuizPayload(values: QuizFormValues): QuizWritePayload {
   return {
+    ...(values.points === '' ? {} : { quizPoint: values.points }),
     quizTitle: values.keywords.map((item) => item.keyword).join(', '),
     quizLev: values.level,
     quizQuestion: values.question,
@@ -247,6 +250,7 @@
   payload: QuizWritePayload
 ): Record<string, string | number | undefined> {
   const params: Record<string, string | number | undefined> = {
+    quizPoint: payload.quizPoint,
     quizTitle: payload.quizTitle,
     quizLev: payload.quizLev,
     quizQuestion: payload.quizQuestion,
lib/domain/content-form.ts
--- lib/domain/content-form.ts
+++ lib/domain/content-form.ts
@@ -77,6 +77,11 @@
 };
 
 export type QuizFormValues = GradeSelection & {
+  /**
+   * 기존 포인트. 화면에 입력 칸이 없지만(기획에 없다) 수정 시 그대로 돌려보내야 한다 —
+   * 백엔드 UPDATE가 `QUIZ_POINT = #{quizPoint}`로 무조건 덮어써서, 안 보내면 지워진다.
+   */
+  points: string;
   level: string;
   keywords: ContentKeyword[];
   question: string;
Add a comment
List