/** * CalendarUpcomingWidget — shows next 3 upcoming events (Task 5.25). */ import React from 'react'; import { useQuery } from '@tanstack/react-query'; import { useTranslation } from 'react-i18next'; import { listEntries, type CalendarEntry } from '@/api/calendar'; import { formatDateTime } from '@/utils/date'; import { Calendar, MapPin } from 'lucide-react'; export function CalendarUpcomingWidget() { const { t } = useTranslation(); const { data, isLoading, isError } = useQuery({ queryKey: ['calendarEntries', 'upcoming'], queryFn: () => listEntries(), staleTime: 60 * 1000, }); if (isLoading) { return
{t('dashboard.widgetError')}
; } const entries: CalendarEntry[] = data ?? []; const now = new Date(); const upcoming = entries .filter((e: CalendarEntry) => new Date(e.start_at || e.due_date || '') >= now) .slice(0, 3); if (upcoming.length === 0) { return{t('dashboard.noUpcomingEvents')}
; } return (