feat: 생일 기능 추가 및 일정 페이지 개선

- 생일 카드 컴포넌트 추가 (PC/모바일)
- 생일 폭죽(confetti) 애니메이션 적용 (하루에 한 번)
- 생일 상세 페이지 추가 (/birthday/멤버이름/년도)
- 관리자 일정 페이지에 생일 표시 (수정/삭제 버튼 숨김)
- 일정 상세 페이지 404 에러 UI 개선
- 일정 상세 페이지 불필요한 재시도 방지 (retry: false)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
caadiq 2026-01-15 20:09:26 +09:00
parent 611a20a8f0
commit 6275f0f92a
10 changed files with 850 additions and 110 deletions

View file

@ -1320,6 +1320,58 @@ router.get("/schedules", async (req, res) => {
}) })
); );
// 년/월 필터가 있고 검색이 아닌 경우 생일 데이터 추가
if (year && month && !search) {
const [birthdays] = await pool.query(
`SELECT id, name, name_en, birth_date, image_url
FROM members
WHERE is_former = 0 AND MONTH(birth_date) = ?`,
[parseInt(month)]
);
const birthdaySchedules = birthdays.map((member) => {
const birthDate = new Date(member.birth_date);
const birthdayThisYear = new Date(
parseInt(year),
birthDate.getMonth(),
birthDate.getDate()
);
return {
id: `birthday-${member.id}`,
title: `HAPPY ${member.name_en} DAY`,
description: null,
date: birthdayThisYear,
time: null,
end_date: null,
end_time: null,
category_id: 8,
source_url: null,
source_name: null,
location_name: null,
location_address: null,
location_detail: null,
location_lat: null,
location_lng: null,
created_at: null,
category_name: "생일",
category_color: "#f472b6",
images: [],
members: [{ id: member.id, name: member.name }],
member_names: member.name,
is_birthday: true,
member_image: member.image_url,
};
});
// 일정과 생일을 합쳐서 날짜순 정렬
const allSchedules = [...schedulesWithDetails, ...birthdaySchedules].sort(
(a, b) => new Date(a.date) - new Date(b.date)
);
return res.json(allSchedules);
}
res.json(schedulesWithDetails); res.json(schedulesWithDetails);
} catch (error) { } catch (error) {
console.error("일정 조회 오류:", error); console.error("일정 조회 오류:", error);

View file

@ -110,6 +110,49 @@ router.get("/", async (req, res) => {
params params
); );
// 년/월 필터가 있으면 해당 월의 현재 멤버 생일을 가상 일정으로 추가
if (year && month) {
const [birthdays] = await pool.query(
`SELECT id, name, name_en, birth_date, image_url
FROM members
WHERE is_former = 0 AND MONTH(birth_date) = ?`,
[parseInt(month)]
);
const birthdaySchedules = birthdays.map((member) => {
const birthDate = new Date(member.birth_date);
const birthdayThisYear = new Date(
parseInt(year),
birthDate.getMonth(),
birthDate.getDate()
);
return {
id: `birthday-${member.id}`,
title: `HAPPY ${member.name_en} DAY`,
description: null,
date: birthdayThisYear,
time: null,
category_id: 8,
source_url: null,
source_name: null,
location_name: null,
category_name: "생일",
category_color: "#f472b6",
member_names: member.name,
is_birthday: true,
member_image: member.image_url,
};
});
// 일정과 생일을 합쳐서 날짜순 정렬
const allSchedules = [...schedules, ...birthdaySchedules].sort(
(a, b) => new Date(a.date) - new Date(b.date)
);
return res.json(allSchedules);
}
res.json(schedules); res.json(schedules);
} catch (error) { } catch (error) {
console.error("일정 목록 조회 오류:", error); console.error("일정 목록 조회 오류:", error);
@ -164,6 +207,16 @@ router.get("/:id", async (req, res) => {
); );
schedule.images = images.map((img) => img.image_url); schedule.images = images.map((img) => img.image_url);
// 멤버 조회
const [members] = await pool.query(
`SELECT m.id, m.name FROM members m
JOIN schedule_members sm ON m.id = sm.member_id
WHERE sm.schedule_id = ?
ORDER BY m.id`,
[id]
);
schedule.members = members;
// 콘서트 카테고리(id=6)인 경우 같은 제목의 관련 일정들도 조회 // 콘서트 카테고리(id=6)인 경우 같은 제목의 관련 일정들도 조회
if (schedule.category_id === 6) { if (schedule.category_id === 6) {
const [relatedSchedules] = await pool.query( const [relatedSchedules] = await pool.query(

View file

@ -10,6 +10,7 @@
"dependencies": { "dependencies": {
"@tanstack/react-query": "^5.90.16", "@tanstack/react-query": "^5.90.16",
"@tanstack/react-virtual": "^3.13.18", "@tanstack/react-virtual": "^3.13.18",
"canvas-confetti": "^1.9.4",
"dayjs": "^1.11.19", "dayjs": "^1.11.19",
"framer-motion": "^11.0.8", "framer-motion": "^11.0.8",
"lucide-react": "^0.344.0", "lucide-react": "^0.344.0",
@ -1464,6 +1465,16 @@
], ],
"license": "CC-BY-4.0" "license": "CC-BY-4.0"
}, },
"node_modules/canvas-confetti": {
"version": "1.9.4",
"resolved": "https://registry.npmjs.org/canvas-confetti/-/canvas-confetti-1.9.4.tgz",
"integrity": "sha512-yxQbJkAVrFXWNbTUjPqjF7G+g6pDotOUHGbkZq2NELZUMDpiJ85rIEazVb8GTaAptNW2miJAXbs1BtioA251Pw==",
"license": "ISC",
"funding": {
"type": "donate",
"url": "https://www.paypal.me/kirilvatev"
}
},
"node_modules/chokidar": { "node_modules/chokidar": {
"version": "3.6.0", "version": "3.6.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",

View file

@ -11,6 +11,7 @@
"dependencies": { "dependencies": {
"@tanstack/react-query": "^5.90.16", "@tanstack/react-query": "^5.90.16",
"@tanstack/react-virtual": "^3.13.18", "@tanstack/react-virtual": "^3.13.18",
"canvas-confetti": "^1.9.4",
"dayjs": "^1.11.19", "dayjs": "^1.11.19",
"framer-motion": "^11.0.8", "framer-motion": "^11.0.8",
"lucide-react": "^0.344.0", "lucide-react": "^0.344.0",

View file

@ -14,6 +14,7 @@ import PCAlbumGallery from './pages/pc/public/AlbumGallery';
import PCTrackDetail from './pages/pc/public/TrackDetail'; import PCTrackDetail from './pages/pc/public/TrackDetail';
import PCSchedule from './pages/pc/public/Schedule'; import PCSchedule from './pages/pc/public/Schedule';
import PCScheduleDetail from './pages/pc/public/ScheduleDetail'; import PCScheduleDetail from './pages/pc/public/ScheduleDetail';
import PCBirthday from './pages/pc/public/Birthday';
import PCNotFound from './pages/pc/public/NotFound'; import PCNotFound from './pages/pc/public/NotFound';
// //
@ -86,6 +87,7 @@ function App() {
<Route path="/album/:name/track/:trackTitle" element={<PCTrackDetail />} /> <Route path="/album/:name/track/:trackTitle" element={<PCTrackDetail />} />
<Route path="/schedule" element={<PCSchedule />} /> <Route path="/schedule" element={<PCSchedule />} />
<Route path="/schedule/:id" element={<PCScheduleDetail />} /> <Route path="/schedule/:id" element={<PCScheduleDetail />} />
<Route path="/birthday/:memberName/:year" element={<PCBirthday />} />
<Route path="*" element={<PCNotFound />} /> <Route path="*" element={<PCNotFound />} />
</Routes> </Routes>
</PCLayout> </PCLayout>

View file

@ -1,11 +1,70 @@
import { useState, useEffect, useMemo, useRef, useCallback } from 'react'; import { useState, useEffect, useMemo, useRef, useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import { motion, AnimatePresence } from 'framer-motion'; import { motion, AnimatePresence } from 'framer-motion';
import { Clock, Tag, Link2, ChevronLeft, ChevronRight, ChevronDown, Search, X, Calendar } from 'lucide-react'; import { Clock, Tag, Link2, ChevronLeft, ChevronRight, ChevronDown, Search, X, Calendar } from 'lucide-react';
import { useQuery, useInfiniteQuery } from '@tanstack/react-query'; import { useQuery, useInfiniteQuery } from '@tanstack/react-query';
import { useInView } from 'react-intersection-observer'; import { useInView } from 'react-intersection-observer';
import { useVirtualizer } from '@tanstack/react-virtual'; import { useVirtualizer } from '@tanstack/react-virtual';
import confetti from 'canvas-confetti';
import { getTodayKST } from '../../../utils/date';
import { getSchedules, getCategories, searchSchedules } from '../../../api/public/schedules'; import { getSchedules, getCategories, searchSchedules } from '../../../api/public/schedules';
//
const fireBirthdayConfetti = () => {
const duration = 3000;
const animationEnd = Date.now() + duration;
const colors = ['#ff69b4', '#ff1493', '#da70d6', '#ba55d3', '#9370db', '#8a2be2', '#ffd700', '#ff6347'];
const randomInRange = (min, max) => Math.random() * (max - min) + min;
const interval = setInterval(() => {
const timeLeft = animationEnd - Date.now();
if (timeLeft <= 0) {
clearInterval(interval);
return;
}
const particleCount = 50 * (timeLeft / duration);
//
confetti({
particleCount: Math.floor(particleCount),
startVelocity: 30,
spread: 60,
origin: { x: randomInRange(0.1, 0.3), y: Math.random() - 0.2 },
colors: colors,
shapes: ['circle', 'square'],
gravity: 1.2,
scalar: randomInRange(0.8, 1.2),
drift: randomInRange(-0.5, 0.5),
});
//
confetti({
particleCount: Math.floor(particleCount),
startVelocity: 30,
spread: 60,
origin: { x: randomInRange(0.7, 0.9), y: Math.random() - 0.2 },
colors: colors,
shapes: ['circle', 'square'],
gravity: 1.2,
scalar: randomInRange(0.8, 1.2),
drift: randomInRange(-0.5, 0.5),
});
}, 250);
//
confetti({
particleCount: 100,
spread: 100,
origin: { x: 0.5, y: 0.6 },
colors: colors,
shapes: ['circle', 'square'],
startVelocity: 45,
});
};
// HTML // HTML
const decodeHtmlEntities = (text) => { const decodeHtmlEntities = (text) => {
if (!text) return ''; if (!text) return '';
@ -14,8 +73,54 @@ const decodeHtmlEntities = (text) => {
return textarea.value; return textarea.value;
}; };
//
function MobileBirthdayCard({ schedule, onClick, delay = 0 }) {
return (
<motion.div
initial={{ opacity: 0, x: -10 }}
animate={{ opacity: 1, x: 0 }}
transition={{ delay, type: "spring", stiffness: 300, damping: 30 }}
onClick={onClick}
className="cursor-pointer"
>
<div className="relative overflow-hidden bg-gradient-to-r from-pink-400 via-purple-400 to-indigo-400 rounded-xl shadow-lg">
{/* 배경 장식 */}
<div className="absolute inset-0 overflow-hidden">
<div className="absolute -top-3 -right-3 w-16 h-16 bg-white/10 rounded-full" />
<div className="absolute -bottom-4 -left-4 w-20 h-20 bg-white/10 rounded-full" />
<div className="absolute bottom-3 left-8 text-sm animate-pulse">🎉</div>
</div>
<div className="relative flex items-center p-4 gap-3">
{/* 멤버 사진 */}
{schedule.member_image && (
<div className="flex-shrink-0">
<div className="w-14 h-14 rounded-full border-2 border-white/50 shadow-md overflow-hidden bg-white">
<img
src={schedule.member_image}
alt={schedule.member_names}
className="w-full h-full object-cover"
/>
</div>
</div>
)}
{/* 내용 */}
<div className="flex-1 text-white flex items-center gap-2 min-w-0">
<span className="text-2xl flex-shrink-0">🎂</span>
<h3 className="font-bold text-base tracking-wide truncate">
{decodeHtmlEntities(schedule.title)}
</h3>
</div>
</div>
</div>
</motion.div>
);
}
// //
function MobileSchedule() { function MobileSchedule() {
const navigate = useNavigate();
const [selectedDate, setSelectedDate] = useState(new Date()); const [selectedDate, setSelectedDate] = useState(new Date());
const [isSearchMode, setIsSearchMode] = useState(false); const [isSearchMode, setIsSearchMode] = useState(false);
const [searchInput, setSearchInput] = useState(''); // const [searchInput, setSearchInput] = useState(''); //
@ -161,6 +266,32 @@ function MobileSchedule() {
queryFn: () => getSchedules(viewYear, viewMonth), queryFn: () => getSchedules(viewYear, viewMonth),
}); });
// ( )
useEffect(() => {
if (loading || schedules.length === 0) return;
const today = getTodayKST();
const confettiKey = `birthday-confetti-${today}`;
//
if (localStorage.getItem(confettiKey)) return;
const hasBirthdayToday = schedules.some(s => {
if (!s.is_birthday) return false;
const scheduleDate = s.date ? s.date.split('T')[0] : '';
return scheduleDate === today;
});
if (hasBirthdayToday) {
// ( )
const timer = setTimeout(() => {
fireBirthdayConfetti();
localStorage.setItem(confettiKey, 'true');
}, 500);
return () => clearTimeout(timer);
}
}, [schedules, loading]);
// //
const changeMonth = (delta) => { const changeMonth = (delta) => {
const newDate = new Date(selectedDate); const newDate = new Date(selectedDate);
@ -723,15 +854,34 @@ function MobileSchedule() {
) : ( ) : (
// //
<div className="space-y-3"> <div className="space-y-3">
{selectedDateSchedules.map((schedule, index) => ( {selectedDateSchedules.map((schedule, index) => {
<TimelineScheduleCard const isBirthday = schedule.is_birthday || String(schedule.id).startsWith('birthday-');
key={schedule.id}
schedule={schedule} if (isBirthday) {
categoryColor={getCategoryColor(schedule.category_id)} return (
categories={categories} <MobileBirthdayCard
delay={index * 0.05} key={schedule.id}
/> schedule={schedule}
))} delay={index * 0.05}
onClick={() => {
const scheduleYear = new Date(schedule.date).getFullYear();
const memberName = schedule.member_names;
navigate(`/birthday/${encodeURIComponent(memberName)}/${scheduleYear}`);
}}
/>
);
}
return (
<TimelineScheduleCard
key={schedule.id}
schedule={schedule}
categoryColor={getCategoryColor(schedule.category_id)}
categories={categories}
delay={index * 0.05}
/>
);
})}
</div> </div>
)} )}
</div> </div>

View file

@ -38,6 +38,7 @@ const ScheduleItem = memo(function ScheduleItem({
openDeleteDialog openDeleteDialog
}) { }) {
const scheduleDate = new Date(schedule.date); const scheduleDate = new Date(schedule.date);
const isBirthday = schedule.is_birthday || String(schedule.id).startsWith('birthday-');
const categoryColor = getColorStyle(categories.find(c => c.id === schedule.category_id)?.color)?.style?.backgroundColor || '#6b7280'; const categoryColor = getColorStyle(categories.find(c => c.id === schedule.category_id)?.color)?.style?.backgroundColor || '#6b7280';
const categoryName = categories.find(c => c.id === schedule.category_id)?.name || '미분류'; const categoryName = categories.find(c => c.id === schedule.category_id)?.name || '미분류';
const memberNames = schedule.member_names || schedule.members?.map(m => m.name).join(',') || ''; const memberNames = schedule.member_names || schedule.members?.map(m => m.name).join(',') || '';
@ -103,31 +104,34 @@ const ScheduleItem = memo(function ScheduleItem({
)} )}
</div> </div>
<div className="flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity"> {/* 생일 일정은 수정/삭제 불가 */}
{schedule.source_url && ( {!isBirthday && (
<a <div className="flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity">
href={schedule.source_url} {schedule.source_url && (
target="_blank" <a
rel="noopener noreferrer" href={schedule.source_url}
onClick={(e) => e.stopPropagation()} target="_blank"
className="p-2 hover:bg-blue-100 rounded-lg transition-colors text-blue-500" rel="noopener noreferrer"
onClick={(e) => e.stopPropagation()}
className="p-2 hover:bg-blue-100 rounded-lg transition-colors text-blue-500"
>
<ExternalLink size={18} />
</a>
)}
<button
onClick={() => navigate(`/admin/schedule/${schedule.id}/edit`)}
className="p-2 hover:bg-gray-200 rounded-lg transition-colors text-gray-500"
> >
<ExternalLink size={18} /> <Edit2 size={18} />
</a> </button>
)} <button
<button onClick={() => openDeleteDialog(schedule)}
onClick={() => navigate(`/admin/schedule/${schedule.id}/edit`)} className="p-2 hover:bg-red-100 rounded-lg transition-colors text-red-500"
className="p-2 hover:bg-gray-200 rounded-lg transition-colors text-gray-500" >
> <Trash2 size={18} />
<Edit2 size={18} /> </button>
</button> </div>
<button )}
onClick={() => openDeleteDialog(schedule)}
className="p-2 hover:bg-red-100 rounded-lg transition-colors text-red-500"
>
<Trash2 size={18} />
</button>
</div>
</div> </div>
</motion.div> </motion.div>
); );

View file

@ -0,0 +1,207 @@
import { useParams, useNavigate } from 'react-router-dom';
import { useQuery } from '@tanstack/react-query';
import { motion } from 'framer-motion';
import { ArrowLeft, Calendar, MapPin, Clock } from 'lucide-react';
import { fetchApi } from '../../../api';
//
const memberEnglishName = {
'송하영': 'HAYOUNG',
'박지원': 'JIWON',
'이채영': 'CHAEYOUNG',
'이나경': 'NAKYUNG',
'백지헌': 'JIHEON',
'장규리': 'GYURI',
'이새롬': 'SAEROM',
'노지선': 'JISUN',
'이서연': 'SEOYEON',
};
function Birthday() {
const { memberName, year } = useParams();
const navigate = useNavigate();
// URL
const decodedMemberName = decodeURIComponent(memberName || '');
const englishName = memberEnglishName[decodedMemberName];
//
const { data: member, isLoading: memberLoading, error } = useQuery({
queryKey: ['member', decodedMemberName],
queryFn: () => fetchApi(`/api/members/${encodeURIComponent(decodedMemberName)}`),
enabled: !!decodedMemberName,
});
// ( )
// const { data: cafes } = useQuery({
// queryKey: ['birthdayCafes', decodedMemberName, year],
// queryFn: () => fetchApi(`/api/birthday-cafes?member=${encodeURIComponent(decodedMemberName)}&year=${year}`),
// });
if (!decodedMemberName || error) {
return (
<div className="min-h-[calc(100vh-64px)] flex items-center justify-center">
<div className="text-center">
<h1 className="text-2xl font-bold text-gray-900 mb-2">멤버를 찾을 없습니다</h1>
<button
onClick={() => navigate('/schedule')}
className="text-primary hover:underline"
>
일정으로 돌아가기
</button>
</div>
</div>
);
}
if (memberLoading) {
return (
<div className="min-h-[calc(100vh-64px)] flex items-center justify-center">
<div className="w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin" />
</div>
);
}
//
const birthDate = member?.birth_date ? new Date(member.birth_date) : null;
const birthdayThisYear = birthDate ? new Date(parseInt(year), birthDate.getMonth(), birthDate.getDate()) : null;
return (
<div className="min-h-[calc(100vh-64px)] bg-gradient-to-b from-pink-50 to-purple-50">
<div className="max-w-4xl mx-auto px-6 py-8">
{/* 뒤로가기 */}
<button
onClick={() => navigate(-1)}
className="flex items-center gap-2 text-gray-600 hover:text-gray-900 mb-6 transition-colors"
>
<ArrowLeft size={20} />
<span>뒤로가기</span>
</button>
{/* 헤더 카드 */}
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
className="relative overflow-hidden bg-gradient-to-r from-pink-400 via-purple-400 to-indigo-400 rounded-3xl shadow-xl mb-8"
>
{/* 배경 장식 */}
<div className="absolute inset-0 overflow-hidden">
<div className="absolute -top-10 -right-10 w-40 h-40 bg-white/10 rounded-full" />
<div className="absolute -bottom-10 -left-10 w-48 h-48 bg-white/10 rounded-full" />
<div className="absolute top-1/3 right-1/4 w-20 h-20 bg-white/5 rounded-full" />
<div className="absolute top-6 right-12 text-4xl animate-pulse"></div>
<div className="absolute bottom-6 left-16 text-3xl animate-pulse delay-300">🎉</div>
<div className="absolute top-1/2 right-8 text-2xl animate-bounce">🎈</div>
</div>
<div className="relative flex items-center p-8 gap-8">
{/* 멤버 사진 */}
{member?.image_url && (
<div className="flex-shrink-0">
<div className="w-32 h-32 rounded-full border-4 border-white/50 shadow-xl overflow-hidden bg-white">
<img
src={member.image_url}
alt={member.name}
className="w-full h-full object-cover"
/>
</div>
</div>
)}
{/* 내용 */}
<div className="flex-1 text-white">
<div className="flex items-center gap-3 mb-2">
<span className="text-5xl">🎂</span>
<h1 className="font-bold text-4xl tracking-wide">
HAPPY {englishName} DAY
</h1>
</div>
<p className="text-white/80 text-lg mt-2">
{year} {birthdayThisYear?.getMonth() + 1} {birthdayThisYear?.getDate()}
</p>
</div>
{/* 년도 뱃지 */}
<div className="flex-shrink-0 bg-white/20 backdrop-blur-sm rounded-2xl px-6 py-4 text-center">
<div className="text-white/70 text-sm font-medium">YEAR</div>
<div className="text-white text-4xl font-bold">{year}</div>
</div>
</div>
</motion.div>
{/* 생일카페 섹션 */}
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.1 }}
className="bg-white rounded-2xl shadow-lg p-8"
>
<h2 className="text-2xl font-bold text-gray-900 mb-6 flex items-center gap-2">
<span></span>
생일카페
</h2>
{/* 준비 중 메시지 */}
<div className="text-center py-12">
<div className="text-6xl mb-4">🎁</div>
<p className="text-gray-500 text-lg">
{year} {decodedMemberName} 생일카페 정보가 준비 중입니다
</p>
<p className="text-gray-400 text-sm mt-2">
생일카페 정보가 등록되면 이곳에 표시됩니다
</p>
</div>
{/* 생일카페 목록 (나중에 구현) */}
{/* {cafes?.length > 0 ? (
<div className="space-y-4">
{cafes.map((cafe) => (
<div key={cafe.id} className="border border-gray-200 rounded-xl p-6">
<h3 className="font-bold text-lg mb-3">{cafe.name}</h3>
<div className="space-y-2 text-gray-600">
<div className="flex items-center gap-2">
<Calendar size={16} />
<span>{cafe.start_date} ~ {cafe.end_date}</span>
</div>
<div className="flex items-center gap-2">
<Clock size={16} />
<span>{cafe.open_time} - {cafe.close_time}</span>
</div>
<div className="flex items-center gap-2">
<MapPin size={16} />
<span>{cafe.location}</span>
</div>
</div>
</div>
))}
</div>
) : null} */}
</motion.div>
{/* 다른 년도 보기 (나중에 구현) */}
{/* <motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.2 }}
className="mt-6 flex justify-center gap-2"
>
{[2023, 2024, 2025, 2026].map((y) => (
<button
key={y}
onClick={() => navigate(`/birthday/${encodeURIComponent(decodedMemberName)}/${y}`)}
className={`px-4 py-2 rounded-lg transition-colors ${
parseInt(year) === y
? 'bg-primary text-white'
: 'bg-white text-gray-600 hover:bg-gray-100'
}`}
>
{y}
</button>
))}
</motion.div> */}
</div>
</div>
);
}
export default Birthday;

View file

@ -1,10 +1,11 @@
import { useState, useEffect, useRef, useMemo, useDeferredValue, memo } from 'react'; import { useState, useEffect, useRef, useMemo, useDeferredValue, memo, useCallback } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { motion, AnimatePresence } from 'framer-motion'; import { motion, AnimatePresence } from 'framer-motion';
import { Clock, ChevronLeft, ChevronRight, ChevronDown, Tag, Search, ArrowLeft, Link2, X } from 'lucide-react'; import { Clock, ChevronLeft, ChevronRight, ChevronDown, Tag, Search, ArrowLeft, Link2, X } from 'lucide-react';
import { useQuery, useInfiniteQuery } from '@tanstack/react-query'; import { useQuery, useInfiniteQuery } from '@tanstack/react-query';
import { useVirtualizer } from '@tanstack/react-virtual'; import { useVirtualizer } from '@tanstack/react-virtual';
import { useInView } from 'react-intersection-observer'; import { useInView } from 'react-intersection-observer';
import confetti from 'canvas-confetti';
import { getTodayKST } from '../../../utils/date'; import { getTodayKST } from '../../../utils/date';
import { getSchedules, getCategories, searchSchedules as searchSchedulesApi } from '../../../api/public/schedules'; import { getSchedules, getCategories, searchSchedules as searchSchedulesApi } from '../../../api/public/schedules';
import useScheduleStore from '../../../stores/useScheduleStore'; import useScheduleStore from '../../../stores/useScheduleStore';
@ -17,6 +18,118 @@ const decodeHtmlEntities = (text) => {
return textarea.value; return textarea.value;
}; };
//
const fireBirthdayConfetti = () => {
const duration = 3000;
const animationEnd = Date.now() + duration;
const colors = ['#ff69b4', '#ff1493', '#da70d6', '#ba55d3', '#9370db', '#8a2be2', '#ffd700', '#ff6347'];
const randomInRange = (min, max) => Math.random() * (max - min) + min;
const interval = setInterval(() => {
const timeLeft = animationEnd - Date.now();
if (timeLeft <= 0) {
clearInterval(interval);
return;
}
const particleCount = 50 * (timeLeft / duration);
//
confetti({
particleCount: Math.floor(particleCount),
startVelocity: 30,
spread: 60,
origin: { x: randomInRange(0.1, 0.3), y: Math.random() - 0.2 },
colors: colors,
shapes: ['circle', 'square'],
gravity: 1.2,
scalar: randomInRange(0.8, 1.2),
drift: randomInRange(-0.5, 0.5),
});
//
confetti({
particleCount: Math.floor(particleCount),
startVelocity: 30,
spread: 60,
origin: { x: randomInRange(0.7, 0.9), y: Math.random() - 0.2 },
colors: colors,
shapes: ['circle', 'square'],
gravity: 1.2,
scalar: randomInRange(0.8, 1.2),
drift: randomInRange(-0.5, 0.5),
});
}, 250);
//
confetti({
particleCount: 100,
spread: 100,
origin: { x: 0.5, y: 0.6 },
colors: colors,
shapes: ['circle', 'square'],
startVelocity: 45,
});
};
//
function BirthdayCard({ schedule, formatted, showYear = false, onClick }) {
return (
<div
onClick={onClick}
className="relative overflow-hidden bg-gradient-to-r from-pink-400 via-purple-400 to-indigo-400 rounded-2xl shadow-lg hover:shadow-xl transition-shadow cursor-pointer"
>
{/* 배경 장식 */}
<div className="absolute inset-0 overflow-hidden">
<div className="absolute -top-4 -right-4 w-24 h-24 bg-white/10 rounded-full" />
<div className="absolute -bottom-6 -left-6 w-32 h-32 bg-white/10 rounded-full" />
<div className="absolute top-1/2 right-1/4 w-16 h-16 bg-white/5 rounded-full" />
<div className="absolute bottom-4 left-12 text-xl animate-pulse">🎉</div>
</div>
<div className="relative flex items-center p-4 gap-4">
{/* 멤버 사진 */}
{schedule.member_image && (
<div className="flex-shrink-0">
<div className="w-20 h-20 rounded-full border-4 border-white/50 shadow-lg overflow-hidden bg-white">
<img
src={schedule.member_image}
alt={schedule.member_names}
className="w-full h-full object-cover"
/>
</div>
</div>
)}
{/* 내용 */}
<div className="flex-1 text-white flex items-center gap-3">
<span className="text-4xl">🎂</span>
<h3 className="font-bold text-2xl tracking-wide">
{schedule.title}
</h3>
</div>
{/* 날짜 뱃지 */}
<div className="flex-shrink-0 bg-white/20 backdrop-blur-sm rounded-xl px-4 py-2 text-center">
{showYear && (
<div className="text-white/70 text-xs font-medium">
{new Date(schedule.date).getFullYear()}
</div>
)}
<div className="text-white/70 text-xs font-medium">
{new Date(schedule.date).getMonth() + 1}
</div>
<div className="text-white text-2xl font-bold">
{formatted.day}
</div>
</div>
</div>
</div>
);
}
function Schedule() { function Schedule() {
const navigate = useNavigate(); const navigate = useNavigate();
@ -59,6 +172,32 @@ function Schedule() {
queryFn: () => getSchedules(year, month + 1), queryFn: () => getSchedules(year, month + 1),
}); });
// ( )
useEffect(() => {
if (loading || schedules.length === 0) return;
const today = getTodayKST();
const confettiKey = `birthday-confetti-${today}`;
//
if (localStorage.getItem(confettiKey)) return;
const hasBirthdayToday = schedules.some(s => {
if (!s.is_birthday) return false;
const scheduleDate = s.date ? s.date.split('T')[0] : '';
return scheduleDate === today;
});
if (hasBirthdayToday) {
// ( )
const timer = setTimeout(() => {
fireBirthdayConfetti();
localStorage.setItem(confettiKey, 'true');
}, 500);
return () => clearTimeout(timer);
}
}, [schedules, loading]);
// //
const [showCategoryTooltip, setShowCategoryTooltip] = useState(false); const [showCategoryTooltip, setShowCategoryTooltip] = useState(false);
const categoryRef = useRef(null); const categoryRef = useRef(null);
@ -366,6 +505,14 @@ function Schedule() {
// //
const handleScheduleClick = (schedule) => { const handleScheduleClick = (schedule) => {
//
if (schedule.is_birthday || String(schedule.id).startsWith('birthday-')) {
const scheduleYear = new Date(schedule.date).getFullYear();
const memberName = schedule.member_names; //
navigate(`/birthday/${encodeURIComponent(memberName)}/${scheduleYear}`);
return;
}
// (id=2), X(id=3), (id=6) // (id=2), X(id=3), (id=6)
if (schedule.category_id === 2 || schedule.category_id === 3 || schedule.category_id === 6) { if (schedule.category_id === 2 || schedule.category_id === 3 || schedule.category_id === 6) {
navigate(`/schedule/${schedule.id}`); navigate(`/schedule/${schedule.id}`);
@ -996,6 +1143,9 @@ function Schedule() {
}} }}
> >
<div className={virtualItem.index < filteredSchedules.length - 1 ? "pb-4" : ""}> <div className={virtualItem.index < filteredSchedules.length - 1 ? "pb-4" : ""}>
{schedule.is_birthday ? (
<BirthdayCard schedule={schedule} formatted={formatted} showYear={true} onClick={() => handleScheduleClick(schedule)} />
) : (
<div <div
onClick={() => handleScheduleClick(schedule)} onClick={() => handleScheduleClick(schedule)}
className="flex items-stretch bg-white rounded-2xl shadow-sm hover:shadow-md transition-shadow overflow-hidden cursor-pointer min-h-[100px]" className="flex items-stretch bg-white rounded-2xl shadow-sm hover:shadow-md transition-shadow overflow-hidden cursor-pointer min-h-[100px]"
@ -1060,6 +1210,7 @@ function Schedule() {
})()} })()}
</div> </div>
</div> </div>
)}
</div> </div>
</div> </div>
); );
@ -1093,60 +1244,67 @@ function Schedule() {
initial={{ opacity: 0 }} initial={{ opacity: 0 }}
animate={{ opacity: 1 }} animate={{ opacity: 1 }}
transition={{ delay: Math.min(index, 10) * 0.03 }} transition={{ delay: Math.min(index, 10) * 0.03 }}
onClick={() => handleScheduleClick(schedule)}
className="flex items-stretch bg-white rounded-2xl shadow-sm hover:shadow-md transition-shadow overflow-hidden cursor-pointer"
> >
{schedule.is_birthday ? (
<BirthdayCard schedule={schedule} formatted={formatted} onClick={() => handleScheduleClick(schedule)} />
) : (
<div <div
className="w-24 flex flex-col items-center justify-center text-white py-6" onClick={() => handleScheduleClick(schedule)}
style={{ backgroundColor: categoryColor }} className="flex items-stretch bg-white rounded-2xl shadow-sm hover:shadow-md transition-shadow overflow-hidden cursor-pointer"
> >
<span className="text-3xl font-bold">{formatted.day}</span> <div
<span className="text-sm font-medium opacity-80">{formatted.weekday}</span> className="w-24 flex flex-col items-center justify-center text-white py-6"
</div> style={{ backgroundColor: categoryColor }}
<div className="flex-1 p-6 flex flex-col justify-center"> >
<h3 className="font-bold text-lg mb-2">{decodeHtmlEntities(schedule.title)}</h3> <span className="text-3xl font-bold">{formatted.day}</span>
<div className="flex flex-wrap gap-3 text-base text-gray-500"> <span className="text-sm font-medium opacity-80">{formatted.weekday}</span>
{schedule.time && (
<span className="flex items-center gap-1">
<Clock size={16} className="opacity-60" />
{schedule.time.slice(0, 5)}
</span>
)}
<span className="flex items-center gap-1">
<Tag size={16} className="opacity-60" />
{categoryName}
</span>
{schedule.source_name && (
<span className="flex items-center gap-1">
<Link2 size={16} className="opacity-60" />
{schedule.source_name}
</span>
)}
</div> </div>
{(() => { <div className="flex-1 p-6 flex flex-col justify-center">
const memberNames = schedule.member_names || schedule.members?.map(m => m.name).join(',') || ''; <h3 className="font-bold text-lg mb-2">{decodeHtmlEntities(schedule.title)}</h3>
const memberList = memberNames.split(',').filter(name => name.trim()); <div className="flex flex-wrap gap-3 text-base text-gray-500">
if (memberList.length === 0) return null; {schedule.time && (
if (memberList.length === 5) { <span className="flex items-center gap-1">
<Clock size={16} className="opacity-60" />
{schedule.time.slice(0, 5)}
</span>
)}
<span className="flex items-center gap-1">
<Tag size={16} className="opacity-60" />
{categoryName}
</span>
{schedule.source_name && (
<span className="flex items-center gap-1">
<Link2 size={16} className="opacity-60" />
{schedule.source_name}
</span>
)}
</div>
{(() => {
const memberNames = schedule.member_names || schedule.members?.map(m => m.name).join(',') || '';
const memberList = memberNames.split(',').filter(name => name.trim());
if (memberList.length === 0) return null;
if (memberList.length === 5) {
return (
<div className="flex flex-wrap gap-1.5 mt-2">
<span className="px-2 py-0.5 bg-primary/10 text-primary text-sm font-medium rounded-full">
프로미스나인
</span>
</div>
);
}
return ( return (
<div className="flex flex-wrap gap-1.5 mt-2"> <div className="flex flex-wrap gap-1.5 mt-2">
<span className="px-2 py-0.5 bg-primary/10 text-primary text-sm font-medium rounded-full"> {memberList.map((name, i) => (
프로미스나인 <span key={i} className="px-2 py-0.5 bg-primary/10 text-primary text-sm font-medium rounded-full">
</span> {name}
</span>
))}
</div> </div>
); );
} })()}
return ( </div>
<div className="flex flex-wrap gap-1.5 mt-2">
{memberList.map((name, i) => (
<span key={i} className="px-2 py-0.5 bg-primary/10 text-primary text-sm font-medium rounded-full">
{name}
</span>
))}
</div>
);
})()}
</div> </div>
)}
</motion.div> </motion.div>
); );
}) })
@ -1157,9 +1315,19 @@ function Schedule() {
initial={{ opacity: 0, y: 10 }} initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }} animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.2 }} transition={{ duration: 0.2 }}
className="text-center py-20 text-gray-500" className="flex flex-col items-center justify-center py-16"
> >
{selectedDate ? '선택한 날짜에 일정이 없습니다.' : '예정된 일정이 없습니다.'} <div className="w-24 h-24 bg-gray-100 rounded-full flex items-center justify-center mb-4">
<svg className="w-12 h-12 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
</svg>
</div>
<p className="text-gray-400 text-lg font-medium mb-1">
{selectedDate ? '일정이 없습니다' : '예정된 일정이 없습니다'}
</p>
<p className="text-gray-300 text-sm">
{selectedDate ? '다른 날짜를 선택해 보세요' : '다른 달을 확인해 보세요'}
</p>
</motion.div> </motion.div>
) )
)} )}

View file

@ -74,6 +74,9 @@ const formatXDateTime = (dateStr, timeStr) => {
// () // ()
function VideoInfo({ schedule, isShorts }) { function VideoInfo({ schedule, isShorts }) {
const members = schedule.members || [];
const isFullGroup = members.length === 5;
return ( return (
<div className={`bg-gradient-to-br from-gray-50 to-gray-100/50 rounded-2xl p-6 ${isShorts ? 'flex-1' : ''}`}> <div className={`bg-gradient-to-br from-gray-50 to-gray-100/50 rounded-2xl p-6 ${isShorts ? 'flex-1' : ''}`}>
{/* 제목 */} {/* 제목 */}
@ -112,6 +115,26 @@ function VideoInfo({ schedule, isShorts }) {
)} )}
</div> </div>
{/* 멤버 목록 */}
{members.length > 0 && (
<div className="flex flex-wrap gap-2 mt-4">
{isFullGroup ? (
<span className="px-3 py-1 bg-primary/10 text-primary text-sm font-medium rounded-full">
프로미스나인
</span>
) : (
members.map((member) => (
<span
key={member.id}
className="px-3 py-1 bg-primary/10 text-primary text-sm font-medium rounded-full"
>
{member.name}
</span>
))
)}
</div>
)}
{/* 유튜브에서 보기 버튼 */} {/* 유튜브에서 보기 버튼 */}
<div className="mt-6 pt-5 border-t border-gray-200"> <div className="mt-6 pt-5 border-t border-gray-200">
<a <a
@ -654,6 +677,7 @@ function ScheduleDetail() {
queryKey: ['schedule', id], queryKey: ['schedule', id],
queryFn: () => getSchedule(id), queryFn: () => getSchedule(id),
placeholderData: keepPreviousData, placeholderData: keepPreviousData,
retry: false, // 404
}); });
if (isLoading) { if (isLoading) {
@ -666,16 +690,84 @@ function ScheduleDetail() {
if (error || !schedule) { if (error || !schedule) {
return ( return (
<div className="min-h-[calc(100vh-64px)] flex flex-col items-center justify-center bg-gray-50"> <div className="min-h-[calc(100vh-64px)] flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100">
<div className="text-center"> <div className="text-center px-6">
<div className="text-6xl mb-4">😢</div> {/* 아이콘 */}
<p className="text-gray-500 mb-6">일정을 찾을 없습니다</p> <motion.div
<Link initial={{ opacity: 0, scale: 0.5 }}
to="/schedule" animate={{ opacity: 1, scale: 1 }}
className="px-6 py-3 bg-primary hover:bg-primary-dark text-white rounded-xl font-medium transition-colors" transition={{ duration: 0.5, type: "spring", stiffness: 100 }}
className="mb-8"
> >
일정 목록으로 <div className="w-32 h-32 mx-auto bg-gradient-to-br from-primary/10 to-primary/5 rounded-3xl flex items-center justify-center">
</Link> <Calendar size={64} className="text-primary/40" />
</div>
</motion.div>
{/* 메시지 */}
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.2, duration: 0.5 }}
className="mb-8"
>
<h2 className="text-2xl font-bold text-gray-800 mb-3">
일정을 찾을 없습니다
</h2>
<p className="text-gray-500 leading-relaxed">
요청하신 일정이 존재하지 않거나 삭제되었을 있습니다.
<br />
다른 일정을 확인해 주세요.
</p>
</motion.div>
{/* 장식 요소 */}
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ delay: 0.4, duration: 0.5 }}
className="flex justify-center gap-2 mb-10"
>
{[...Array(5)].map((_, i) => (
<motion.div
key={i}
className="w-2 h-2 rounded-full bg-primary"
animate={{
y: [0, -8, 0],
opacity: [0.3, 1, 0.3],
}}
transition={{
duration: 1.2,
repeat: Infinity,
delay: i * 0.15,
ease: "easeInOut",
}}
/>
))}
</motion.div>
{/* 버튼들 */}
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.5, duration: 0.5 }}
className="flex justify-center gap-4"
>
<button
onClick={() => window.history.back()}
className="flex items-center gap-2 px-6 py-3 border-2 border-primary text-primary rounded-full font-medium hover:bg-primary hover:text-white transition-colors duration-200"
>
<ChevronRight size={18} className="rotate-180" />
이전 페이지
</button>
<Link
to="/schedule"
className="flex items-center gap-2 px-6 py-3 bg-gradient-to-r from-primary to-primary-dark text-white rounded-full font-medium hover:shadow-lg hover:shadow-primary/30 transition-all duration-200"
>
<Calendar size={18} />
일정 목록
</Link>
</motion.div>
</div> </div>
</div> </div>
); );