2026-01-09 19:26:52 +09:00
|
|
|
import { useState, useEffect, useRef, useMemo, memo, useDeferredValue } from 'react';
|
2026-01-04 20:50:21 +09:00
|
|
|
import { useNavigate, Link } from 'react-router-dom';
|
|
|
|
|
import { motion, AnimatePresence } from 'framer-motion';
|
|
|
|
|
import {
|
2026-01-09 23:18:48 +09:00
|
|
|
Home, ChevronRight, Calendar, Plus, Edit2, Trash2,
|
2026-01-09 23:36:34 +09:00
|
|
|
ChevronLeft, Search, ChevronDown, Bot, Tag, ArrowLeft, ExternalLink, Clock, Link2
|
2026-01-04 20:50:21 +09:00
|
|
|
} from 'lucide-react';
|
2026-01-06 19:48:43 +09:00
|
|
|
import { useInfiniteQuery } from '@tanstack/react-query';
|
2026-01-10 09:34:18 +09:00
|
|
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
2026-01-06 19:48:43 +09:00
|
|
|
import { useInView } from 'react-intersection-observer';
|
2026-01-06 11:14:18 +09:00
|
|
|
|
2026-01-04 20:50:21 +09:00
|
|
|
import Toast from '../../../components/Toast';
|
2026-01-05 18:11:40 +09:00
|
|
|
import Tooltip from '../../../components/Tooltip';
|
2026-01-11 12:13:59 +09:00
|
|
|
import AdminLayout from '../../../components/admin/AdminLayout';
|
2026-01-09 23:36:34 +09:00
|
|
|
import ConfirmDialog from '../../../components/admin/ConfirmDialog';
|
2026-01-06 12:26:40 +09:00
|
|
|
import useScheduleStore from '../../../stores/useScheduleStore';
|
2026-01-09 22:57:34 +09:00
|
|
|
import useToast from '../../../hooks/useToast';
|
2026-01-09 09:57:51 +09:00
|
|
|
import { getTodayKST, formatDate } from '../../../utils/date';
|
2026-01-09 22:09:42 +09:00
|
|
|
import * as schedulesApi from '../../../api/admin/schedules';
|
|
|
|
|
import * as categoriesApi from '../../../api/admin/categories';
|
2026-01-04 20:50:21 +09:00
|
|
|
|
2026-01-10 00:26:13 +09:00
|
|
|
// HTML 엔티티 디코딩 함수
|
|
|
|
|
const decodeHtmlEntities = (text) => {
|
|
|
|
|
if (!text) return '';
|
|
|
|
|
const textarea = document.createElement('textarea');
|
|
|
|
|
textarea.innerHTML = text;
|
|
|
|
|
return textarea.value;
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-09 19:26:52 +09:00
|
|
|
// 일정 아이템 컴포넌트 - React.memo로 불필요한 리렌더링 방지
|
|
|
|
|
const ScheduleItem = memo(function ScheduleItem({
|
|
|
|
|
schedule,
|
|
|
|
|
index,
|
|
|
|
|
selectedDate,
|
|
|
|
|
categories,
|
|
|
|
|
getColorStyle,
|
|
|
|
|
navigate,
|
|
|
|
|
openDeleteDialog
|
|
|
|
|
}) {
|
|
|
|
|
const scheduleDate = new Date(schedule.date);
|
|
|
|
|
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 memberNames = schedule.member_names || schedule.members?.map(m => m.name).join(',') || '';
|
|
|
|
|
const memberList = memberNames.split(',').filter(name => name.trim());
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<motion.div
|
|
|
|
|
key={`${schedule.id}-${selectedDate || 'all'}`}
|
|
|
|
|
initial={{ opacity: 0 }}
|
|
|
|
|
animate={{ opacity: 1 }}
|
|
|
|
|
transition={{ delay: Math.min(index, 10) * 0.03 }}
|
|
|
|
|
className="p-6 hover:bg-gray-50 transition-colors group"
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-start gap-4">
|
|
|
|
|
<div className="w-20 text-center flex-shrink-0">
|
|
|
|
|
<div className="text-2xl font-bold text-gray-900">
|
|
|
|
|
{scheduleDate.getDate()}
|
|
|
|
|
</div>
|
|
|
|
|
<div className="text-sm text-gray-500">
|
|
|
|
|
{['일', '월', '화', '수', '목', '금', '토'][scheduleDate.getDay()]}요일
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
className="w-1.5 rounded-full flex-shrink-0 self-stretch"
|
|
|
|
|
style={{ backgroundColor: categoryColor }}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<div className="flex-1 min-w-0">
|
2026-01-10 00:26:13 +09:00
|
|
|
<h3 className="font-semibold text-gray-900">{decodeHtmlEntities(schedule.title)}</h3>
|
2026-01-09 19:26:52 +09:00
|
|
|
<div className="flex items-center gap-3 mt-1 text-sm text-gray-500">
|
|
|
|
|
{schedule.time && (
|
|
|
|
|
<span className="flex items-center gap-1">
|
|
|
|
|
<Clock size={14} />
|
|
|
|
|
{schedule.time.slice(0, 5)}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
<span className="flex items-center gap-1">
|
|
|
|
|
<Tag size={14} />
|
|
|
|
|
{categoryName}
|
|
|
|
|
</span>
|
|
|
|
|
{schedule.source_name && (
|
|
|
|
|
<span className="flex items-center gap-1">
|
|
|
|
|
<Link2 size={14} />
|
|
|
|
|
{schedule.source_name}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
{memberList.length > 0 && (
|
|
|
|
|
<div className="flex flex-wrap gap-1.5 mt-2">
|
|
|
|
|
{memberList.length >= 5 ? (
|
|
|
|
|
<span className="px-2 py-0.5 bg-primary/10 text-primary text-xs font-medium rounded-full">
|
|
|
|
|
프로미스나인
|
|
|
|
|
</span>
|
|
|
|
|
) : (
|
|
|
|
|
memberList.map((name, i) => (
|
|
|
|
|
<span key={i} className="px-2 py-0.5 bg-primary/10 text-primary text-xs font-medium rounded-full">
|
|
|
|
|
{name.trim()}
|
|
|
|
|
</span>
|
|
|
|
|
))
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity">
|
|
|
|
|
{schedule.source_url && (
|
|
|
|
|
<a
|
|
|
|
|
href={schedule.source_url}
|
|
|
|
|
target="_blank"
|
|
|
|
|
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"
|
|
|
|
|
>
|
|
|
|
|
<Edit2 size={18} />
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => openDeleteDialog(schedule)}
|
|
|
|
|
className="p-2 hover:bg-red-100 rounded-lg transition-colors text-red-500"
|
|
|
|
|
>
|
|
|
|
|
<Trash2 size={18} />
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</motion.div>
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
2026-01-04 20:50:21 +09:00
|
|
|
function AdminSchedule() {
|
|
|
|
|
const navigate = useNavigate();
|
2026-01-06 08:09:17 +09:00
|
|
|
|
2026-01-06 12:26:40 +09:00
|
|
|
// Zustand 스토어에서 상태 가져오기
|
|
|
|
|
const {
|
|
|
|
|
searchInput, setSearchInput,
|
|
|
|
|
searchTerm, setSearchTerm,
|
|
|
|
|
isSearchMode, setIsSearchMode,
|
|
|
|
|
selectedCategories, setSelectedCategories,
|
|
|
|
|
selectedDate, setSelectedDate,
|
|
|
|
|
currentDate, setCurrentDate,
|
2026-01-07 23:54:35 +09:00
|
|
|
scrollPosition, setScrollPosition,
|
2026-01-06 12:26:40 +09:00
|
|
|
} = useScheduleStore();
|
2026-01-06 09:50:29 +09:00
|
|
|
|
2026-01-06 12:26:40 +09:00
|
|
|
// 로컬 상태 (페이지 이동 시 유지할 필요 없는 것들)
|
2026-01-04 20:50:21 +09:00
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
|
const [user, setUser] = useState(null);
|
2026-01-09 22:57:34 +09:00
|
|
|
const { toast, setToast } = useToast();
|
2026-01-07 23:54:35 +09:00
|
|
|
const scrollContainerRef = useRef(null);
|
2026-01-10 09:20:27 +09:00
|
|
|
const SEARCH_LIMIT = 20; // 페이지당 20개
|
2026-01-10 09:52:34 +09:00
|
|
|
const ESTIMATED_ITEM_HEIGHT = 100; // 아이템 추정 높이 (동적 측정)
|
2026-01-06 19:48:43 +09:00
|
|
|
|
|
|
|
|
// Intersection Observer for infinite scroll
|
|
|
|
|
const { ref: loadMoreRef, inView } = useInView({
|
|
|
|
|
threshold: 0,
|
|
|
|
|
rootMargin: '100px',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// useInfiniteQuery for search
|
|
|
|
|
const {
|
|
|
|
|
data: searchData,
|
|
|
|
|
fetchNextPage,
|
|
|
|
|
hasNextPage,
|
|
|
|
|
isFetchingNextPage,
|
|
|
|
|
isLoading: searchLoading,
|
|
|
|
|
} = useInfiniteQuery({
|
|
|
|
|
queryKey: ['adminScheduleSearch', searchTerm],
|
|
|
|
|
queryFn: async ({ pageParam = 0 }) => {
|
|
|
|
|
const response = await fetch(
|
|
|
|
|
`/api/schedules?search=${encodeURIComponent(searchTerm)}&offset=${pageParam}&limit=${SEARCH_LIMIT}`
|
|
|
|
|
);
|
|
|
|
|
if (!response.ok) throw new Error('Search failed');
|
|
|
|
|
return response.json();
|
|
|
|
|
},
|
|
|
|
|
getNextPageParam: (lastPage) => {
|
|
|
|
|
if (lastPage.hasMore) {
|
|
|
|
|
return lastPage.offset + lastPage.schedules.length;
|
|
|
|
|
}
|
|
|
|
|
return undefined;
|
|
|
|
|
},
|
|
|
|
|
enabled: !!searchTerm && isSearchMode,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Flatten search results
|
|
|
|
|
const searchResults = useMemo(() => {
|
|
|
|
|
if (!searchData?.pages) return [];
|
|
|
|
|
return searchData.pages.flatMap(page => page.schedules);
|
|
|
|
|
}, [searchData]);
|
|
|
|
|
|
|
|
|
|
const searchTotal = searchData?.pages?.[0]?.total || 0;
|
|
|
|
|
|
|
|
|
|
// Auto fetch next page when scrolled to bottom
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (inView && hasNextPage && !isFetchingNextPage && isSearchMode && searchTerm) {
|
|
|
|
|
fetchNextPage();
|
|
|
|
|
}
|
|
|
|
|
}, [inView, hasNextPage, isFetchingNextPage, fetchNextPage, isSearchMode, searchTerm]);
|
2026-01-06 12:26:40 +09:00
|
|
|
|
2026-01-10 00:20:04 +09:00
|
|
|
// selectedDate가 없으면 오늘 날짜로 초기화
|
2026-01-06 12:26:40 +09:00
|
|
|
useEffect(() => {
|
2026-01-10 00:20:04 +09:00
|
|
|
if (!selectedDate) {
|
2026-01-06 12:26:40 +09:00
|
|
|
setSelectedDate(getTodayKST());
|
|
|
|
|
}
|
|
|
|
|
}, []);
|
|
|
|
|
|
2026-01-06 09:50:29 +09:00
|
|
|
|
2026-01-06 08:09:17 +09:00
|
|
|
|
2026-01-04 20:50:21 +09:00
|
|
|
const [slideDirection, setSlideDirection] = useState(0);
|
|
|
|
|
|
|
|
|
|
// 년월 선택 관련 (Schedule.jsx와 동일한 패턴)
|
|
|
|
|
const [showYearMonthPicker, setShowYearMonthPicker] = useState(false);
|
2026-01-05 22:08:41 +09:00
|
|
|
const [showCategoryTooltip, setShowCategoryTooltip] = useState(false);
|
2026-01-04 20:50:21 +09:00
|
|
|
const [viewMode, setViewMode] = useState('yearMonth'); // 'yearMonth' | 'months'
|
|
|
|
|
const pickerRef = useRef(null);
|
2026-01-05 22:08:41 +09:00
|
|
|
const categoryTooltipRef = useRef(null);
|
2026-01-04 20:50:21 +09:00
|
|
|
|
|
|
|
|
// 달력 관련
|
|
|
|
|
const year = currentDate.getFullYear();
|
|
|
|
|
const month = currentDate.getMonth();
|
|
|
|
|
const firstDay = new Date(year, month, 1).getDay();
|
|
|
|
|
const daysInMonth = new Date(year, month + 1, 0).getDate();
|
|
|
|
|
const days = ['일', '월', '화', '수', '목', '금', '토'];
|
|
|
|
|
const monthNames = ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'];
|
|
|
|
|
|
|
|
|
|
// 년도 범위 (현재 년도 기준 10년 단위 - Schedule.jsx와 동일)
|
|
|
|
|
const startYear = Math.floor(year / 10) * 10 - 1;
|
|
|
|
|
const yearRange = Array.from({ length: 12 }, (_, i) => startYear + i);
|
|
|
|
|
|
|
|
|
|
// 현재 년도/월 확인 함수
|
|
|
|
|
const isCurrentYear = (y) => new Date().getFullYear() === y;
|
|
|
|
|
const isCurrentMonth = (m) => {
|
|
|
|
|
const today = new Date();
|
|
|
|
|
return today.getFullYear() === year && today.getMonth() === m;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getDaysInMonth = (y, m) => new Date(y, m + 1, 0).getDate();
|
|
|
|
|
|
2026-01-05 18:11:40 +09:00
|
|
|
// 카테고리 목록 (API에서 로드)
|
|
|
|
|
const [categories, setCategories] = useState([
|
|
|
|
|
{ id: 'all', name: '전체', color: 'gray' }
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// 일정 목록 (API에서 로드)
|
|
|
|
|
const [schedules, setSchedules] = useState([]);
|
|
|
|
|
|
|
|
|
|
// 카테고리 색상 맵핑
|
|
|
|
|
const colorMap = {
|
|
|
|
|
blue: 'bg-blue-500',
|
|
|
|
|
green: 'bg-green-500',
|
|
|
|
|
purple: 'bg-purple-500',
|
|
|
|
|
red: 'bg-red-500',
|
|
|
|
|
pink: 'bg-pink-500',
|
|
|
|
|
yellow: 'bg-yellow-500',
|
|
|
|
|
orange: 'bg-orange-500',
|
|
|
|
|
gray: 'bg-gray-500',
|
2026-01-04 20:50:21 +09:00
|
|
|
};
|
|
|
|
|
|
2026-01-05 18:11:40 +09:00
|
|
|
// 색상 스타일 (기본 색상 또는 커스텀 HEX)
|
|
|
|
|
const getColorStyle = (color) => {
|
|
|
|
|
if (!color) return { className: 'bg-gray-500' };
|
|
|
|
|
if (color.startsWith('#')) {
|
|
|
|
|
return { style: { backgroundColor: color } };
|
|
|
|
|
}
|
|
|
|
|
return { className: colorMap[color] || 'bg-gray-500' };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 카테고리별 색상 (배지용)
|
|
|
|
|
const getCategoryColor = (color) => {
|
2026-01-04 20:50:21 +09:00
|
|
|
const colors = {
|
2026-01-05 18:11:40 +09:00
|
|
|
blue: 'bg-blue-100 text-blue-700',
|
|
|
|
|
green: 'bg-green-100 text-green-700',
|
|
|
|
|
purple: 'bg-purple-100 text-purple-700',
|
|
|
|
|
red: 'bg-red-100 text-red-700',
|
|
|
|
|
pink: 'bg-pink-100 text-pink-700',
|
|
|
|
|
yellow: 'bg-yellow-100 text-yellow-700',
|
|
|
|
|
orange: 'bg-orange-100 text-orange-700',
|
|
|
|
|
gray: 'bg-gray-100 text-gray-700',
|
2026-01-04 20:50:21 +09:00
|
|
|
};
|
2026-01-05 18:11:40 +09:00
|
|
|
if (color?.startsWith('#')) {
|
|
|
|
|
return 'bg-gray-100 text-gray-700';
|
|
|
|
|
}
|
|
|
|
|
return colors[color] || 'bg-gray-100 text-gray-700';
|
2026-01-04 20:50:21 +09:00
|
|
|
};
|
|
|
|
|
|
2026-01-09 19:26:52 +09:00
|
|
|
// 일정 데이터를 지연 처리하여 달력 UI 응답성 향상
|
|
|
|
|
const deferredSchedules = useDeferredValue(schedules);
|
|
|
|
|
|
|
|
|
|
// 일정 날짜별 맵 (O(1) 조회용) - 지연된 데이터로 점 표시
|
2026-01-09 17:53:58 +09:00
|
|
|
const scheduleDateMap = useMemo(() => {
|
|
|
|
|
const map = new Map();
|
2026-01-09 19:26:52 +09:00
|
|
|
deferredSchedules.forEach(s => {
|
2026-01-09 17:53:58 +09:00
|
|
|
const dateStr = formatDate(s.date);
|
|
|
|
|
if (!map.has(dateStr)) {
|
|
|
|
|
map.set(dateStr, s);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return map;
|
2026-01-09 19:26:52 +09:00
|
|
|
}, [deferredSchedules]);
|
2026-01-09 17:53:58 +09:00
|
|
|
|
|
|
|
|
// 해당 날짜에 일정이 있는지 확인 (O(1))
|
2026-01-04 20:50:21 +09:00
|
|
|
const hasSchedule = (day) => {
|
|
|
|
|
const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
|
2026-01-09 17:53:58 +09:00
|
|
|
return scheduleDateMap.has(dateStr);
|
2026-01-04 20:50:21 +09:00
|
|
|
};
|
|
|
|
|
|
2026-01-09 17:53:58 +09:00
|
|
|
// 해당 날짜의 첫 번째 일정 카테고리 색상 (O(1))
|
2026-01-05 22:08:41 +09:00
|
|
|
const getScheduleColor = (day) => {
|
|
|
|
|
const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
|
2026-01-09 17:53:58 +09:00
|
|
|
const schedule = scheduleDateMap.get(dateStr);
|
2026-01-05 22:08:41 +09:00
|
|
|
if (!schedule) return null;
|
|
|
|
|
const cat = categories.find(c => c.id === schedule.category_id);
|
|
|
|
|
return cat?.color || '#4A7C59';
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-04 20:50:21 +09:00
|
|
|
useEffect(() => {
|
|
|
|
|
const token = localStorage.getItem('adminToken');
|
|
|
|
|
const userData = localStorage.getItem('adminUser');
|
|
|
|
|
|
|
|
|
|
if (!token || !userData) {
|
|
|
|
|
navigate('/admin');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setUser(JSON.parse(userData));
|
2026-01-05 18:11:40 +09:00
|
|
|
|
|
|
|
|
// 카테고리 로드
|
|
|
|
|
fetchCategories();
|
2026-01-06 11:42:47 +09:00
|
|
|
|
|
|
|
|
// sessionStorage에서 토스트 메시지 확인 (일정 추가/수정 완료 시)
|
|
|
|
|
const savedToast = sessionStorage.getItem('scheduleToast');
|
|
|
|
|
if (savedToast) {
|
|
|
|
|
setToast(JSON.parse(savedToast));
|
|
|
|
|
sessionStorage.removeItem('scheduleToast');
|
|
|
|
|
}
|
2026-01-04 20:50:21 +09:00
|
|
|
}, [navigate]);
|
2026-01-06 11:42:47 +09:00
|
|
|
|
2026-01-05 18:11:40 +09:00
|
|
|
|
|
|
|
|
// 월이 변경될 때마다 일정 로드
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
fetchSchedules();
|
|
|
|
|
}, [year, month]);
|
|
|
|
|
|
2026-01-07 23:54:35 +09:00
|
|
|
// 스크롤 위치 복원
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (scrollContainerRef.current && scrollPosition > 0) {
|
|
|
|
|
scrollContainerRef.current.scrollTop = scrollPosition;
|
|
|
|
|
}
|
|
|
|
|
}, [loading]); // 로딩이 끝나면 스크롤 복원
|
|
|
|
|
|
2026-01-09 19:26:52 +09:00
|
|
|
// 날짜 변경 시 스크롤 맨 위로 초기화
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (scrollContainerRef.current) {
|
|
|
|
|
scrollContainerRef.current.scrollTop = 0;
|
|
|
|
|
}
|
|
|
|
|
}, [selectedDate]);
|
|
|
|
|
|
2026-01-07 23:54:35 +09:00
|
|
|
// 스크롤 위치 저장
|
|
|
|
|
const handleScroll = (e) => {
|
|
|
|
|
setScrollPosition(e.target.scrollTop);
|
|
|
|
|
};
|
2026-01-06 09:50:29 +09:00
|
|
|
|
|
|
|
|
|
2026-01-05 18:11:40 +09:00
|
|
|
// 카테고리 로드 함수
|
|
|
|
|
const fetchCategories = async () => {
|
|
|
|
|
try {
|
2026-01-09 22:09:42 +09:00
|
|
|
const data = await categoriesApi.getCategories();
|
2026-01-05 18:11:40 +09:00
|
|
|
setCategories([
|
|
|
|
|
{ id: 'all', name: '전체', color: 'gray' },
|
|
|
|
|
...data
|
|
|
|
|
]);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('카테고리 로드 오류:', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 일정 로드 함수
|
|
|
|
|
const fetchSchedules = async () => {
|
|
|
|
|
setLoading(true);
|
|
|
|
|
try {
|
2026-01-09 22:09:42 +09:00
|
|
|
const data = await schedulesApi.getSchedules(year, month + 1);
|
2026-01-05 18:11:40 +09:00
|
|
|
setSchedules(data);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('일정 로드 오류:', error);
|
|
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
2026-01-04 20:50:21 +09:00
|
|
|
|
2026-01-06 08:46:10 +09:00
|
|
|
|
2026-01-04 20:50:21 +09:00
|
|
|
// 외부 클릭 시 피커 닫기
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const handleClickOutside = (event) => {
|
|
|
|
|
if (pickerRef.current && !pickerRef.current.contains(event.target)) {
|
|
|
|
|
setShowYearMonthPicker(false);
|
|
|
|
|
setViewMode('yearMonth');
|
|
|
|
|
}
|
2026-01-05 22:08:41 +09:00
|
|
|
if (categoryTooltipRef.current && !categoryTooltipRef.current.contains(event.target)) {
|
|
|
|
|
setShowCategoryTooltip(false);
|
|
|
|
|
}
|
2026-01-04 20:50:21 +09:00
|
|
|
};
|
|
|
|
|
|
2026-01-05 22:08:41 +09:00
|
|
|
if (showYearMonthPicker || showCategoryTooltip) {
|
2026-01-04 20:50:21 +09:00
|
|
|
document.addEventListener('mousedown', handleClickOutside);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return () => document.removeEventListener('mousedown', handleClickOutside);
|
2026-01-05 22:08:41 +09:00
|
|
|
}, [showYearMonthPicker, showCategoryTooltip]);
|
2026-01-04 20:50:21 +09:00
|
|
|
|
|
|
|
|
// 월 이동
|
|
|
|
|
const prevMonth = () => {
|
|
|
|
|
setSlideDirection(-1);
|
2026-01-09 17:35:15 +09:00
|
|
|
const newDate = new Date(year, month - 1, 1);
|
|
|
|
|
setCurrentDate(newDate);
|
|
|
|
|
// 이번달이면 오늘, 다른 달이면 1일 선택
|
|
|
|
|
const today = new Date();
|
|
|
|
|
if (newDate.getFullYear() === today.getFullYear() && newDate.getMonth() === today.getMonth()) {
|
|
|
|
|
setSelectedDate(getTodayKST());
|
|
|
|
|
} else {
|
|
|
|
|
const firstDay = `${newDate.getFullYear()}-${String(newDate.getMonth() + 1).padStart(2, '0')}-01`;
|
|
|
|
|
setSelectedDate(firstDay);
|
|
|
|
|
}
|
2026-01-05 22:08:41 +09:00
|
|
|
setSchedules([]); // 이전 달 데이터 즉시 초기화
|
2026-01-04 20:50:21 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const nextMonth = () => {
|
|
|
|
|
setSlideDirection(1);
|
2026-01-09 17:35:15 +09:00
|
|
|
const newDate = new Date(year, month + 1, 1);
|
|
|
|
|
setCurrentDate(newDate);
|
|
|
|
|
// 이번달이면 오늘, 다른 달이면 1일 선택
|
|
|
|
|
const today = new Date();
|
|
|
|
|
if (newDate.getFullYear() === today.getFullYear() && newDate.getMonth() === today.getMonth()) {
|
|
|
|
|
setSelectedDate(getTodayKST());
|
|
|
|
|
} else {
|
|
|
|
|
const firstDay = `${newDate.getFullYear()}-${String(newDate.getMonth() + 1).padStart(2, '0')}-01`;
|
|
|
|
|
setSelectedDate(firstDay);
|
|
|
|
|
}
|
2026-01-05 22:08:41 +09:00
|
|
|
setSchedules([]); // 이전 달 데이터 즉시 초기화
|
2026-01-04 20:50:21 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 년도 범위 이동
|
|
|
|
|
const prevYearRange = () => setCurrentDate(new Date(year - 10, month, 1));
|
|
|
|
|
const nextYearRange = () => setCurrentDate(new Date(year + 10, month, 1));
|
|
|
|
|
|
|
|
|
|
// 년도 선택 시 월 선택 모드로 전환
|
|
|
|
|
const selectYear = (newYear) => {
|
|
|
|
|
setCurrentDate(new Date(newYear, month, 1));
|
|
|
|
|
setViewMode('months');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 월 선택 시 적용 후 닫기
|
|
|
|
|
const selectMonth = (newMonth) => {
|
2026-01-09 17:35:15 +09:00
|
|
|
const newDate = new Date(year, newMonth, 1);
|
|
|
|
|
setCurrentDate(newDate);
|
|
|
|
|
// 이번달이면 오늘, 다른 달이면 1일 선택
|
|
|
|
|
const today = new Date();
|
|
|
|
|
if (newDate.getFullYear() === today.getFullYear() && newDate.getMonth() === today.getMonth()) {
|
|
|
|
|
setSelectedDate(getTodayKST());
|
|
|
|
|
} else {
|
|
|
|
|
const firstDay = `${year}-${String(newMonth + 1).padStart(2, '0')}-01`;
|
|
|
|
|
setSelectedDate(firstDay);
|
|
|
|
|
}
|
2026-01-04 20:50:21 +09:00
|
|
|
setShowYearMonthPicker(false);
|
|
|
|
|
setViewMode('yearMonth');
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-09 17:35:15 +09:00
|
|
|
// 날짜 선택 (토글 없이 항상 선택)
|
2026-01-04 20:50:21 +09:00
|
|
|
const selectDate = (day) => {
|
|
|
|
|
const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
|
2026-01-09 17:35:15 +09:00
|
|
|
setSelectedDate(dateStr);
|
2026-01-05 18:11:40 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 삭제 관련 상태
|
|
|
|
|
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
|
|
|
|
const [scheduleToDelete, setScheduleToDelete] = useState(null);
|
|
|
|
|
const [deleting, setDeleting] = useState(false);
|
|
|
|
|
|
|
|
|
|
// 삭제 확인 다이얼로그 열기
|
|
|
|
|
const openDeleteDialog = (schedule) => {
|
|
|
|
|
setScheduleToDelete(schedule);
|
|
|
|
|
setDeleteDialogOpen(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 일정 삭제
|
|
|
|
|
const handleDelete = async () => {
|
|
|
|
|
if (!scheduleToDelete) return;
|
|
|
|
|
|
|
|
|
|
setDeleting(true);
|
|
|
|
|
try {
|
2026-01-09 22:09:42 +09:00
|
|
|
await schedulesApi.deleteSchedule(scheduleToDelete.id);
|
|
|
|
|
setToast({ type: 'success', message: '일정이 삭제되었습니다.' });
|
|
|
|
|
fetchSchedules();
|
2026-01-05 18:11:40 +09:00
|
|
|
} catch (error) {
|
|
|
|
|
console.error('삭제 오류:', error);
|
2026-01-09 22:09:42 +09:00
|
|
|
setToast({ type: 'error', message: error.message || '삭제 중 오류가 발생했습니다.' });
|
2026-01-05 18:11:40 +09:00
|
|
|
} finally {
|
|
|
|
|
setDeleting(false);
|
|
|
|
|
setDeleteDialogOpen(false);
|
|
|
|
|
setScheduleToDelete(null);
|
|
|
|
|
}
|
|
|
|
|
};
|
2026-01-04 20:50:21 +09:00
|
|
|
|
2026-01-05 22:08:41 +09:00
|
|
|
// 검색어 정규화 (대소문자, 띄어쓰기, 특수문자 무시)
|
|
|
|
|
const normalizeForSearch = (str) => {
|
|
|
|
|
return (str || '').toLowerCase().replace(/[\s\-_.,!?#@]/g, '');
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-09 19:26:52 +09:00
|
|
|
// 일정 목록 (검색 모드일 때 searchResults, 일반 모드일 때 로컬 필터링) - useMemo로 최적화
|
|
|
|
|
const filteredSchedules = useMemo(() => {
|
|
|
|
|
if (isSearchMode) {
|
2026-01-10 09:16:15 +09:00
|
|
|
if (!searchTerm) return [];
|
|
|
|
|
// 카테고리 필터링 적용
|
|
|
|
|
if (selectedCategories.length === 0) return searchResults;
|
|
|
|
|
return searchResults.filter(s => selectedCategories.includes(s.category_id));
|
2026-01-09 19:26:52 +09:00
|
|
|
}
|
|
|
|
|
// 일반 모드: 로컬 필터링
|
|
|
|
|
return schedules.filter(schedule => {
|
2026-01-05 22:08:41 +09:00
|
|
|
const matchesCategory = selectedCategories.length === 0 || selectedCategories.includes(schedule.category_id);
|
2026-01-09 09:57:51 +09:00
|
|
|
const scheduleDate = formatDate(schedule.date);
|
2026-01-05 22:08:41 +09:00
|
|
|
const matchesDate = !selectedDate || scheduleDate === selectedDate;
|
|
|
|
|
return matchesCategory && matchesDate;
|
|
|
|
|
});
|
2026-01-09 19:26:52 +09:00
|
|
|
}, [isSearchMode, searchTerm, searchResults, schedules, selectedCategories, selectedDate]);
|
2026-01-10 09:34:18 +09:00
|
|
|
|
2026-01-10 09:52:34 +09:00
|
|
|
// 가상 스크롤 설정 (검색 모드에서만 활성화, 동적 높이 지원)
|
2026-01-10 09:34:18 +09:00
|
|
|
const virtualizer = useVirtualizer({
|
|
|
|
|
count: isSearchMode && searchTerm ? filteredSchedules.length : 0,
|
|
|
|
|
getScrollElement: () => scrollContainerRef.current,
|
2026-01-10 09:52:34 +09:00
|
|
|
estimateSize: () => ESTIMATED_ITEM_HEIGHT,
|
2026-01-10 09:34:18 +09:00
|
|
|
overscan: 5, // 버퍼 아이템 수
|
|
|
|
|
});
|
2026-01-05 22:08:41 +09:00
|
|
|
|
2026-01-09 19:26:52 +09:00
|
|
|
// 카테고리별 카운트 맵 (useMemo로 미리 계산) - 선택된 날짜 기준
|
|
|
|
|
const categoryCounts = useMemo(() => {
|
2026-01-11 15:58:20 +09:00
|
|
|
// 검색어가 있을 때만 검색 결과 사용, 아니면 기존 schedules 사용
|
2026-01-09 19:26:52 +09:00
|
|
|
const source = (isSearchMode && searchTerm) ? searchResults : schedules;
|
|
|
|
|
const counts = new Map();
|
|
|
|
|
let total = 0;
|
|
|
|
|
|
|
|
|
|
source.forEach(s => {
|
2026-01-11 15:58:20 +09:00
|
|
|
// 검색 모드에서 검색어가 있을 때는 전체 대상
|
|
|
|
|
// 그 외에는 선택된 날짜 기준으로 필터링
|
|
|
|
|
if (!(isSearchMode && searchTerm) && selectedDate) {
|
2026-01-09 19:26:52 +09:00
|
|
|
const scheduleDate = formatDate(s.date);
|
|
|
|
|
if (scheduleDate !== selectedDate) return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const catId = s.category_id;
|
|
|
|
|
counts.set(catId, (counts.get(catId) || 0) + 1);
|
|
|
|
|
total++;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
counts.set('total', total);
|
|
|
|
|
return counts;
|
|
|
|
|
}, [schedules, searchResults, isSearchMode, searchTerm, selectedDate]);
|
2026-01-04 20:50:21 +09:00
|
|
|
|
2026-01-06 14:16:29 +09:00
|
|
|
// 정렬된 카테고리 목록 (메모이제이션으로 깜빡임 방지)
|
|
|
|
|
const sortedCategories = useMemo(() => {
|
2026-01-09 19:26:52 +09:00
|
|
|
const total = categoryCounts.get('total') || 0;
|
|
|
|
|
|
2026-01-06 14:16:29 +09:00
|
|
|
return categories
|
|
|
|
|
.map(category => ({
|
|
|
|
|
...category,
|
2026-01-09 19:26:52 +09:00
|
|
|
count: category.id === 'all' ? total : (categoryCounts.get(category.id) || 0)
|
2026-01-06 14:16:29 +09:00
|
|
|
}))
|
|
|
|
|
.filter(category => category.id === 'all' || category.count > 0)
|
|
|
|
|
.sort((a, b) => {
|
|
|
|
|
if (a.id === 'all') return -1;
|
|
|
|
|
if (b.id === 'all') return 1;
|
|
|
|
|
if (a.name === '기타') return 1;
|
|
|
|
|
if (b.name === '기타') return -1;
|
|
|
|
|
return b.count - a.count;
|
|
|
|
|
});
|
2026-01-09 19:26:52 +09:00
|
|
|
}, [categories, categoryCounts]);
|
2026-01-06 14:16:29 +09:00
|
|
|
|
2026-01-04 20:50:21 +09:00
|
|
|
return (
|
2026-01-11 12:13:59 +09:00
|
|
|
<AdminLayout user={user}>
|
2026-01-04 20:50:21 +09:00
|
|
|
<Toast toast={toast} onClose={() => setToast(null)} />
|
|
|
|
|
|
2026-01-05 18:11:40 +09:00
|
|
|
{/* 삭제 확인 다이얼로그 */}
|
2026-01-09 23:36:34 +09:00
|
|
|
<ConfirmDialog
|
|
|
|
|
isOpen={deleteDialogOpen}
|
|
|
|
|
onClose={() => setDeleteDialogOpen(false)}
|
|
|
|
|
onConfirm={handleDelete}
|
|
|
|
|
title="일정 삭제"
|
|
|
|
|
message={
|
|
|
|
|
<>
|
|
|
|
|
<p className="text-gray-600 mb-2">다음 일정을 삭제하시겠습니까?</p>
|
|
|
|
|
<p className="text-gray-900 font-medium mb-4 p-3 bg-gray-50 rounded-lg">
|
|
|
|
|
{scheduleToDelete?.title}
|
|
|
|
|
</p>
|
|
|
|
|
<p className="text-sm text-red-500">이 작업은 되돌릴 수 없습니다.</p>
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
loading={deleting}
|
|
|
|
|
/>
|
2026-01-05 18:11:40 +09:00
|
|
|
|
2026-01-11 12:13:59 +09:00
|
|
|
{/* 메인 콘텐츠 - 전체 높이 차지 */}
|
|
|
|
|
<div className="h-full flex flex-col overflow-hidden max-w-7xl mx-auto px-6 py-8 w-full">
|
2026-01-04 20:50:21 +09:00
|
|
|
{/* 브레드크럼 */}
|
2026-01-10 00:30:12 +09:00
|
|
|
<div className="flex-shrink-0 flex items-center gap-2 text-sm text-gray-400 mb-8">
|
2026-01-04 20:50:21 +09:00
|
|
|
<Link to="/admin/dashboard" className="hover:text-primary transition-colors">
|
|
|
|
|
<Home size={16} />
|
|
|
|
|
</Link>
|
|
|
|
|
<ChevronRight size={14} />
|
|
|
|
|
<span className="text-gray-700">일정 관리</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 타이틀 + 추가 버튼 */}
|
2026-01-10 00:30:12 +09:00
|
|
|
<div className="flex-shrink-0 flex items-center justify-between mb-8">
|
2026-01-04 20:50:21 +09:00
|
|
|
<div>
|
|
|
|
|
<h1 className="text-3xl font-bold text-gray-900 mb-2">일정 관리</h1>
|
|
|
|
|
<p className="text-gray-500">fromis_9의 일정을 관리합니다</p>
|
|
|
|
|
</div>
|
2026-01-05 22:08:41 +09:00
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
<button
|
2026-01-06 12:26:40 +09:00
|
|
|
onClick={() => navigate('/admin/schedule/bots')}
|
2026-01-05 22:08:41 +09:00
|
|
|
className="flex items-center gap-2 px-5 py-3 bg-gray-100 text-gray-700 rounded-xl hover:bg-gray-200 transition-colors font-medium"
|
|
|
|
|
>
|
|
|
|
|
<Bot size={20} />
|
|
|
|
|
봇 관리
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
2026-01-06 12:26:40 +09:00
|
|
|
onClick={() => navigate('/admin/schedule/new')}
|
2026-01-05 22:08:41 +09:00
|
|
|
className="flex items-center gap-2 px-5 py-3 bg-primary text-white rounded-xl hover:bg-primary-dark transition-colors font-medium shadow-sm"
|
|
|
|
|
>
|
|
|
|
|
<Plus size={20} />
|
|
|
|
|
일정 추가
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2026-01-04 20:50:21 +09:00
|
|
|
</div>
|
|
|
|
|
|
2026-01-10 00:30:12 +09:00
|
|
|
<div className="flex-1 min-h-0 grid grid-cols-3 gap-8">
|
2026-01-04 20:50:21 +09:00
|
|
|
{/* 왼쪽: 달력 + 카테고리 필터 */}
|
|
|
|
|
<div className="space-y-6">
|
|
|
|
|
{/* 달력 (Schedule.jsx와 동일한 패턴) */}
|
2026-01-05 22:08:41 +09:00
|
|
|
<motion.div
|
|
|
|
|
ref={pickerRef}
|
|
|
|
|
animate={{ opacity: isSearchMode ? 0.4 : 1 }}
|
|
|
|
|
transition={{ duration: 0.2 }}
|
|
|
|
|
className={`bg-white rounded-2xl shadow-sm pt-8 px-8 pb-6 relative ${isSearchMode ? 'pointer-events-none' : ''}`}
|
|
|
|
|
>
|
2026-01-04 20:50:21 +09:00
|
|
|
{/* 달력 헤더 */}
|
2026-01-05 22:08:41 +09:00
|
|
|
<div className={`flex items-center justify-between mb-8 ${isSearchMode ? 'opacity-50' : ''}`}>
|
2026-01-04 20:50:21 +09:00
|
|
|
<button
|
|
|
|
|
onClick={prevMonth}
|
2026-01-05 22:08:41 +09:00
|
|
|
disabled={isSearchMode}
|
|
|
|
|
className={`p-2 rounded-full transition-colors ${isSearchMode ? 'cursor-not-allowed' : 'hover:bg-gray-100'}`}
|
2026-01-04 20:50:21 +09:00
|
|
|
>
|
2026-01-05 18:11:40 +09:00
|
|
|
<ChevronLeft size={24} />
|
2026-01-04 20:50:21 +09:00
|
|
|
</button>
|
|
|
|
|
<button
|
2026-01-05 22:08:41 +09:00
|
|
|
onClick={() => !isSearchMode && setShowYearMonthPicker(!showYearMonthPicker)}
|
|
|
|
|
disabled={isSearchMode}
|
|
|
|
|
className={`flex items-center gap-1 text-xl font-bold transition-colors ${isSearchMode ? 'cursor-not-allowed' : 'hover:text-primary'}`}
|
2026-01-04 20:50:21 +09:00
|
|
|
>
|
|
|
|
|
<span>{year}년 {month + 1}월</span>
|
2026-01-05 18:11:40 +09:00
|
|
|
<ChevronDown size={20} className={`transition-transform ${showYearMonthPicker ? 'rotate-180' : ''}`} />
|
2026-01-04 20:50:21 +09:00
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
onClick={nextMonth}
|
2026-01-05 22:08:41 +09:00
|
|
|
disabled={isSearchMode}
|
|
|
|
|
className={`p-2 rounded-full transition-colors ${isSearchMode ? 'cursor-not-allowed' : 'hover:bg-gray-100'}`}
|
2026-01-04 20:50:21 +09:00
|
|
|
>
|
2026-01-05 18:11:40 +09:00
|
|
|
<ChevronRight size={24} />
|
2026-01-04 20:50:21 +09:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 년/월 선택 팝업 (Schedule.jsx와 동일한 스타일) */}
|
|
|
|
|
<AnimatePresence>
|
|
|
|
|
{showYearMonthPicker && (
|
|
|
|
|
<motion.div
|
|
|
|
|
initial={{ opacity: 0, y: -10 }}
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
|
exit={{ opacity: 0, y: -10 }}
|
|
|
|
|
className="absolute top-16 left-6 right-6 bg-white rounded-xl shadow-lg border border-gray-200 p-4 z-10"
|
|
|
|
|
>
|
|
|
|
|
{/* 헤더 - 년도 범위 이동 */}
|
|
|
|
|
<div className="flex items-center justify-between mb-4">
|
|
|
|
|
<button
|
|
|
|
|
onClick={prevYearRange}
|
|
|
|
|
className="p-1.5 hover:bg-gray-100 rounded-lg transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<ChevronLeft size={20} className="text-gray-600" />
|
|
|
|
|
</button>
|
|
|
|
|
<span className="font-medium text-gray-900">
|
|
|
|
|
{viewMode === 'yearMonth' ? `${yearRange[0]} - ${yearRange[yearRange.length - 1]}` : `${year}년`}
|
|
|
|
|
</span>
|
|
|
|
|
<button
|
|
|
|
|
onClick={nextYearRange}
|
|
|
|
|
className="p-1.5 hover:bg-gray-100 rounded-lg transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<ChevronRight size={20} className="text-gray-600" />
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<AnimatePresence mode="wait">
|
|
|
|
|
{viewMode === 'yearMonth' && (
|
|
|
|
|
<motion.div
|
|
|
|
|
key="yearMonth"
|
|
|
|
|
initial={{ opacity: 0 }}
|
|
|
|
|
animate={{ opacity: 1 }}
|
|
|
|
|
exit={{ opacity: 0 }}
|
|
|
|
|
transition={{ duration: 0.15 }}
|
|
|
|
|
>
|
|
|
|
|
{/* 년도 선택 */}
|
|
|
|
|
<div className="text-center text-sm text-gray-500 mb-3">년도</div>
|
|
|
|
|
<div className="grid grid-cols-4 gap-2 mb-4">
|
|
|
|
|
{yearRange.map((y) => (
|
|
|
|
|
<button
|
|
|
|
|
key={y}
|
|
|
|
|
onClick={() => selectYear(y)}
|
|
|
|
|
className={`py-2 text-sm rounded-lg transition-colors ${
|
|
|
|
|
year === y
|
|
|
|
|
? 'bg-primary text-white'
|
|
|
|
|
: isCurrentYear(y) && year !== y
|
2026-01-09 22:47:32 +09:00
|
|
|
? 'text-primary font-medium hover:bg-primary/10'
|
2026-01-04 20:50:21 +09:00
|
|
|
: 'hover:bg-gray-100 text-gray-700'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{y}
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 월 선택 */}
|
|
|
|
|
<div className="text-center text-sm text-gray-500 mb-3">월</div>
|
|
|
|
|
<div className="grid grid-cols-4 gap-2">
|
|
|
|
|
{monthNames.map((m, i) => (
|
|
|
|
|
<button
|
|
|
|
|
key={m}
|
|
|
|
|
onClick={() => selectMonth(i)}
|
|
|
|
|
className={`py-2 text-sm rounded-lg transition-colors ${
|
|
|
|
|
month === i
|
|
|
|
|
? 'bg-primary text-white'
|
|
|
|
|
: isCurrentMonth(i) && month !== i
|
2026-01-09 22:47:32 +09:00
|
|
|
? 'text-primary font-medium hover:bg-primary/10'
|
2026-01-04 20:50:21 +09:00
|
|
|
: 'hover:bg-gray-100 text-gray-700'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{m}
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</motion.div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{viewMode === 'months' && (
|
|
|
|
|
<motion.div
|
|
|
|
|
key="months"
|
|
|
|
|
initial={{ opacity: 0 }}
|
|
|
|
|
animate={{ opacity: 1 }}
|
|
|
|
|
exit={{ opacity: 0 }}
|
|
|
|
|
transition={{ duration: 0.15 }}
|
|
|
|
|
>
|
|
|
|
|
{/* 월 선택 */}
|
|
|
|
|
<div className="text-center text-sm text-gray-500 mb-3">월 선택</div>
|
|
|
|
|
<div className="grid grid-cols-4 gap-2">
|
|
|
|
|
{monthNames.map((m, i) => (
|
|
|
|
|
<button
|
|
|
|
|
key={m}
|
|
|
|
|
onClick={() => selectMonth(i)}
|
|
|
|
|
className={`py-2.5 text-sm rounded-lg transition-colors ${
|
|
|
|
|
month === i
|
|
|
|
|
? 'bg-primary text-white'
|
|
|
|
|
: isCurrentMonth(i) && month !== i
|
2026-01-09 22:47:32 +09:00
|
|
|
? 'text-primary font-medium hover:bg-primary/10'
|
2026-01-04 20:50:21 +09:00
|
|
|
: 'hover:bg-gray-100 text-gray-700'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{m}
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</motion.div>
|
|
|
|
|
)}
|
|
|
|
|
</AnimatePresence>
|
|
|
|
|
</motion.div>
|
|
|
|
|
)}
|
|
|
|
|
</AnimatePresence>
|
|
|
|
|
|
|
|
|
|
{/* 요일 헤더 + 날짜 그리드 */}
|
|
|
|
|
<AnimatePresence mode="wait" initial={false}>
|
|
|
|
|
<motion.div
|
|
|
|
|
key={`${year}-${month}`}
|
|
|
|
|
initial={{ opacity: 0, x: slideDirection * 20 }}
|
|
|
|
|
animate={{ opacity: 1, x: 0 }}
|
|
|
|
|
exit={{ opacity: 0, x: slideDirection * -20 }}
|
|
|
|
|
transition={{ duration: 0.08 }}
|
|
|
|
|
>
|
|
|
|
|
{/* 요일 헤더 */}
|
2026-01-05 18:11:40 +09:00
|
|
|
<div className="grid grid-cols-7 mb-4">
|
2026-01-04 20:50:21 +09:00
|
|
|
{days.map((day, i) => (
|
|
|
|
|
<div
|
|
|
|
|
key={day}
|
|
|
|
|
className={`text-center text-sm font-medium py-2 ${
|
|
|
|
|
i === 0 ? 'text-red-500' : i === 6 ? 'text-blue-500' : 'text-gray-500'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{day}
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 날짜 그리드 */}
|
|
|
|
|
<div className="grid grid-cols-7 gap-1">
|
|
|
|
|
{/* 전달 날짜 */}
|
|
|
|
|
{Array.from({ length: firstDay }).map((_, i) => {
|
|
|
|
|
const prevMonthDays = getDaysInMonth(year, month - 1);
|
|
|
|
|
const day = prevMonthDays - firstDay + i + 1;
|
|
|
|
|
return (
|
2026-01-05 18:11:40 +09:00
|
|
|
<div key={`prev-${i}`} className="aspect-square flex items-center justify-center text-gray-300 text-base">
|
2026-01-04 20:50:21 +09:00
|
|
|
{day}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
|
|
|
|
|
{/* 현재 달 날짜 */}
|
|
|
|
|
{Array.from({ length: daysInMonth }).map((_, i) => {
|
|
|
|
|
const day = i + 1;
|
|
|
|
|
const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
|
|
|
|
|
const isSelected = selectedDate === dateStr;
|
|
|
|
|
const hasEvent = hasSchedule(day);
|
2026-01-05 22:08:41 +09:00
|
|
|
const eventColor = getScheduleColor(day);
|
2026-01-04 20:50:21 +09:00
|
|
|
const dayOfWeek = (firstDay + i) % 7;
|
|
|
|
|
const isToday = new Date().toDateString() === new Date(year, month, day).toDateString();
|
2026-01-06 19:48:43 +09:00
|
|
|
|
|
|
|
|
// 해당 날짜의 일정 목록 (점 표시용, 최대 3개)
|
|
|
|
|
const daySchedules = schedules.filter(s => {
|
|
|
|
|
const scheduleDate = s.date ? s.date.split('T')[0] : '';
|
|
|
|
|
const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
|
|
|
|
|
return scheduleDate === dateStr;
|
|
|
|
|
}).slice(0, 3);
|
2026-01-04 20:50:21 +09:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
key={day}
|
2026-01-05 22:08:41 +09:00
|
|
|
onClick={() => !isSearchMode && selectDate(day)}
|
|
|
|
|
disabled={isSearchMode}
|
|
|
|
|
className={`aspect-square flex flex-col items-center justify-center rounded-full text-base font-medium transition-all relative
|
|
|
|
|
${isSearchMode ? 'cursor-not-allowed opacity-50' : 'hover:bg-gray-100'}
|
|
|
|
|
${isSelected && !isSearchMode ? 'bg-primary text-white shadow-lg hover:bg-primary' : ''}
|
2026-01-06 19:48:43 +09:00
|
|
|
${isToday && !isSelected ? 'text-primary font-bold' : ''}
|
2026-01-04 20:50:21 +09:00
|
|
|
${dayOfWeek === 0 && !isSelected && !isToday ? 'text-red-500' : ''}
|
|
|
|
|
${dayOfWeek === 6 && !isSelected && !isToday ? 'text-blue-500' : ''}
|
|
|
|
|
`}
|
|
|
|
|
>
|
|
|
|
|
<span>{day}</span>
|
2026-01-06 19:48:43 +09:00
|
|
|
{/* 점: 선택되지 않은 날짜에만 표시, 최대 3개 */}
|
|
|
|
|
{!isSelected && daySchedules.length > 0 && (
|
|
|
|
|
<span className="absolute bottom-1 flex gap-0.5">
|
|
|
|
|
{daySchedules.map((schedule, idx) => (
|
|
|
|
|
<span
|
|
|
|
|
key={idx}
|
|
|
|
|
className="w-1 h-1 rounded-full"
|
|
|
|
|
style={{ backgroundColor: getColorStyle(categories.find(c => c.id === schedule.category_id)?.color)?.style?.backgroundColor || '#6b7280' }}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
2026-01-04 20:50:21 +09:00
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
|
|
|
|
|
{/* 다음달 날짜 */}
|
|
|
|
|
{(() => {
|
|
|
|
|
const totalCells = firstDay + daysInMonth;
|
|
|
|
|
const remainder = totalCells % 7;
|
|
|
|
|
const nextDays = remainder === 0 ? 0 : 7 - remainder;
|
|
|
|
|
return Array.from({ length: nextDays }).map((_, i) => (
|
2026-01-05 18:11:40 +09:00
|
|
|
<div key={`next-${i}`} className="aspect-square flex items-center justify-center text-gray-300 text-base">
|
2026-01-04 20:50:21 +09:00
|
|
|
{i + 1}
|
|
|
|
|
</div>
|
|
|
|
|
));
|
|
|
|
|
})()}
|
|
|
|
|
</div>
|
|
|
|
|
</motion.div>
|
|
|
|
|
</AnimatePresence>
|
2026-01-09 17:35:15 +09:00
|
|
|
{/* 범례 */}
|
|
|
|
|
<div className="mt-6 pt-4 border-t border-gray-100 flex items-center text-sm">
|
2026-01-05 18:11:40 +09:00
|
|
|
<div className="flex items-center gap-1.5 text-gray-500">
|
|
|
|
|
<span className="w-2 h-2 rounded-full bg-primary flex-shrink-0" />
|
|
|
|
|
<span className="leading-none">일정 있음</span>
|
|
|
|
|
</div>
|
2026-01-04 20:50:21 +09:00
|
|
|
</div>
|
2026-01-05 22:08:41 +09:00
|
|
|
</motion.div>
|
2026-01-04 20:50:21 +09:00
|
|
|
|
|
|
|
|
{/* 카테고리 필터 */}
|
2026-01-05 22:08:41 +09:00
|
|
|
<motion.div
|
|
|
|
|
animate={{ opacity: isSearchMode && !searchTerm ? 0.4 : 1 }}
|
|
|
|
|
transition={{ duration: 0.2 }}
|
|
|
|
|
className={`bg-white rounded-2xl shadow-sm p-6 ${isSearchMode && !searchTerm ? 'pointer-events-none' : ''}`}
|
|
|
|
|
>
|
2026-01-04 20:50:21 +09:00
|
|
|
<h3 className="font-bold text-gray-900 mb-4">카테고리</h3>
|
|
|
|
|
<div className="space-y-2">
|
2026-01-06 14:16:29 +09:00
|
|
|
{/* 카테고리 - useMemo로 정렬됨 */}
|
|
|
|
|
{sortedCategories.map(category => {
|
2026-01-05 18:11:40 +09:00
|
|
|
const isSelected = category.id === 'all'
|
|
|
|
|
? selectedCategories.length === 0
|
|
|
|
|
: selectedCategories.includes(category.id);
|
|
|
|
|
|
|
|
|
|
const handleClick = () => {
|
|
|
|
|
if (category.id === 'all') {
|
|
|
|
|
setSelectedCategories([]);
|
|
|
|
|
} else {
|
|
|
|
|
if (selectedCategories.includes(category.id)) {
|
|
|
|
|
setSelectedCategories(selectedCategories.filter(id => id !== category.id));
|
|
|
|
|
} else {
|
|
|
|
|
setSelectedCategories([...selectedCategories, category.id]);
|
2026-01-04 20:50:21 +09:00
|
|
|
}
|
2026-01-05 18:11:40 +09:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
key={category.id}
|
|
|
|
|
onClick={handleClick}
|
|
|
|
|
className={`w-full flex items-center gap-3 px-4 py-3 rounded-xl text-left transition-colors ${
|
|
|
|
|
isSelected
|
|
|
|
|
? 'bg-primary/10 text-primary'
|
|
|
|
|
: 'hover:bg-gray-50 text-gray-700'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
<span
|
|
|
|
|
className={`w-3 h-3 rounded-full ${category.id === 'all' ? 'bg-gray-400' : (getColorStyle(category.color).className || '')}`}
|
|
|
|
|
style={category.id !== 'all' ? getColorStyle(category.color).style : undefined}
|
|
|
|
|
/>
|
|
|
|
|
<span className="font-medium">{category.name}</span>
|
|
|
|
|
<span className="ml-auto text-sm text-gray-400">
|
2026-01-06 14:16:29 +09:00
|
|
|
{category.count}
|
2026-01-05 18:11:40 +09:00
|
|
|
</span>
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2026-01-04 20:50:21 +09:00
|
|
|
</div>
|
2026-01-05 22:08:41 +09:00
|
|
|
</motion.div>
|
2026-01-04 20:50:21 +09:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 오른쪽: 일정 목록 */}
|
2026-01-10 00:30:12 +09:00
|
|
|
<div className="col-span-2 flex flex-col min-h-0">
|
2026-01-04 20:50:21 +09:00
|
|
|
{/* 일정 목록 */}
|
2026-01-10 00:30:12 +09:00
|
|
|
<div className="flex-1 flex flex-col min-h-0 bg-white rounded-2xl shadow-sm overflow-hidden">
|
2026-01-05 22:08:41 +09:00
|
|
|
<div className="p-5 border-b border-gray-100">
|
|
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
<AnimatePresence mode="wait">
|
|
|
|
|
{isSearchMode ? (
|
|
|
|
|
/* 검색 모드 */
|
|
|
|
|
<motion.div
|
|
|
|
|
key="search-mode"
|
|
|
|
|
initial={{ opacity: 0, x: -10 }}
|
|
|
|
|
animate={{ opacity: 1, x: 0 }}
|
|
|
|
|
exit={{ opacity: 0, x: -10 }}
|
|
|
|
|
transition={{ duration: 0.15 }}
|
|
|
|
|
className="flex items-center gap-3 flex-1"
|
|
|
|
|
>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setIsSearchMode(false);
|
|
|
|
|
setSearchInput('');
|
|
|
|
|
setSearchTerm('');
|
|
|
|
|
}}
|
|
|
|
|
className="p-1.5 hover:bg-gray-100 rounded-lg transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<ArrowLeft size={20} className="text-gray-500" />
|
|
|
|
|
</button>
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder="일정 검색..."
|
|
|
|
|
value={searchInput}
|
|
|
|
|
autoFocus
|
|
|
|
|
onChange={(e) => setSearchInput(e.target.value)}
|
|
|
|
|
onKeyDown={(e) => {
|
|
|
|
|
if (e.key === 'Enter') {
|
|
|
|
|
setSearchTerm(searchInput);
|
|
|
|
|
} else if (e.key === 'Escape') {
|
|
|
|
|
setIsSearchMode(false);
|
|
|
|
|
setSearchInput('');
|
|
|
|
|
setSearchTerm('');
|
|
|
|
|
setSearchResults([]);
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
className="flex-1 bg-transparent focus:outline-none text-gray-700 placeholder-gray-400"
|
|
|
|
|
/>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setSearchTerm(searchInput);
|
|
|
|
|
}}
|
|
|
|
|
disabled={searchLoading}
|
|
|
|
|
className="px-4 py-1.5 bg-primary text-white text-sm font-medium rounded-lg hover:bg-primary/90 transition-colors disabled:opacity-50"
|
|
|
|
|
>
|
|
|
|
|
{searchLoading ? '...' : '검색'}
|
|
|
|
|
</button>
|
|
|
|
|
</motion.div>
|
|
|
|
|
) : (
|
|
|
|
|
/* 일반 모드 */
|
|
|
|
|
<motion.div
|
|
|
|
|
key="normal-mode"
|
|
|
|
|
initial={{ opacity: 0, x: 10 }}
|
|
|
|
|
animate={{ opacity: 1, x: 0 }}
|
|
|
|
|
exit={{ opacity: 0, x: 10 }}
|
|
|
|
|
transition={{ duration: 0.15 }}
|
|
|
|
|
className="flex items-center gap-3 flex-1"
|
|
|
|
|
>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => setIsSearchMode(true)}
|
|
|
|
|
className="p-1.5 hover:bg-gray-100 rounded-lg transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<Search size={20} className="text-gray-500" />
|
|
|
|
|
</button>
|
|
|
|
|
<span className="font-medium text-gray-900">
|
|
|
|
|
{selectedDate
|
|
|
|
|
? (() => {
|
|
|
|
|
const d = new Date(selectedDate);
|
|
|
|
|
const dayNames = ['일', '월', '화', '수', '목', '금', '토'];
|
|
|
|
|
return `${d.getMonth() + 1}월 ${d.getDate()}일 ${dayNames[d.getDay()]}요일`;
|
|
|
|
|
})()
|
|
|
|
|
: `${month + 1}월 전체 일정`
|
|
|
|
|
}
|
|
|
|
|
</span>
|
|
|
|
|
<div className="flex-1" />
|
|
|
|
|
{/* 카테고리 필터 */}
|
|
|
|
|
{selectedCategories.length > 0 && (
|
|
|
|
|
<div className="relative" ref={categoryTooltipRef}>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => setShowCategoryTooltip(!showCategoryTooltip)}
|
|
|
|
|
className="flex items-center gap-1 px-2 py-1 bg-gray-100 rounded-md text-sm text-gray-600 hover:bg-gray-200 transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<Tag size={14} />
|
2026-01-06 09:50:29 +09:00
|
|
|
<span>{selectedCategories.length}개 일정</span>
|
2026-01-05 22:08:41 +09:00
|
|
|
</button>
|
|
|
|
|
<AnimatePresence>
|
|
|
|
|
{showCategoryTooltip && (
|
|
|
|
|
<motion.div
|
|
|
|
|
initial={{ opacity: 0, y: -5 }}
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
|
exit={{ opacity: 0, y: -5 }}
|
|
|
|
|
transition={{ duration: 0.15 }}
|
|
|
|
|
className="absolute top-full right-0 mt-1 bg-white rounded-lg shadow-lg border border-gray-200 p-3 z-10 min-w-[120px]"
|
|
|
|
|
>
|
|
|
|
|
{selectedCategories.map(id => {
|
|
|
|
|
const cat = categories.find(c => c.id === id);
|
|
|
|
|
if (!cat) return null;
|
|
|
|
|
return (
|
|
|
|
|
<div key={id} className="flex items-center gap-2 py-1">
|
|
|
|
|
<span
|
|
|
|
|
className="w-2 h-2 rounded-full"
|
|
|
|
|
style={{ backgroundColor: cat.color?.startsWith('#') ? cat.color : undefined }}
|
|
|
|
|
/>
|
|
|
|
|
<span className="text-sm">{cat.name}</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</motion.div>
|
|
|
|
|
)}
|
|
|
|
|
</AnimatePresence>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2026-01-06 09:50:29 +09:00
|
|
|
<span className="text-sm text-gray-400">{filteredSchedules.length}개 일정</span>
|
2026-01-05 22:08:41 +09:00
|
|
|
</motion.div>
|
|
|
|
|
)}
|
|
|
|
|
</AnimatePresence>
|
2026-01-04 20:50:21 +09:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{loading ? (
|
|
|
|
|
<div className="flex justify-center items-center py-20">
|
|
|
|
|
<div className="animate-spin rounded-full h-12 w-12 border-4 border-primary border-t-transparent"></div>
|
|
|
|
|
</div>
|
|
|
|
|
) : filteredSchedules.length === 0 ? (
|
|
|
|
|
<div className="text-center py-16 text-gray-500">
|
|
|
|
|
<Calendar size={48} className="mx-auto mb-4 text-gray-300" />
|
|
|
|
|
<p>등록된 일정이 없습니다</p>
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
2026-01-06 19:48:43 +09:00
|
|
|
<div
|
2026-01-07 23:54:35 +09:00
|
|
|
ref={scrollContainerRef}
|
|
|
|
|
onScroll={handleScroll}
|
2026-01-06 19:48:43 +09:00
|
|
|
id="adminScheduleScrollContainer"
|
2026-01-10 00:30:12 +09:00
|
|
|
className="flex-1 overflow-y-auto divide-y divide-gray-100 py-2"
|
2026-01-06 19:48:43 +09:00
|
|
|
>
|
|
|
|
|
{isSearchMode && searchTerm ? (
|
2026-01-10 09:34:18 +09:00
|
|
|
/* 검색 모드: 가상 스크롤 */
|
2026-01-06 19:48:43 +09:00
|
|
|
<>
|
2026-01-10 09:34:18 +09:00
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
height: `${virtualizer.getTotalSize()}px`,
|
|
|
|
|
width: '100%',
|
|
|
|
|
position: 'relative',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{virtualizer.getVirtualItems().map((virtualItem) => {
|
|
|
|
|
const schedule = filteredSchedules[virtualItem.index];
|
|
|
|
|
if (!schedule) return null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
key={virtualItem.key}
|
2026-01-10 09:52:34 +09:00
|
|
|
ref={virtualizer.measureElement}
|
|
|
|
|
data-index={virtualItem.index}
|
2026-01-10 09:34:18 +09:00
|
|
|
style={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
top: 0,
|
|
|
|
|
left: 0,
|
|
|
|
|
width: '100%',
|
|
|
|
|
transform: `translateY(${virtualItem.start}px)`,
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-01-10 09:52:34 +09:00
|
|
|
<div className="p-5 hover:bg-gray-50 transition-colors group border-b border-gray-100">
|
2026-01-10 09:34:18 +09:00
|
|
|
<div className="flex items-start gap-4">
|
2026-01-10 09:50:56 +09:00
|
|
|
<div className="w-20 text-center flex-shrink-0">
|
2026-01-10 09:34:18 +09:00
|
|
|
<div className="text-xs text-gray-400 mb-0.5">
|
|
|
|
|
{new Date(schedule.date).getFullYear()}.{new Date(schedule.date).getMonth() + 1}
|
|
|
|
|
</div>
|
2026-01-10 09:50:56 +09:00
|
|
|
<div className="text-2xl font-bold text-gray-900">
|
2026-01-10 09:34:18 +09:00
|
|
|
{new Date(schedule.date).getDate()}
|
|
|
|
|
</div>
|
2026-01-10 09:50:56 +09:00
|
|
|
<div className="text-sm text-gray-500">
|
2026-01-10 09:34:18 +09:00
|
|
|
{['일', '월', '화', '수', '목', '금', '토'][new Date(schedule.date).getDay()]}요일
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-01-06 08:59:31 +09:00
|
|
|
|
2026-01-10 09:34:18 +09:00
|
|
|
<div
|
2026-01-10 09:50:56 +09:00
|
|
|
className="w-1.5 rounded-full flex-shrink-0 self-stretch"
|
2026-01-10 09:34:18 +09:00
|
|
|
style={{ backgroundColor: getColorStyle(categories.find(c => c.id === schedule.category_id)?.color)?.style?.backgroundColor || '#6b7280' }}
|
|
|
|
|
/>
|
2026-01-06 09:50:29 +09:00
|
|
|
|
2026-01-10 09:34:18 +09:00
|
|
|
<div className="flex-1 min-w-0">
|
2026-01-10 09:50:56 +09:00
|
|
|
<h3 className="font-semibold text-gray-900">{decodeHtmlEntities(schedule.title)}</h3>
|
|
|
|
|
<div className="flex items-center gap-3 mt-1 text-sm text-gray-500">
|
2026-01-10 09:34:18 +09:00
|
|
|
{schedule.time && (
|
|
|
|
|
<span className="flex items-center gap-1">
|
2026-01-10 09:50:56 +09:00
|
|
|
<Clock size={14} />
|
2026-01-10 09:34:18 +09:00
|
|
|
{schedule.time.slice(0, 5)}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
<span className="flex items-center gap-1">
|
2026-01-10 09:50:56 +09:00
|
|
|
<Tag size={14} />
|
2026-01-10 09:34:18 +09:00
|
|
|
{categories.find(c => c.id === schedule.category_id)?.name || '미분류'}
|
2026-01-06 19:48:43 +09:00
|
|
|
</span>
|
2026-01-10 09:34:18 +09:00
|
|
|
{schedule.source_name && (
|
|
|
|
|
<span className="flex items-center gap-1">
|
2026-01-10 09:50:56 +09:00
|
|
|
<Link2 size={14} />
|
2026-01-10 09:34:18 +09:00
|
|
|
{schedule.source_name}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
{schedule.member_names && (
|
2026-01-10 09:50:56 +09:00
|
|
|
<div className="flex flex-wrap gap-1.5 mt-2">
|
2026-01-10 09:34:18 +09:00
|
|
|
{schedule.member_names.split(',').length >= 5 ? (
|
2026-01-10 09:50:56 +09:00
|
|
|
<span className="px-2 py-0.5 bg-primary/10 text-primary text-xs font-medium rounded-full">
|
2026-01-10 09:34:18 +09:00
|
|
|
프로미스나인
|
|
|
|
|
</span>
|
|
|
|
|
) : (
|
|
|
|
|
schedule.member_names.split(',').map((name, i) => (
|
2026-01-10 09:50:56 +09:00
|
|
|
<span key={i} className="px-2 py-0.5 bg-primary/10 text-primary text-xs font-medium rounded-full">
|
2026-01-10 09:34:18 +09:00
|
|
|
{name.trim()}
|
|
|
|
|
</span>
|
|
|
|
|
))
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2026-01-06 09:50:29 +09:00
|
|
|
|
2026-01-10 09:50:56 +09:00
|
|
|
<div className="flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity">
|
2026-01-10 09:34:18 +09:00
|
|
|
{schedule.source_url && (
|
|
|
|
|
<a
|
|
|
|
|
href={schedule.source_url}
|
|
|
|
|
target="_blank"
|
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
|
onClick={(e) => e.stopPropagation()}
|
2026-01-10 09:50:56 +09:00
|
|
|
className="p-2 hover:bg-blue-100 rounded-lg transition-colors text-blue-500"
|
2026-01-10 09:34:18 +09:00
|
|
|
>
|
2026-01-10 09:50:56 +09:00
|
|
|
<ExternalLink size={18} />
|
2026-01-10 09:34:18 +09:00
|
|
|
</a>
|
|
|
|
|
)}
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => navigate(`/admin/schedule/${schedule.id}/edit`)}
|
2026-01-10 09:50:56 +09:00
|
|
|
className="p-2 hover:bg-gray-200 rounded-lg transition-colors text-gray-500"
|
2026-01-10 09:34:18 +09:00
|
|
|
>
|
2026-01-10 09:50:56 +09:00
|
|
|
<Edit2 size={18} />
|
2026-01-10 09:34:18 +09:00
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => openDeleteDialog(schedule)}
|
2026-01-10 09:50:56 +09:00
|
|
|
className="p-2 hover:bg-red-100 rounded-lg transition-colors text-red-500"
|
2026-01-10 09:34:18 +09:00
|
|
|
>
|
2026-01-10 09:50:56 +09:00
|
|
|
<Trash2 size={18} />
|
2026-01-10 09:34:18 +09:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-01-05 22:08:41 +09:00
|
|
|
</div>
|
2026-01-10 09:34:18 +09:00
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
2026-01-06 19:48:43 +09:00
|
|
|
|
|
|
|
|
{/* 무한 스크롤 트리거 & 로딩 인디케이터 */}
|
|
|
|
|
<div ref={loadMoreRef} className="py-4">
|
|
|
|
|
{isFetchingNextPage && (
|
|
|
|
|
<div className="flex justify-center">
|
|
|
|
|
<div className="w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" />
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2026-01-10 09:34:18 +09:00
|
|
|
{!hasNextPage && filteredSchedules.length > 0 && (
|
2026-01-06 19:48:43 +09:00
|
|
|
<div className="text-center text-sm text-gray-400">
|
2026-01-10 09:34:18 +09:00
|
|
|
{filteredSchedules.length}개 표시 (모두 로드됨)
|
2026-01-06 19:48:43 +09:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
) : (
|
2026-01-09 19:26:52 +09:00
|
|
|
/* 일반 모드: ScheduleItem 컴포넌트 사용 */
|
2026-01-06 19:48:43 +09:00
|
|
|
filteredSchedules.map((schedule, index) => (
|
2026-01-09 19:26:52 +09:00
|
|
|
<ScheduleItem
|
2026-01-06 19:48:43 +09:00
|
|
|
key={`${schedule.id}-${selectedDate || 'all'}`}
|
2026-01-09 19:26:52 +09:00
|
|
|
schedule={schedule}
|
|
|
|
|
index={index}
|
|
|
|
|
selectedDate={selectedDate}
|
|
|
|
|
categories={categories}
|
|
|
|
|
getColorStyle={getColorStyle}
|
|
|
|
|
navigate={navigate}
|
|
|
|
|
openDeleteDialog={openDeleteDialog}
|
|
|
|
|
/>
|
2026-01-06 19:48:43 +09:00
|
|
|
))
|
|
|
|
|
)}
|
2026-01-04 20:50:21 +09:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-01-11 12:13:59 +09:00
|
|
|
</div>
|
|
|
|
|
</AdminLayout>
|
2026-01-04 20:50:21 +09:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default AdminSchedule;
|