Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions components/entry-codes-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions components/global-settings-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<FormState | null>(null)
const [savedForm, setSavedForm] = useState<FormState | null>(null)
Expand Down Expand Up @@ -193,7 +204,7 @@ export function GlobalSettingsContent() {
<SelectValue placeholder="기간 선택" />
</SelectTrigger>
<SelectContent>
{RETENTION_DAY_OPTIONS.map((opt) => (
{buildRetentionSelectOptions(form.logRetentionLabel).map((opt) => (
<SelectItem key={opt.days} value={opt.label}>
{opt.label}
</SelectItem>
Expand All @@ -216,7 +227,7 @@ export function GlobalSettingsContent() {
<SelectValue placeholder="기간 선택" />
</SelectTrigger>
<SelectContent>
{RETENTION_DAY_OPTIONS.map((opt) => (
{buildRetentionSelectOptions(form.submissionRetentionLabel).map((opt) => (
<SelectItem key={opt.days} value={opt.label}>
{opt.label}
</SelectItem>
Expand Down
17 changes: 16 additions & 1 deletion lib/api/master-platform-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading