From 957db2135fac1e0e321a849f2a6c18857fc92220 Mon Sep 17 00:00:00 2001 From: ChanWook Lee Date: Wed, 3 Jun 2026 20:23:44 +0900 Subject: [PATCH] =?UTF-8?q?Copilot=20=EB=A6=AC=EB=B7=B0=20=EA=B8=B0?= =?UTF-8?q?=EB=B0=98=20FE=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EB=B3=B4=EC=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/entry-codes-content.tsx | 4 +--- components/global-settings-content.tsx | 15 +++++++++++++-- lib/api/master-platform-settings.ts | 17 ++++++++++++++++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/components/entry-codes-content.tsx b/components/entry-codes-content.tsx index 6db6dd0..2e9a759 100644 --- a/components/entry-codes-content.tsx +++ b/components/entry-codes-content.tsx @@ -350,9 +350,7 @@ export function EntryCodesContent() { if (!isFutureDateTime(examEndsAt)) { setCreateExamValidationError(EXPIRES_AT_PAST_ERROR_MESSAGE) - if (!isFutureDateTime(examStartsAt)) { - shouldBlockSubmit = true - } + shouldBlockSubmit = true } else if (startDate && endDate && startDate >= endDate) { setCreateExamValidationError(ENDS_AT_BEFORE_STARTS_AT_ERROR_MESSAGE) shouldBlockSubmit = true diff --git a/components/global-settings-content.tsx b/components/global-settings-content.tsx index 3d0941e..30a3d53 100644 --- a/components/global-settings-content.tsx +++ b/components/global-settings-content.tsx @@ -40,6 +40,17 @@ function formStatesEqual(a: FormState, b: FormState): boolean { ) } +/** 서버에서 내려온 label이 RETENTION_DAY_OPTIONS에 없을 때 Select value 매칭용 */ +function buildRetentionSelectOptions(selectedLabel: string) { + if (RETENTION_DAY_OPTIONS.some((o) => o.label === selectedLabel)) { + return [...RETENTION_DAY_OPTIONS] + } + return [ + ...RETENTION_DAY_OPTIONS, + { label: selectedLabel, days: retentionLabelToDays(selectedLabel) }, + ] +} + export function GlobalSettingsContent() { const [form, setForm] = useState(null) const [savedForm, setSavedForm] = useState(null) @@ -193,7 +204,7 @@ export function GlobalSettingsContent() { - {RETENTION_DAY_OPTIONS.map((opt) => ( + {buildRetentionSelectOptions(form.logRetentionLabel).map((opt) => ( {opt.label} @@ -216,7 +227,7 @@ export function GlobalSettingsContent() { - {RETENTION_DAY_OPTIONS.map((opt) => ( + {buildRetentionSelectOptions(form.submissionRetentionLabel).map((opt) => ( {opt.label} diff --git a/lib/api/master-platform-settings.ts b/lib/api/master-platform-settings.ts index 611caa2..7f59a48 100644 --- a/lib/api/master-platform-settings.ts +++ b/lib/api/master-platform-settings.ts @@ -24,7 +24,22 @@ export function daysToRetentionLabel(days: number): string { return found?.label ?? `${days}일` } +const RETENTION_LABEL_DAYS_PATTERN = /^(\d+)\s*일?\s*$/ + export function retentionLabelToDays(label: string): number { const found = RETENTION_DAY_OPTIONS.find((o) => o.label === label) - return found?.days ?? 90 + if (found) { + return found.days + } + + const trimmed = label.trim() + const parsed = trimmed.match(RETENTION_LABEL_DAYS_PATTERN) + if (parsed) { + const days = Number.parseInt(parsed[1], 10) + if (Number.isFinite(days) && days > 0) { + return days + } + } + + return 90 }