From a83a8298d21eaa83ee8e720544c7b8b9aeafc5d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Thu, 26 Feb 2026 15:25:36 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[calendar]=20=EB=8C=80=EB=9F=89=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=20=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EA=B8=B0=EC=A1=B4=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - BulkRegistrationDialog에 schedules prop 추가 - 다이얼로그 열릴 때 기존 등록 데이터를 텍스트로 변환하여 표시 - MNG 대량 등록과 동일한 동작 --- .../BulkRegistrationDialog.tsx | 25 ++++++++++++++++--- .../hr/CalendarManagement/index.tsx | 1 + 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/components/hr/CalendarManagement/BulkRegistrationDialog.tsx b/src/components/hr/CalendarManagement/BulkRegistrationDialog.tsx index b2330c90..2c6f8986 100644 --- a/src/components/hr/CalendarManagement/BulkRegistrationDialog.tsx +++ b/src/components/hr/CalendarManagement/BulkRegistrationDialog.tsx @@ -1,13 +1,13 @@ 'use client'; -import { useState, useMemo } from 'react'; +import { useState, useMemo, useEffect } from 'react'; import { Loader2, Info } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog'; import { Textarea } from '@/components/ui/textarea'; import { Badge } from '@/components/ui/badge'; import { toast } from 'sonner'; -import type { BulkScheduleItem, CalendarScheduleType } from './types'; +import type { BulkScheduleItem, CalendarSchedule, CalendarScheduleType } from './types'; import { SCHEDULE_TYPE_LABELS, SCHEDULE_TYPE_BADGE_COLORS } from './types'; import { bulkCreateCalendarSchedules } from './actions'; @@ -15,6 +15,7 @@ interface BulkRegistrationDialogProps { open: boolean; onOpenChange: (open: boolean) => void; onSuccess: () => void; + schedules?: CalendarSchedule[]; } const TYPE_KEYWORD_MAP: Record = { @@ -65,10 +66,28 @@ function parseBulkText(text: string): BulkScheduleItem[] { return items; } -export function BulkRegistrationDialog({ open, onOpenChange, onSuccess }: BulkRegistrationDialogProps) { +function schedulesToText(schedules: CalendarSchedule[]): string { + return schedules.map((s) => { + const datePart = s.startDate === s.endDate ? s.startDate : `${s.startDate}~${s.endDate}`; + const typePart = s.type !== 'publicHoliday' ? ` [${SCHEDULE_TYPE_LABELS[s.type]}]` : ''; + return `${datePart} ${s.name}${typePart}`; + }).join('\n'); +} + +export function BulkRegistrationDialog({ open, onOpenChange, onSuccess, schedules }: BulkRegistrationDialogProps) { const [text, setText] = useState(''); const [isSaving, setIsSaving] = useState(false); + useEffect(() => { + if (open) { + if (schedules && schedules.length > 0) { + setText(schedulesToText(schedules)); + } else { + setText(''); + } + } + }, [open, schedules]); + const parsedItems = useMemo(() => parseBulkText(text), [text]); const validItems = parsedItems.filter((item) => item.isValid); diff --git a/src/components/hr/CalendarManagement/index.tsx b/src/components/hr/CalendarManagement/index.tsx index 5c401c0c..323faad1 100644 --- a/src/components/hr/CalendarManagement/index.tsx +++ b/src/components/hr/CalendarManagement/index.tsx @@ -285,6 +285,7 @@ export function CalendarManagement() { open={bulkOpen} onOpenChange={setBulkOpen} onSuccess={loadData} + schedules={schedules} /> );