'use client'; /** * Mini Calendar Component * * Compact month view calendar for quick date navigation. * Uses FullCalendar daygrid plugin for consistency with the main calendar. */ import { useCallback, useRef, useEffect } from 'react'; import FullCalendar from '@fullcalendar/react'; import dayGridPlugin from '@fullcalendar/daygrid'; import interactionPlugin from '@fullcalendar/interaction'; import nlLocale from '@fullcalendar/core/locales/nl'; import type { DateClickArg } from '@fullcalendar/interaction'; import { ChevronLeft, ChevronRight } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { format } from 'date-fns'; import { nl } from 'date-fns/locale'; interface MiniCalendarProps { selectedDate: Date; onDateSelect: (date: Date) => void; } export function MiniCalendar({ selectedDate, onDateSelect }: MiniCalendarProps) { const calendarRef = useRef(null); // Navigate to month containing selected date useEffect(() => { if (calendarRef.current) { const api = calendarRef.current.getApi(); api.gotoDate(selectedDate); } }, [selectedDate]); const handleDateClick = useCallback((info: DateClickArg) => { onDateSelect(info.date); }, [onDateSelect]); const handlePrevMonth = useCallback(() => { if (calendarRef.current) { calendarRef.current.getApi().prev(); } }, []); const handleNextMonth = useCallback(() => { if (calendarRef.current) { calendarRef.current.getApi().next(); } }, []); const handleToday = useCallback(() => { if (calendarRef.current) { calendarRef.current.getApi().today(); } onDateSelect(new Date()); }, [onDateSelect]); return (
{/* Custom header with month/year navigation */}
{/* Mini calendar */}
{ const isSelected = arg.date.toDateString() === selectedDate.toDateString(); return isSelected ? 'mini-cal-selected' : ''; }} />
); }