'use client'; import { useTranslations } from 'next-intl'; import { ChevronRight } from 'lucide-react'; import { Link } from '@/i18n/navigation'; import { Card } from '@/components/ui/shared/Card'; import { formatTimeForInput } from '@/components/appointments/appointmentTime'; import { canAccessAppointmentsSection } from '@/components/shared/permissions'; import { useAuth } from '@/lib/hooks/useAuth'; import { ListRowSkeleton } from '@/components/today/TodaySkeleton'; import type { TodaySummaryActions } from '@/types/today'; interface TodayUpcomingAppointmentsProps { actions: TodaySummaryActions; loading?: boolean; isInitialLoad?: boolean; } export function TodayUpcomingAppointments({ actions, loading = false, isInitialLoad = false, }: TodayUpcomingAppointmentsProps) { const t = useTranslations('today'); const { currentOrganization } = useAuth(); if (!canAccessAppointmentsSection(currentOrganization)) { return null; } const appointments = actions.upcomingAppointmentsToday ?? []; if (isInitialLoad) { return ( {[0, 1, 2].map((key) => ( ))} ); } return ( {t('upcomingAppointmentsTitle')} {t('upcomingAppointmentsSubtitle')} {t('viewAllAppointments')} {appointments.length === 0 ? ( {t('noUpcomingAppointments')} ) : ( {appointments.map((appointment) => { const start = new Date(appointment.startAt); const end = new Date(appointment.endAt); const timeLabel = `${formatTimeForInput(start)} – ${formatTimeForInput(end)}`; return ( {appointment.patientName} {timeLabel} {appointment.purpose ? ( · {appointment.purpose} ) : null} ); })} )} ); }
{t('upcomingAppointmentsSubtitle')}
{t('noUpcomingAppointments')}
{appointment.patientName}
{timeLabel} {appointment.purpose ? ( · {appointment.purpose} ) : null}