refactor: AdminSchedule, AdminScheduleForm 날짜 파싱에 formatDate 유틸리티 적용
- AdminSchedule.jsx: hasSchedule, getScheduleColor, filteredSchedules에서 formatDate 사용 - AdminScheduleForm.jsx: 수정 모드 날짜 로드 시 formatDate 사용 - toISOString 대신 dayjs 기반 formatDate 사용
This commit is contained in:
parent
0d72dfe456
commit
d0b78f0b5d
2 changed files with 7 additions and 10 deletions
|
|
@ -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;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue