2026-01-09 20:34:26 +09:00
|
|
|
import { useState, useEffect, useRef, useMemo, useDeferredValue, memo } from 'react';
|
2026-01-05 22:08:41 +09:00
|
|
|
import { useNavigate } from 'react-router-dom';
|
2025-12-31 22:28:47 +09:00
|
|
|
import { motion, AnimatePresence } from 'framer-motion';
|
2026-01-11 15:58:20 +09:00
|
|
|
import { Clock, ChevronLeft, ChevronRight, ChevronDown, Tag, Search, ArrowLeft, Link2, X } from 'lucide-react';
|
2026-01-12 15:51:27 +09:00
|
|
|
import { useQuery, 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-09 22:09:42 +09:00
|
|
|
import { getTodayKST } from '../../../utils/date';
|
|
|
|
|
import { getSchedules, getCategories, searchSchedules as searchSchedulesApi } from '../../../api/public/schedules';
|
2025-12-31 21:51:23 +09:00
|
|
|
|
2026-01-10 00:35:28 +09:00
|
|
|
// HTML 엔티티 디코딩 함수
|
|
|
|
|
const decodeHtmlEntities = (text) => {
|
|
|
|
|
if (!text) return '';
|
|
|
|
|
const textarea = document.createElement('textarea');
|
|
|
|
|
textarea.innerHTML = text;
|
|
|
|
|
return textarea.value;
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-31 21:51:23 +09:00
|
|
|
function Schedule() {
|
2026-01-05 22:08:41 +09:00
|
|
|
const navigate = useNavigate();
|
2026-01-06 08:09:17 +09:00
|
|
|
|
2025-12-31 22:08:01 +09:00
|
|
|
const [currentDate, setCurrentDate] = useState(new Date());
|
2026-01-06 08:09:17 +09:00
|
|
|
const [selectedDate, setSelectedDate] = useState(getTodayKST()); // KST 기준 오늘
|
2025-12-31 22:28:47 +09:00
|
|
|
const [showYearMonthPicker, setShowYearMonthPicker] = useState(false);
|
2026-01-05 22:08:41 +09:00
|
|
|
const [viewMode, setViewMode] = useState('yearMonth');
|
|
|
|
|
const [slideDirection, setSlideDirection] = useState(0);
|
2025-12-31 22:35:09 +09:00
|
|
|
const pickerRef = useRef(null);
|
|
|
|
|
|
2026-01-06 08:09:17 +09:00
|
|
|
|
2026-01-05 22:08:41 +09:00
|
|
|
// 데이터 상태
|
|
|
|
|
const [selectedCategories, setSelectedCategories] = useState([]);
|
2026-01-12 15:51:27 +09:00
|
|
|
|
|
|
|
|
// 카테고리 데이터 로드 (useQuery)
|
|
|
|
|
const { data: categories = [] } = useQuery({
|
|
|
|
|
queryKey: ['scheduleCategories'],
|
|
|
|
|
queryFn: getCategories,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 월별 일정 데이터 로드 (useQuery)
|
|
|
|
|
const year = currentDate.getFullYear();
|
|
|
|
|
const month = currentDate.getMonth();
|
|
|
|
|
const { data: schedules = [], isLoading: loading } = useQuery({
|
|
|
|
|
queryKey: ['schedules', year, month + 1],
|
|
|
|
|
queryFn: () => getSchedules(year, month + 1),
|
|
|
|
|
});
|
2026-01-05 22:08:41 +09:00
|
|
|
|
|
|
|
|
// 카테고리 필터 툴팁
|
|
|
|
|
const [showCategoryTooltip, setShowCategoryTooltip] = useState(false);
|
|
|
|
|
const categoryRef = useRef(null);
|
2026-01-09 20:34:26 +09:00
|
|
|
const scrollContainerRef = useRef(null); // 일정 목록 스크롤 컨테이너
|
2026-01-11 15:58:20 +09:00
|
|
|
const searchContainerRef = useRef(null); // 검색 컨테이너 (외부 클릭 감지용)
|
2026-01-05 22:08:41 +09:00
|
|
|
|
|
|
|
|
// 검색 상태
|
|
|
|
|
const [isSearchMode, setIsSearchMode] = useState(false);
|
2026-01-11 15:58:20 +09:00
|
|
|
const [searchInput, setSearchInput] = useState(''); // 입력창에 표시되는 값
|
|
|
|
|
const [originalSearchQuery, setOriginalSearchQuery] = useState(''); // 사용자가 직접 입력한 원본 값 (필터링용)
|
2026-01-05 22:08:41 +09:00
|
|
|
const [searchTerm, setSearchTerm] = useState('');
|
2026-01-11 15:58:20 +09:00
|
|
|
const [showSuggestions, setShowSuggestions] = useState(false);
|
|
|
|
|
const [selectedSuggestionIndex, setSelectedSuggestionIndex] = useState(-1);
|
2026-01-11 21:33:55 +09:00
|
|
|
const [suggestions, setSuggestions] = useState([]); // 추천 검색어 목록
|
|
|
|
|
const [isLoadingSuggestions, setIsLoadingSuggestions] = useState(false);
|
2026-01-10 09:20:27 +09:00
|
|
|
const SEARCH_LIMIT = 20; // 페이지당 20개
|
2026-01-10 09:46:38 +09:00
|
|
|
const ESTIMATED_ITEM_HEIGHT = 120; // 아이템 추정 높이 (동적 측정)
|
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,
|
|
|
|
|
refetch: refetchSearch,
|
|
|
|
|
} = useInfiniteQuery({
|
|
|
|
|
queryKey: ['scheduleSearch', 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;
|
|
|
|
|
|
2026-01-10 09:34:18 +09:00
|
|
|
|
|
|
|
|
|
2026-01-06 19:48:43 +09:00
|
|
|
// Auto fetch next page when scrolled to bottom
|
2026-01-11 19:06:52 +09:00
|
|
|
// inView가 true로 변경될 때만 fetch (중복 요청 방지)
|
|
|
|
|
const prevInViewRef = useRef(false);
|
2026-01-06 19:48:43 +09:00
|
|
|
useEffect(() => {
|
2026-01-11 19:06:52 +09:00
|
|
|
// inView가 false→true로 변경될 때만 fetch
|
|
|
|
|
if (inView && !prevInViewRef.current && hasNextPage && !isFetchingNextPage && isSearchMode && searchTerm) {
|
2026-01-06 19:48:43 +09:00
|
|
|
fetchNextPage();
|
|
|
|
|
}
|
2026-01-11 19:06:52 +09:00
|
|
|
prevInViewRef.current = inView;
|
2026-01-06 19:48:43 +09:00
|
|
|
}, [inView, hasNextPage, isFetchingNextPage, fetchNextPage, isSearchMode, searchTerm]);
|
2026-01-05 22:08:41 +09:00
|
|
|
|
2026-01-11 21:33:55 +09:00
|
|
|
// 검색어 자동완성 API 호출 (debounce 적용)
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// 검색어가 비어있으면 초기화
|
|
|
|
|
if (!originalSearchQuery || originalSearchQuery.trim().length === 0) {
|
|
|
|
|
setSuggestions([]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// debounce: 200ms 후에 API 호출
|
|
|
|
|
const timeoutId = setTimeout(async () => {
|
|
|
|
|
setIsLoadingSuggestions(true);
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(`/api/schedules/suggestions?q=${encodeURIComponent(originalSearchQuery)}&limit=10`);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
setSuggestions(data.suggestions || []);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('추천 검색어 API 오류:', error);
|
|
|
|
|
setSuggestions([]);
|
|
|
|
|
} finally {
|
|
|
|
|
setIsLoadingSuggestions(false);
|
|
|
|
|
}
|
|
|
|
|
}, 200);
|
|
|
|
|
|
|
|
|
|
return () => clearTimeout(timeoutId);
|
|
|
|
|
}, [originalSearchQuery]);
|
|
|
|
|
|
2026-01-12 15:51:27 +09:00
|
|
|
// 카테고리/일정 데이터는 상단에서 useQuery로 관리됨
|
2026-01-05 22:08:41 +09:00
|
|
|
|
2025-12-31 22:35:09 +09:00
|
|
|
// 외부 클릭시 팝업 닫기
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const handleClickOutside = (event) => {
|
|
|
|
|
if (pickerRef.current && !pickerRef.current.contains(event.target)) {
|
|
|
|
|
setShowYearMonthPicker(false);
|
2026-01-04 20:50:21 +09:00
|
|
|
setViewMode('yearMonth');
|
2025-12-31 22:35:09 +09:00
|
|
|
}
|
2026-01-05 22:08:41 +09:00
|
|
|
if (categoryRef.current && !categoryRef.current.contains(event.target)) {
|
|
|
|
|
setShowCategoryTooltip(false);
|
|
|
|
|
}
|
2026-01-11 15:58:20 +09:00
|
|
|
// 검색 추천 드롭다운 외부 클릭 시 닫기
|
|
|
|
|
if (searchContainerRef.current && !searchContainerRef.current.contains(event.target)) {
|
|
|
|
|
setShowSuggestions(false);
|
|
|
|
|
setSelectedSuggestionIndex(-1);
|
|
|
|
|
}
|
2025-12-31 22:35:09 +09:00
|
|
|
};
|
|
|
|
|
|
2026-01-05 22:08:41 +09:00
|
|
|
document.addEventListener('mousedown', handleClickOutside);
|
|
|
|
|
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
|
|
|
}, []);
|
2025-12-31 22:08:01 +09:00
|
|
|
|
2026-01-09 20:34:26 +09:00
|
|
|
// 날짜 변경 시 스크롤 맨 위로 초기화
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (scrollContainerRef.current) {
|
|
|
|
|
scrollContainerRef.current.scrollTop = 0;
|
|
|
|
|
}
|
|
|
|
|
}, [selectedDate]);
|
|
|
|
|
|
2025-12-31 22:08:01 +09:00
|
|
|
// 달력 관련 함수
|
2026-01-12 15:51:27 +09:00
|
|
|
const getDaysInMonth = (y, m) => new Date(y, m + 1, 0).getDate();
|
|
|
|
|
const getFirstDayOfMonth = (y, m) => new Date(y, m, 1).getDay();
|
2025-12-31 22:08:01 +09:00
|
|
|
|
2026-01-12 15:51:27 +09:00
|
|
|
// year, month는 상단에서 이미 선언됨 (useQuery)
|
2025-12-31 22:08:01 +09:00
|
|
|
const daysInMonth = getDaysInMonth(year, month);
|
|
|
|
|
const firstDay = getFirstDayOfMonth(year, month);
|
|
|
|
|
|
|
|
|
|
const days = ['일', '월', '화', '수', '목', '금', '토'];
|
|
|
|
|
|
2026-01-09 20:34:26 +09:00
|
|
|
// 스케줄 데이터를 지연 처리하여 달력 UI 응답성 향상
|
|
|
|
|
const deferredSchedules = useDeferredValue(schedules);
|
|
|
|
|
|
|
|
|
|
// 일정 날짜별 맵 (O(1) 조회용) - 지연된 데이터로 점 표시
|
|
|
|
|
const scheduleDateMap = useMemo(() => {
|
|
|
|
|
const map = new Map();
|
|
|
|
|
deferredSchedules.forEach(s => {
|
|
|
|
|
const dateStr = s.date ? s.date.split('T')[0] : '';
|
|
|
|
|
if (!map.has(dateStr)) {
|
|
|
|
|
map.set(dateStr, s);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return map;
|
|
|
|
|
}, [deferredSchedules]);
|
2026-01-05 22:08:41 +09:00
|
|
|
|
2026-01-09 20:34:26 +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 20:34:26 +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';
|
|
|
|
|
};
|
2025-12-31 22:08:01 +09:00
|
|
|
|
2026-01-09 20:34:26 +09:00
|
|
|
// 해당 날짜에 일정이 있는지 확인 (O(1))
|
2025-12-31 22:08:01 +09:00
|
|
|
const hasSchedule = (day) => {
|
|
|
|
|
const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
|
2026-01-09 20:34:26 +09:00
|
|
|
return scheduleDateMap.has(dateStr);
|
2025-12-31 22:08:01 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const prevMonth = () => {
|
2026-01-04 20:50:21 +09:00
|
|
|
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);
|
|
|
|
|
}
|
2025-12-31 22:08:01 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const nextMonth = () => {
|
2026-01-04 20:50:21 +09:00
|
|
|
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);
|
|
|
|
|
}
|
2025-12-31 22:08:01 +09:00
|
|
|
};
|
|
|
|
|
|
2026-01-09 17:35:15 +09:00
|
|
|
// 날짜 선택 (토글 없이 항상 선택)
|
2025-12-31 22:08:01 +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-04 20:50:21 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const selectYear = (newYear) => {
|
|
|
|
|
setCurrentDate(new Date(newYear, month, 1));
|
|
|
|
|
setViewMode('months');
|
2025-12-31 22:28:47 +09:00
|
|
|
};
|
|
|
|
|
|
2026-01-04 20:50:21 +09:00
|
|
|
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);
|
|
|
|
|
}
|
2025-12-31 22:28:47 +09:00
|
|
|
setShowYearMonthPicker(false);
|
2026-01-04 20:50:21 +09:00
|
|
|
setViewMode('yearMonth');
|
2025-12-31 22:08:01 +09:00
|
|
|
};
|
|
|
|
|
|
2026-01-05 22:08:41 +09:00
|
|
|
// 카테고리 토글
|
|
|
|
|
const toggleCategory = (categoryId) => {
|
|
|
|
|
setSelectedCategories(prev =>
|
|
|
|
|
prev.includes(categoryId)
|
|
|
|
|
? prev.filter(id => id !== categoryId)
|
|
|
|
|
: [...prev, categoryId]
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 필터링된 스케줄 (useMemo로 성능 최적화, 시간순 정렬)
|
|
|
|
|
const currentYearMonth = `${year}-${String(month + 1).padStart(2, '0')}`;
|
|
|
|
|
|
|
|
|
|
const filteredSchedules = useMemo(() => {
|
|
|
|
|
// 검색 모드일 때
|
|
|
|
|
if (isSearchMode) {
|
2026-01-06 08:46:10 +09:00
|
|
|
// 검색 전엔 빈 목록, 검색 후엔 API 결과 (Meilisearch 유사도순 유지)
|
2026-01-05 22:08:41 +09:00
|
|
|
if (!searchTerm) return [];
|
2026-01-10 09:16:15 +09:00
|
|
|
// 카테고리 필터링 적용
|
|
|
|
|
if (selectedCategories.length === 0) return searchResults;
|
|
|
|
|
return searchResults.filter(s => selectedCategories.includes(s.category_id));
|
2026-01-05 22:08:41 +09:00
|
|
|
}
|
2026-01-06 08:46:10 +09:00
|
|
|
|
2026-01-05 22:08:41 +09:00
|
|
|
|
|
|
|
|
// 일반 모드: 기존 필터링
|
|
|
|
|
return schedules
|
|
|
|
|
.filter(s => {
|
|
|
|
|
const scheduleDate = s.date ? s.date.split('T')[0] : '';
|
|
|
|
|
const matchesDate = selectedDate
|
|
|
|
|
? scheduleDate === selectedDate
|
|
|
|
|
: scheduleDate.startsWith(currentYearMonth);
|
|
|
|
|
const matchesCategory = selectedCategories.length === 0 || selectedCategories.includes(s.category_id);
|
|
|
|
|
return matchesDate && matchesCategory;
|
|
|
|
|
})
|
|
|
|
|
.sort((a, b) => {
|
|
|
|
|
const dateA = a.date ? a.date.split('T')[0] : '';
|
|
|
|
|
const dateB = b.date ? b.date.split('T')[0] : '';
|
|
|
|
|
if (dateA !== dateB) return dateA.localeCompare(dateB);
|
|
|
|
|
const timeA = a.time || '00:00:00';
|
|
|
|
|
const timeB = b.time || '00:00:00';
|
|
|
|
|
return timeA.localeCompare(timeB);
|
|
|
|
|
});
|
|
|
|
|
}, [schedules, selectedDate, currentYearMonth, selectedCategories, isSearchMode, searchTerm, searchResults]);
|
2025-12-31 21:51:23 +09:00
|
|
|
|
2026-01-10 09:46:38 +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:46:38 +09:00
|
|
|
estimateSize: () => ESTIMATED_ITEM_HEIGHT,
|
2026-01-10 09:34:18 +09:00
|
|
|
overscan: 5, // 버퍼 아이템 수
|
|
|
|
|
});
|
|
|
|
|
|
2026-01-09 21:42:29 +09:00
|
|
|
// 카테고리별 카운트 맵 (useMemo로 미리 계산) - 선택된 날짜 기준
|
|
|
|
|
const categoryCounts = useMemo(() => {
|
2026-01-11 15:58:20 +09:00
|
|
|
// 검색어가 있을 때만 검색 결과 사용, 아니면 기존 schedules 사용
|
2026-01-09 21:42:29 +09:00
|
|
|
const source = (isSearchMode && searchTerm) ? searchResults : schedules;
|
|
|
|
|
const counts = new Map();
|
|
|
|
|
let total = 0;
|
|
|
|
|
|
|
|
|
|
source.forEach(s => {
|
|
|
|
|
const scheduleDate = s.date ? s.date.split('T')[0] : '';
|
2026-01-11 15:58:20 +09:00
|
|
|
// 검색 모드에서 검색어가 있을 때는 전체 대상
|
|
|
|
|
// 그 외에는 선택된 날짜 기준으로 필터링
|
|
|
|
|
if (!(isSearchMode && searchTerm) && selectedDate) {
|
2026-01-09 21:42:29 +09:00
|
|
|
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]);
|
|
|
|
|
|
2025-12-31 21:51:23 +09:00
|
|
|
const formatDate = (dateStr) => {
|
|
|
|
|
const date = new Date(dateStr);
|
2025-12-31 22:08:01 +09:00
|
|
|
const dayNames = ['일', '월', '화', '수', '목', '금', '토'];
|
2025-12-31 21:51:23 +09:00
|
|
|
return {
|
|
|
|
|
month: date.getMonth() + 1,
|
|
|
|
|
day: date.getDate(),
|
2025-12-31 22:08:01 +09:00
|
|
|
weekday: dayNames[date.getDay()],
|
2025-12-31 21:51:23 +09:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-05 22:08:41 +09:00
|
|
|
// 일정 클릭 핸들러
|
|
|
|
|
const handleScheduleClick = (schedule) => {
|
2026-01-15 14:42:34 +09:00
|
|
|
// 유튜브 카테고리(id=2)는 상세 페이지로 이동
|
|
|
|
|
if (schedule.category_id === 2) {
|
|
|
|
|
navigate(`/schedule/${schedule.id}`);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-05 22:08:41 +09:00
|
|
|
// 설명이 없고 URL만 있으면 바로 링크 열기
|
|
|
|
|
if (!schedule.description && schedule.source_url) {
|
|
|
|
|
window.open(schedule.source_url, '_blank');
|
|
|
|
|
} else {
|
2026-01-09 21:42:29 +09:00
|
|
|
// 상세 페이지로 이동
|
2026-01-05 22:08:41 +09:00
|
|
|
navigate(`/schedule/${schedule.id}`);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-09 21:42:29 +09:00
|
|
|
const currentYear = new Date().getFullYear();
|
|
|
|
|
const isCurrentYear = (y) => y === currentYear;
|
2026-01-04 20:50:21 +09:00
|
|
|
const isCurrentMonth = (m) => {
|
2026-01-09 21:42:29 +09:00
|
|
|
const now = new Date();
|
|
|
|
|
return year === now.getFullYear() && m === now.getMonth();
|
2026-01-04 20:50:21 +09:00
|
|
|
};
|
2026-01-09 21:42:29 +09:00
|
|
|
|
|
|
|
|
// 연도 선택 범위
|
|
|
|
|
const [yearRangeStart, setYearRangeStart] = useState(currentYear - 1);
|
2026-01-09 22:47:32 +09:00
|
|
|
const yearRange = Array.from({ length: 12 }, (_, i) => yearRangeStart + i);
|
|
|
|
|
const monthNames = ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'];
|
2026-01-09 21:42:29 +09:00
|
|
|
const prevYearRange = () => setYearRangeStart(prev => prev - 3);
|
|
|
|
|
const nextYearRange = () => setYearRangeStart(prev => prev + 3);
|
2025-12-31 22:28:47 +09:00
|
|
|
|
2026-01-05 22:08:41 +09:00
|
|
|
// 선택된 카테고리 이름
|
|
|
|
|
const getSelectedCategoryNames = () => {
|
|
|
|
|
if (selectedCategories.length === 0) return '전체';
|
|
|
|
|
const names = selectedCategories.map(id => {
|
|
|
|
|
const cat = categories.find(c => c.id === id);
|
|
|
|
|
return cat?.name || '';
|
|
|
|
|
}).filter(Boolean);
|
|
|
|
|
if (names.length <= 2) return names.join(', ');
|
|
|
|
|
return `${names.slice(0, 2).join(', ')} 외 ${names.length - 2}개`;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 카테고리 색상 가져오기
|
|
|
|
|
const getCategoryColor = (categoryId) => {
|
|
|
|
|
const cat = categories.find(c => c.id === categoryId);
|
|
|
|
|
return cat?.color || '#808080';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getCategoryName = (categoryId) => {
|
|
|
|
|
const cat = categories.find(c => c.id === categoryId);
|
|
|
|
|
return cat?.name || '';
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-06 14:16:29 +09:00
|
|
|
// 정렬된 카테고리 목록 (메모이제이션으로 깜빡임 방지)
|
|
|
|
|
const sortedCategories = useMemo(() => {
|
|
|
|
|
return categories
|
2026-01-09 21:42:29 +09:00
|
|
|
.map(category => ({
|
|
|
|
|
...category,
|
|
|
|
|
count: categoryCounts.get(category.id) || 0
|
|
|
|
|
}))
|
2026-01-06 14:16:29 +09:00
|
|
|
.filter(category => category.count > 0)
|
|
|
|
|
.sort((a, b) => {
|
|
|
|
|
if (a.name === '기타') return 1;
|
|
|
|
|
if (b.name === '기타') return -1;
|
|
|
|
|
return b.count - a.count;
|
|
|
|
|
});
|
2026-01-09 21:42:29 +09:00
|
|
|
}, [categories, categoryCounts]);
|
2026-01-06 14:16:29 +09:00
|
|
|
|
2025-12-31 21:51:23 +09:00
|
|
|
return (
|
2026-01-11 11:26:17 +09:00
|
|
|
<div className="h-[calc(100vh-64px)] overflow-hidden flex flex-col">
|
|
|
|
|
<div className="flex-1 flex flex-col overflow-hidden max-w-7xl mx-auto px-6 py-8 w-full">
|
2025-12-31 21:51:23 +09:00
|
|
|
{/* 헤더 */}
|
2026-01-11 11:26:17 +09:00
|
|
|
<div className="flex-shrink-0 text-center mb-8">
|
2025-12-31 21:51:23 +09:00
|
|
|
<motion.h1
|
|
|
|
|
initial={{ opacity: 0, y: -20 }}
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
|
className="text-4xl font-bold mb-4"
|
|
|
|
|
>
|
2026-01-03 14:30:30 +09:00
|
|
|
일정
|
2025-12-31 21:51:23 +09:00
|
|
|
</motion.h1>
|
|
|
|
|
<motion.p
|
|
|
|
|
initial={{ opacity: 0 }}
|
|
|
|
|
animate={{ opacity: 1 }}
|
|
|
|
|
transition={{ delay: 0.2 }}
|
|
|
|
|
className="text-gray-500"
|
|
|
|
|
>
|
|
|
|
|
프로미스나인의 다가오는 일정을 확인하세요
|
|
|
|
|
</motion.p>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-01-11 11:26:17 +09:00
|
|
|
<div className="flex-1 min-h-0 grid grid-cols-3 gap-8">
|
2026-01-05 22:08:41 +09:00
|
|
|
{/* 왼쪽: 달력 + 카테고리 */}
|
2026-01-11 11:26:17 +09:00
|
|
|
<div className="space-y-6">
|
2026-01-05 22:08:41 +09:00
|
|
|
{/* 달력 */}
|
|
|
|
|
<motion.div
|
|
|
|
|
initial={{ opacity: 0, x: -20 }}
|
|
|
|
|
animate={{ opacity: isSearchMode ? 0.4 : 1, x: 0 }}
|
|
|
|
|
transition={{ duration: 0.2 }}
|
|
|
|
|
className={`${isSearchMode ? 'pointer-events-none' : ''}`}
|
|
|
|
|
>
|
|
|
|
|
<div className="bg-white rounded-2xl shadow-sm pt-8 px-8 pb-6 relative transition-all duration-200" ref={pickerRef}>
|
2025-12-31 22:08:01 +09:00
|
|
|
{/* 달력 헤더 */}
|
2025-12-31 22:28:47 +09:00
|
|
|
<div className="flex items-center justify-between mb-8">
|
2025-12-31 22:08:01 +09:00
|
|
|
<button
|
|
|
|
|
onClick={prevMonth}
|
|
|
|
|
className="p-2 hover:bg-gray-100 rounded-full transition-colors"
|
|
|
|
|
>
|
2025-12-31 22:28:47 +09:00
|
|
|
<ChevronLeft size={24} />
|
|
|
|
|
</button>
|
2026-01-04 20:50:21 +09:00
|
|
|
<button
|
|
|
|
|
onClick={() => setShowYearMonthPicker(!showYearMonthPicker)}
|
|
|
|
|
className="flex items-center gap-1 text-xl font-bold hover:text-primary transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<span>{year}년 {month + 1}월</span>
|
|
|
|
|
<ChevronDown size={20} className={`transition-transform ${showYearMonthPicker ? 'rotate-180' : ''}`} />
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
onClick={nextMonth}
|
|
|
|
|
className="p-2 hover:bg-gray-100 rounded-full transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<ChevronRight size={24} />
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2025-12-31 22:38:21 +09:00
|
|
|
|
2026-01-05 22:08:41 +09:00
|
|
|
{/* 년/월 선택 팝업 */}
|
2026-01-04 20:50:21 +09:00
|
|
|
<AnimatePresence>
|
|
|
|
|
{showYearMonthPicker && (
|
|
|
|
|
<motion.div
|
|
|
|
|
initial={{ opacity: 0, y: -10 }}
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
|
exit={{ opacity: 0, y: -10 }}
|
|
|
|
|
className="absolute top-20 left-8 right-8 mx-auto w-80 bg-white rounded-xl shadow-lg border border-gray-200 p-4 z-10"
|
|
|
|
|
>
|
2026-01-05 22:08:41 +09:00
|
|
|
<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>
|
2026-01-04 20:50:21 +09:00
|
|
|
|
2026-01-05 22:08:41 +09:00
|
|
|
<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' :
|
2026-01-09 22:47:32 +09:00
|
|
|
isCurrentYear(y) && year !== y ? 'text-primary font-medium hover:bg-primary/10' :
|
2026-01-05 22:08:41 +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' :
|
2026-01-09 22:47:32 +09:00
|
|
|
isCurrentMonth(i) && month !== i ? 'text-primary font-medium hover:bg-primary/10' :
|
2026-01-05 22:08:41 +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' :
|
2026-01-09 22:47:32 +09:00
|
|
|
isCurrentMonth(i) && month !== i ? 'text-primary font-medium hover:bg-primary/10' :
|
2026-01-05 22:08:41 +09:00
|
|
|
'hover:bg-gray-100 text-gray-700'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{m}
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</motion.div>
|
|
|
|
|
)}
|
|
|
|
|
</AnimatePresence>
|
2025-12-31 22:28:47 +09:00
|
|
|
</motion.div>
|
|
|
|
|
)}
|
|
|
|
|
</AnimatePresence>
|
|
|
|
|
|
2026-01-05 22:08:41 +09:00
|
|
|
{/* 요일 헤더 + 날짜 그리드 */}
|
2026-01-04 20:50:21 +09:00
|
|
|
<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 }}
|
|
|
|
|
layout
|
|
|
|
|
>
|
|
|
|
|
<div className="grid grid-cols-7 mb-4">
|
|
|
|
|
{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>
|
|
|
|
|
))}
|
2025-12-31 22:02:32 +09:00
|
|
|
</div>
|
2025-12-31 22:08:01 +09:00
|
|
|
|
2026-01-04 20:50:21 +09:00
|
|
|
<div className="grid grid-cols-7 gap-1">
|
2026-01-05 22:08:41 +09:00
|
|
|
{/* 전달 날짜 */}
|
|
|
|
|
{Array.from({ length: firstDay }).map((_, i) => {
|
|
|
|
|
const prevMonthDays = getDaysInMonth(year, month - 1);
|
|
|
|
|
const day = prevMonthDays - firstDay + i + 1;
|
|
|
|
|
return (
|
|
|
|
|
<div key={`prev-${i}`} className="aspect-square flex items-center justify-center text-gray-300 text-base">
|
|
|
|
|
{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);
|
|
|
|
|
const eventColor = getScheduleColor(day);
|
|
|
|
|
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-05 22:08:41 +09:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
key={day}
|
|
|
|
|
onClick={() => selectDate(day)}
|
|
|
|
|
className={`aspect-square flex flex-col items-center justify-center rounded-full text-base font-medium transition-all relative hover:bg-gray-100
|
|
|
|
|
${isSelected ? '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-05 22:08:41 +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: getCategoryColor(schedule.category_id) }}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
2026-01-05 22:08:41 +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) => (
|
|
|
|
|
<div key={`next-${i}`} className="aspect-square flex items-center justify-center text-gray-300 text-base">
|
|
|
|
|
{i + 1}
|
|
|
|
|
</div>
|
|
|
|
|
));
|
|
|
|
|
})()}
|
2026-01-04 20:50:21 +09:00
|
|
|
</div>
|
|
|
|
|
</motion.div>
|
|
|
|
|
</AnimatePresence>
|
2025-12-31 22:08:01 +09:00
|
|
|
|
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-04 20:50:21 +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>
|
2025-12-31 21:51:23 +09:00
|
|
|
</div>
|
2025-12-31 22:08:01 +09:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
2026-01-05 22:08:41 +09:00
|
|
|
{/* 카테고리 필터 */}
|
|
|
|
|
<motion.div
|
|
|
|
|
animate={{ opacity: isSearchMode && searchResults.length === 0 ? 0.4 : 1 }}
|
|
|
|
|
transition={{ duration: 0.2 }}
|
|
|
|
|
className={`bg-white rounded-2xl shadow-sm p-6 mt-4 ${isSearchMode && searchResults.length === 0 ? 'pointer-events-none' : ''}`}
|
|
|
|
|
>
|
|
|
|
|
<h3 className="font-bold text-gray-900 mb-4">카테고리</h3>
|
|
|
|
|
<div className="space-y-1">
|
|
|
|
|
{/* 전체 */}
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => setSelectedCategories([])}
|
|
|
|
|
className={`w-full flex items-center justify-between px-3 py-3 rounded-lg transition-colors ${
|
|
|
|
|
selectedCategories.length === 0 ? 'bg-primary/10 text-primary' : 'hover:bg-gray-50'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<span className="w-3 h-3 rounded-full bg-gray-400" />
|
|
|
|
|
<span>전체</span>
|
|
|
|
|
</div>
|
|
|
|
|
<span className="text-sm text-gray-400">
|
2026-01-09 21:43:45 +09:00
|
|
|
{categoryCounts.get('total') || 0}
|
2026-01-05 22:08:41 +09:00
|
|
|
</span>
|
|
|
|
|
</button>
|
|
|
|
|
|
2026-01-06 14:16:29 +09:00
|
|
|
{/* 개별 카테고리 - useMemo로 정렬됨 */}
|
|
|
|
|
{sortedCategories.map(category => {
|
2026-01-05 22:08:41 +09:00
|
|
|
const isSelected = selectedCategories.includes(category.id);
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
key={category.id}
|
|
|
|
|
onClick={() => toggleCategory(category.id)}
|
|
|
|
|
className={`w-full flex items-center justify-between px-3 py-3 rounded-lg transition-colors ${
|
|
|
|
|
isSelected ? 'bg-primary/10 text-primary' : 'hover:bg-gray-50'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<span
|
|
|
|
|
className="w-3 h-3 rounded-full"
|
|
|
|
|
style={{ backgroundColor: category.color }}
|
|
|
|
|
/>
|
|
|
|
|
<span>{category.name}</span>
|
|
|
|
|
</div>
|
2026-01-06 14:16:29 +09:00
|
|
|
<span className="text-sm text-gray-400">{category.count}</span>
|
2026-01-05 22:08:41 +09:00
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
</motion.div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-12-31 22:08:01 +09:00
|
|
|
{/* 스케줄 리스트 */}
|
2026-01-11 11:26:17 +09:00
|
|
|
<div className="col-span-2 flex flex-col min-h-0">
|
2026-01-05 22:08:41 +09:00
|
|
|
{/* 헤더 */}
|
2026-01-11 15:58:20 +09:00
|
|
|
<div className="flex items-center justify-between h-11 mb-2">
|
2026-01-05 22:08:41 +09:00
|
|
|
<AnimatePresence mode="wait">
|
|
|
|
|
{isSearchMode ? (
|
|
|
|
|
/* 검색 모드 - 밑줄 스타일 */
|
|
|
|
|
<motion.div
|
|
|
|
|
key="search-mode"
|
2026-01-11 15:58:20 +09:00
|
|
|
initial={{ opacity: 0, scale: 0.95 }}
|
|
|
|
|
animate={{ opacity: 1, scale: 1 }}
|
|
|
|
|
exit={{ opacity: 0, scale: 0.95 }}
|
|
|
|
|
transition={{ duration: 0.15, ease: 'easeOut' }}
|
|
|
|
|
className="flex items-center flex-1"
|
2025-12-31 22:08:01 +09:00
|
|
|
>
|
2026-01-11 15:58:20 +09:00
|
|
|
{/* 검색창 컨테이너 - 화살표와 검색창 일체형 */}
|
|
|
|
|
<div className="flex-1 relative" ref={searchContainerRef}>
|
|
|
|
|
<div className="flex items-center border border-gray-200 rounded-xl overflow-hidden">
|
|
|
|
|
{/* 뒤로가기 영역 */}
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
2026-01-05 22:08:41 +09:00
|
|
|
setIsSearchMode(false);
|
|
|
|
|
setSearchInput('');
|
2026-01-11 15:58:20 +09:00
|
|
|
setOriginalSearchQuery('');
|
2026-01-05 22:08:41 +09:00
|
|
|
setSearchTerm('');
|
2026-01-11 15:58:20 +09:00
|
|
|
setShowSuggestions(false);
|
|
|
|
|
setSelectedSuggestionIndex(-1);
|
|
|
|
|
// 스크롤 위치 초기화
|
|
|
|
|
if (scrollContainerRef.current) {
|
|
|
|
|
scrollContainerRef.current.scrollTop = 0;
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
className="flex items-center justify-center px-3 bg-gray-50 border-r border-gray-200 hover:bg-gray-100 transition-colors self-stretch"
|
|
|
|
|
>
|
|
|
|
|
<ArrowLeft size={18} className="text-gray-500" />
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
{/* 검색 입력 영역 */}
|
|
|
|
|
<div className="flex-1 flex items-center bg-white px-3 py-2.5">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder="제목, 멤버, 카테고리로 검색..."
|
|
|
|
|
value={searchInput}
|
|
|
|
|
autoFocus
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
setSearchInput(e.target.value);
|
|
|
|
|
setOriginalSearchQuery(e.target.value); // 원본 쿼리도 업데이트
|
|
|
|
|
setShowSuggestions(true);
|
|
|
|
|
setSelectedSuggestionIndex(-1);
|
|
|
|
|
}}
|
|
|
|
|
onFocus={() => setShowSuggestions(true)}
|
|
|
|
|
onKeyDown={(e) => {
|
|
|
|
|
if (e.key === 'ArrowDown') {
|
|
|
|
|
e.preventDefault();
|
2026-01-11 21:33:55 +09:00
|
|
|
const newIndex = selectedSuggestionIndex < suggestions.length - 1
|
2026-01-11 15:58:20 +09:00
|
|
|
? selectedSuggestionIndex + 1
|
|
|
|
|
: 0;
|
|
|
|
|
setSelectedSuggestionIndex(newIndex);
|
2026-01-11 21:33:55 +09:00
|
|
|
if (suggestions[newIndex]) {
|
|
|
|
|
setSearchInput(suggestions[newIndex]);
|
2026-01-11 15:58:20 +09:00
|
|
|
}
|
|
|
|
|
} else if (e.key === 'ArrowUp') {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
const newIndex = selectedSuggestionIndex > 0
|
|
|
|
|
? selectedSuggestionIndex - 1
|
2026-01-11 21:33:55 +09:00
|
|
|
: suggestions.length - 1;
|
2026-01-11 15:58:20 +09:00
|
|
|
setSelectedSuggestionIndex(newIndex);
|
2026-01-11 21:33:55 +09:00
|
|
|
if (suggestions[newIndex]) {
|
|
|
|
|
setSearchInput(suggestions[newIndex]);
|
2026-01-11 15:58:20 +09:00
|
|
|
}
|
|
|
|
|
} else if (e.key === 'Enter') {
|
2026-01-11 21:33:55 +09:00
|
|
|
if (selectedSuggestionIndex >= 0 && suggestions[selectedSuggestionIndex]) {
|
|
|
|
|
setSearchInput(suggestions[selectedSuggestionIndex]);
|
|
|
|
|
setSearchTerm(suggestions[selectedSuggestionIndex]);
|
2026-01-11 15:58:20 +09:00
|
|
|
} else if (searchInput.trim()) {
|
|
|
|
|
setSearchTerm(searchInput);
|
|
|
|
|
}
|
|
|
|
|
setShowSuggestions(false);
|
|
|
|
|
setSelectedSuggestionIndex(-1);
|
|
|
|
|
} else if (e.key === 'Escape') {
|
|
|
|
|
setIsSearchMode(false);
|
|
|
|
|
setSearchInput('');
|
|
|
|
|
setOriginalSearchQuery('');
|
|
|
|
|
setSearchTerm('');
|
|
|
|
|
setShowSuggestions(false);
|
|
|
|
|
setSelectedSuggestionIndex(-1);
|
|
|
|
|
// 스크롤 위치 초기화
|
|
|
|
|
if (scrollContainerRef.current) {
|
|
|
|
|
scrollContainerRef.current.scrollTop = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
className="flex-1 bg-transparent focus:outline-none text-gray-700 placeholder-gray-400 text-sm"
|
|
|
|
|
/>
|
|
|
|
|
{/* 입력 지우기 버튼 - 항상 공간 차지, 입력 있을 때만 보임 */}
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setSearchInput('');
|
|
|
|
|
setOriginalSearchQuery('');
|
|
|
|
|
setShowSuggestions(false);
|
|
|
|
|
setSelectedSuggestionIndex(-1);
|
|
|
|
|
}}
|
|
|
|
|
className={`p-1 rounded transition-colors ${searchInput ? 'hover:bg-gray-100 opacity-100' : 'opacity-0 pointer-events-none'}`}
|
|
|
|
|
>
|
|
|
|
|
<X size={16} className="text-gray-400" />
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 검색 버튼 영역 */}
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
if (searchInput.trim()) {
|
|
|
|
|
setSearchTerm(searchInput);
|
|
|
|
|
setShowSuggestions(false);
|
|
|
|
|
setSelectedSuggestionIndex(-1);
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
className="flex items-center justify-center px-6 bg-primary hover:bg-primary/90 transition-colors self-stretch"
|
|
|
|
|
>
|
|
|
|
|
<Search size={18} className="text-white" />
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 검색어 추천 드롭다운 */}
|
2026-01-11 21:39:23 +09:00
|
|
|
{showSuggestions && !isLoadingSuggestions && suggestions.length > 0 && (
|
2026-01-11 15:58:20 +09:00
|
|
|
<div className="absolute top-full mt-2 bg-white rounded-xl shadow-lg border border-gray-200 py-1 z-50 overflow-hidden" style={{ left: '44px', right: '66px' }}>
|
2026-01-11 21:39:23 +09:00
|
|
|
{suggestions.map((suggestion, index) => (
|
|
|
|
|
<button
|
|
|
|
|
key={index}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setSearchInput(suggestion);
|
|
|
|
|
setSearchTerm(suggestion);
|
|
|
|
|
setShowSuggestions(false);
|
|
|
|
|
setSelectedSuggestionIndex(-1);
|
|
|
|
|
}}
|
|
|
|
|
onMouseEnter={() => setSelectedSuggestionIndex(index)}
|
|
|
|
|
className={`w-full px-4 py-2.5 text-left flex items-center gap-3 transition-colors ${
|
|
|
|
|
selectedSuggestionIndex === index
|
|
|
|
|
? 'bg-primary/10 text-primary'
|
|
|
|
|
: 'hover:bg-gray-50 text-gray-700'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
<Search size={15} className={selectedSuggestionIndex === index ? 'text-primary' : 'text-gray-400'} />
|
|
|
|
|
<span className="text-sm">{suggestion}</span>
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
2026-01-11 15:58:20 +09:00
|
|
|
</div>
|
|
|
|
|
)}
|
2025-12-31 22:08:01 +09:00
|
|
|
</div>
|
2026-01-05 22:08:41 +09:00
|
|
|
</motion.div>
|
|
|
|
|
) : (
|
|
|
|
|
/* 일반 모드 */
|
|
|
|
|
<motion.div
|
|
|
|
|
key="normal-mode"
|
2026-01-11 15:58:20 +09:00
|
|
|
initial={{ opacity: 0, scale: 0.95 }}
|
|
|
|
|
animate={{ opacity: 1, scale: 1 }}
|
|
|
|
|
exit={{ opacity: 0, scale: 0.95 }}
|
|
|
|
|
transition={{ duration: 0.15, ease: 'easeOut' }}
|
2026-01-05 22:08:41 +09:00
|
|
|
className="flex items-center gap-3"
|
|
|
|
|
>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => setIsSearchMode(true)}
|
|
|
|
|
className="p-1.5 hover:bg-gray-100 rounded-lg transition-colors"
|
|
|
|
|
title="일정 검색"
|
|
|
|
|
>
|
|
|
|
|
<Search size={20} className="text-gray-500" />
|
|
|
|
|
</button>
|
|
|
|
|
<h2 className="text-lg font-bold text-gray-900">
|
|
|
|
|
{selectedDate
|
|
|
|
|
? (() => {
|
|
|
|
|
const d = new Date(selectedDate);
|
|
|
|
|
const dayNames = ['일', '월', '화', '수', '목', '금', '토'];
|
|
|
|
|
return `${d.getMonth() + 1}월 ${d.getDate()}일 ${dayNames[d.getDay()]}요일`;
|
|
|
|
|
})()
|
|
|
|
|
: `${month + 1}월 전체 일정`
|
|
|
|
|
}
|
|
|
|
|
</h2>
|
|
|
|
|
{selectedCategories.length > 0 && (
|
|
|
|
|
<div className="relative" ref={categoryRef}>
|
|
|
|
|
<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} />
|
|
|
|
|
<span>{selectedCategories.length}개 카테고리</span>
|
|
|
|
|
</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 left-0 mt-1 bg-white rounded-lg shadow-lg border border-gray-200 p-3 z-10 min-w-[150px]"
|
|
|
|
|
>
|
|
|
|
|
{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 }} />
|
|
|
|
|
<span className="text-sm">{cat.name}</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</motion.div>
|
|
|
|
|
)}
|
|
|
|
|
</AnimatePresence>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</motion.div>
|
|
|
|
|
)}
|
|
|
|
|
</AnimatePresence>
|
2026-01-06 09:50:29 +09:00
|
|
|
<AnimatePresence>
|
|
|
|
|
{!isSearchMode && (
|
|
|
|
|
<motion.span
|
|
|
|
|
key="count"
|
|
|
|
|
initial={{ opacity: 0, x: 10 }}
|
|
|
|
|
animate={{ opacity: 1, x: 0 }}
|
|
|
|
|
exit={{ opacity: 0, x: 10 }}
|
|
|
|
|
transition={{ duration: 0.15 }}
|
|
|
|
|
className="text-sm text-gray-500"
|
|
|
|
|
>
|
|
|
|
|
{filteredSchedules.length}개 일정
|
|
|
|
|
</motion.span>
|
|
|
|
|
)}
|
|
|
|
|
</AnimatePresence>
|
|
|
|
|
|
2026-01-05 22:08:41 +09:00
|
|
|
</div>
|
2025-12-31 21:51:23 +09:00
|
|
|
|
2026-01-06 19:48:43 +09:00
|
|
|
<div
|
2026-01-09 20:34:26 +09:00
|
|
|
ref={scrollContainerRef}
|
2026-01-06 19:48:43 +09:00
|
|
|
id="scheduleScrollContainer"
|
2026-01-11 11:26:17 +09:00
|
|
|
className="flex-1 min-h-0 overflow-y-auto space-y-4 py-2 pr-2"
|
2026-01-06 09:50:29 +09:00
|
|
|
>
|
2026-01-05 22:08:41 +09:00
|
|
|
{loading ? (
|
|
|
|
|
<div className="text-center py-20 text-gray-500">로딩 중...</div>
|
|
|
|
|
) : filteredSchedules.length > 0 ? (
|
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={{
|
2026-01-10 09:46:38 +09:00
|
|
|
height: `${virtualizer.getTotalSize()}px`,
|
2026-01-10 09:34:18 +09:00
|
|
|
width: '100%',
|
|
|
|
|
position: 'relative',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{virtualizer.getVirtualItems().map((virtualItem) => {
|
|
|
|
|
const schedule = filteredSchedules[virtualItem.index];
|
|
|
|
|
if (!schedule) return null;
|
|
|
|
|
|
|
|
|
|
const formatted = formatDate(schedule.date);
|
|
|
|
|
const categoryColor = getCategoryColor(schedule.category_id);
|
|
|
|
|
const categoryName = getCategoryName(schedule.category_id);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
key={virtualItem.key}
|
2026-01-10 09:46:38 +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-06 19:48:43 +09:00
|
|
|
>
|
2026-01-10 09:42:34 +09:00
|
|
|
<div className={virtualItem.index < filteredSchedules.length - 1 ? "pb-4" : ""}>
|
2026-01-10 09:40:40 +09:00
|
|
|
<div
|
|
|
|
|
onClick={() => handleScheduleClick(schedule)}
|
2026-01-10 09:50:56 +09:00
|
|
|
className="flex items-stretch bg-white rounded-2xl shadow-sm hover:shadow-md transition-shadow overflow-hidden cursor-pointer min-h-[100px]"
|
2026-01-10 09:40:40 +09:00
|
|
|
>
|
2026-01-10 09:34:18 +09:00
|
|
|
{/* 날짜 영역 */}
|
|
|
|
|
<div
|
|
|
|
|
className="w-24 flex flex-col items-center justify-center text-white"
|
|
|
|
|
style={{ backgroundColor: categoryColor }}
|
|
|
|
|
>
|
|
|
|
|
<span className="text-xs font-medium opacity-60">
|
|
|
|
|
{new Date(schedule.date).getFullYear()}.{new Date(schedule.date).getMonth() + 1}
|
2026-01-06 19:48:43 +09:00
|
|
|
</span>
|
2026-01-10 09:34:18 +09:00
|
|
|
<span className="text-3xl font-bold">{formatted.day}</span>
|
|
|
|
|
<span className="text-sm font-medium opacity-80">{formatted.weekday}</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 스케줄 내용 */}
|
|
|
|
|
<div className="flex-1 p-4 flex flex-col justify-center">
|
|
|
|
|
<h3 className="font-bold text-lg mb-1">{decodeHtmlEntities(schedule.title)}</h3>
|
|
|
|
|
|
|
|
|
|
<div className="flex flex-wrap gap-3 text-base text-gray-500">
|
|
|
|
|
{schedule.time && (
|
|
|
|
|
<span className="flex items-center gap-1">
|
|
|
|
|
<Clock size={16} className="opacity-60" />
|
|
|
|
|
{schedule.time.slice(0, 5)}
|
2026-01-06 19:48:43 +09:00
|
|
|
</span>
|
2026-01-10 09:34:18 +09:00
|
|
|
)}
|
|
|
|
|
<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}
|
2026-01-06 19:48:43 +09:00
|
|
|
</span>
|
2026-01-10 09:34:18 +09:00
|
|
|
)}
|
2026-01-06 19:48:43 +09:00
|
|
|
</div>
|
2026-01-10 09:34:18 +09:00
|
|
|
|
|
|
|
|
{(() => {
|
|
|
|
|
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-1">
|
|
|
|
|
<span className="px-2 py-0.5 bg-primary/10 text-primary text-sm font-medium rounded-full">
|
|
|
|
|
프로미스나인
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex flex-wrap gap-1.5 mt-1">
|
|
|
|
|
{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>
|
2026-01-10 09:40:40 +09:00
|
|
|
</div>
|
2026-01-10 09:34:18 +09:00
|
|
|
</div>
|
2026-01-06 19:48:43 +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>
|
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
/* 일반 모드: 기존 렌더링 */
|
|
|
|
|
filteredSchedules.map((schedule, index) => {
|
|
|
|
|
const formatted = formatDate(schedule.date);
|
|
|
|
|
const categoryColor = getCategoryColor(schedule.category_id);
|
|
|
|
|
const categoryName = getCategoryName(schedule.category_id);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<motion.div
|
|
|
|
|
key={`${schedule.id}-${selectedDate || 'all'}`}
|
|
|
|
|
initial={{ opacity: 0 }}
|
|
|
|
|
animate={{ opacity: 1 }}
|
|
|
|
|
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"
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
className="w-24 flex flex-col items-center justify-center text-white py-6"
|
|
|
|
|
style={{ backgroundColor: categoryColor }}
|
|
|
|
|
>
|
|
|
|
|
<span className="text-3xl font-bold">{formatted.day}</span>
|
|
|
|
|
<span className="text-sm font-medium opacity-80">{formatted.weekday}</span>
|
2025-12-31 22:08:01 +09:00
|
|
|
</div>
|
2026-01-06 19:48:43 +09:00
|
|
|
<div className="flex-1 p-6 flex flex-col justify-center">
|
2026-01-10 00:35:28 +09:00
|
|
|
<h3 className="font-bold text-lg mb-2">{decodeHtmlEntities(schedule.title)}</h3>
|
2026-01-06 19:48:43 +09:00
|
|
|
<div className="flex flex-wrap gap-3 text-base text-gray-500">
|
|
|
|
|
{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>
|
|
|
|
|
{(() => {
|
|
|
|
|
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>
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-01-06 00:27:35 +09:00
|
|
|
return (
|
|
|
|
|
<div className="flex flex-wrap gap-1.5 mt-2">
|
2026-01-06 19:48:43 +09:00
|
|
|
{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>
|
|
|
|
|
))}
|
2026-01-06 00:27:35 +09:00
|
|
|
</div>
|
|
|
|
|
);
|
2026-01-06 19:48:43 +09:00
|
|
|
})()}
|
|
|
|
|
</div>
|
|
|
|
|
</motion.div>
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
)
|
2026-01-05 22:08:41 +09:00
|
|
|
) : (
|
2026-01-11 15:58:20 +09:00
|
|
|
!isSearchMode && (
|
|
|
|
|
<motion.div
|
|
|
|
|
initial={{ opacity: 0, y: 10 }}
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
|
transition={{ duration: 0.2 }}
|
|
|
|
|
className="text-center py-20 text-gray-500"
|
|
|
|
|
>
|
|
|
|
|
{selectedDate ? '선택한 날짜에 일정이 없습니다.' : '예정된 일정이 없습니다.'}
|
|
|
|
|
</motion.div>
|
|
|
|
|
)
|
2026-01-05 22:08:41 +09:00
|
|
|
)}
|
2026-01-06 19:48:43 +09:00
|
|
|
</div>
|
2025-12-31 21:51:23 +09:00
|
|
|
</div>
|
2026-01-06 09:50:29 +09:00
|
|
|
|
2025-12-31 22:08:01 +09:00
|
|
|
</div>
|
2025-12-31 21:51:23 +09:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Schedule;
|