import { useParams, Link } from 'react-router-dom'; import { useQuery, keepPreviousData } from '@tanstack/react-query'; import { motion } from 'framer-motion'; import { Calendar, ChevronRight } from 'lucide-react'; import { getSchedule } from '@/api'; // 섹션 컴포넌트들 import { YoutubeSection, XSection, VarietySection, DefaultSection, decodeHtmlEntities } from './sections'; import Birthday from './Birthday'; /** * 특수 일정 ID 파싱 * @param {string} id - 일정 ID * @returns {object|null} { type, year, nameEn } 또는 null */ function parseSpecialId(id) { // birthday-{year}-{nameEn} 형식 const birthdayMatch = id.match(/^birthday-(\d{4})-(.+)$/); if (birthdayMatch) { return { type: 'birthday', year: birthdayMatch[1], nameEn: birthdayMatch[2] }; } // debut-{year} 형식 const debutMatch = id.match(/^debut-(\d{4})$/); if (debutMatch) { return { type: 'debut', year: debutMatch[1] }; } // anniversary-{year} 형식 const anniversaryMatch = id.match(/^anniversary-(\d{4})$/); if (anniversaryMatch) { return { type: 'anniversary', year: anniversaryMatch[1] }; } return null; } /** * PC 일정 상세 페이지 */ function PCScheduleDetail() { const { id } = useParams(); // 특수 일정 ID 체크 const specialId = parseSpecialId(id); if (specialId?.type === 'birthday') { return ; } const { data: schedule, isLoading, error, } = useQuery({ queryKey: ['schedule', id], queryFn: () => getSchedule(id), placeholderData: keepPreviousData, retry: false, }); if (isLoading) { return
; } if (error || !schedule) { return (
{/* 아이콘 */}
{/* 메시지 */}

일정을 찾을 수 없습니다

요청하신 일정이 존재하지 않거나 삭제되었을 수 있습니다.
다른 일정을 확인해 주세요.

{/* 장식 요소 */} {[...Array(5)].map((_, i) => ( ))} {/* 버튼들 */} 일정 목록
); } // 카테고리별 섹션 렌더링 const categoryName = schedule.category?.name; const renderCategorySection = () => { switch (categoryName) { case '유튜브': return ; case 'X': return ; case '예능': return ; default: return ; } }; const isYoutube = categoryName === '유튜브'; const isX = categoryName === 'X'; const isVariety = categoryName === '예능'; const hasCustomLayout = isYoutube || isX || isVariety; return (
{/* 브레드크럼 네비게이션 */} 일정 {schedule.category?.name} {decodeHtmlEntities(schedule.title)} {/* 메인 컨텐츠 */} {renderCategorySection()}
); } export default PCScheduleDetail;