From d0b78f0b5d1c5cead6ea33bc40964a3e129b9ff4 Mon Sep 17 00:00:00 2001 From: caadiq Date: Fri, 9 Jan 2026 09:57:51 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20AdminSchedule,=20AdminScheduleForm?= =?UTF-8?q?=20=EB=82=A0=EC=A7=9C=20=ED=8C=8C=EC=8B=B1=EC=97=90=20formatDat?= =?UTF-8?q?e=20=EC=9C=A0=ED=8B=B8=EB=A6=AC=ED=8B=B0=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - AdminSchedule.jsx: hasSchedule, getScheduleColor, filteredSchedules에서 formatDate 사용 - AdminScheduleForm.jsx: 수정 모드 날짜 로드 시 formatDate 사용 - toISOString 대신 dayjs 기반 formatDate 사용 --- frontend/src/pages/pc/admin/AdminSchedule.jsx | 8 ++++---- frontend/src/pages/pc/admin/AdminScheduleForm.jsx | 9 +++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/frontend/src/pages/pc/admin/AdminSchedule.jsx b/frontend/src/pages/pc/admin/AdminSchedule.jsx index c5ed412..1e8fe48 100644 --- a/frontend/src/pages/pc/admin/AdminSchedule.jsx +++ b/frontend/src/pages/pc/admin/AdminSchedule.jsx @@ -11,7 +11,7 @@ import { useInView } from 'react-intersection-observer'; import Toast from '../../../components/Toast'; import Tooltip from '../../../components/Tooltip'; import useScheduleStore from '../../../stores/useScheduleStore'; -import { getTodayKST } from '../../../utils/date'; +import { getTodayKST, formatDate } from '../../../utils/date'; function AdminSchedule() { const navigate = useNavigate(); @@ -170,7 +170,7 @@ function AdminSchedule() { const hasSchedule = (day) => { const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`; return schedules.some(s => { - const scheduleDate = new Date(s.date).toISOString().split('T')[0]; + const scheduleDate = formatDate(s.date); return scheduleDate === dateStr; }); }; @@ -179,7 +179,7 @@ function AdminSchedule() { const getScheduleColor = (day) => { const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`; const schedule = schedules.find(s => { - const scheduleDate = new Date(s.date).toISOString().split('T')[0]; + const scheduleDate = formatDate(s.date); return scheduleDate === dateStr; }); if (!schedule) return null; @@ -394,7 +394,7 @@ function AdminSchedule() { ? (searchTerm ? searchResults : []) // 검색 모드: 검색 전엔 빈 목록, 검색 후엔 API 결과 : schedules.filter(schedule => { // 일반 모드: 로컬 필터링 const matchesCategory = selectedCategories.length === 0 || selectedCategories.includes(schedule.category_id); - const scheduleDate = new Date(schedule.date).toISOString().split('T')[0]; + const scheduleDate = formatDate(schedule.date); const matchesDate = !selectedDate || scheduleDate === selectedDate; return matchesCategory && matchesDate; }); diff --git a/frontend/src/pages/pc/admin/AdminScheduleForm.jsx b/frontend/src/pages/pc/admin/AdminScheduleForm.jsx index 159c838..28f8264 100644 --- a/frontend/src/pages/pc/admin/AdminScheduleForm.jsx +++ b/frontend/src/pages/pc/admin/AdminScheduleForm.jsx @@ -1,6 +1,7 @@ import { useState, useEffect, useRef } from "react"; import { useNavigate, Link, useParams } from "react-router-dom"; import { motion, AnimatePresence } from "framer-motion"; +import { formatDate } from "../../../utils/date"; import { LogOut, Home, @@ -898,12 +899,8 @@ function AdminScheduleForm() { // 폼 데이터 설정 setFormData({ title: data.title || "", - startDate: data.date - ? new Date(data.date).toISOString().split("T")[0] - : "", - endDate: data.end_date - ? new Date(data.end_date).toISOString().split("T")[0] - : "", + startDate: data.date ? formatDate(data.date) : "", + endDate: data.end_date ? formatDate(data.end_date) : "", startTime: data.time?.slice(0, 5) || "", endTime: data.end_time?.slice(0, 5) || "", isRange: !!data.end_date,