interface DaySchedule { day: 'Sunday' | 'Monday' | 'Tuesday' | 'Wednesday' | 'Thursday' | 'Friday' | 'Saturday'; open?: string; close?: string; closed?: boolean; } interface ScheduleCardProps { schedules: DaySchedule[]; onSuggestEdit?: () => void; } const DAYS: DaySchedule['day'][] = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', ]; function getCurrentDay(): DaySchedule['day'] { return DAYS[new Date().getDay()]; } function isOpenNow(schedules: DaySchedule[]): boolean { const today = getCurrentDay(); const todaySchedule = schedules.find((s) => s.day === today); if (!todaySchedule || todaySchedule.closed || !todaySchedule.open || !todaySchedule.close) return false; const now = new Date(); const [openHour, openMin] = todaySchedule.open.replace(/[^0-9.]/g, '').split('.').map(Number); const [closeHour, closeMin] = todaySchedule.close.replace(/[^0-9.]/g, '').split('.').map(Number); const openIsPm = todaySchedule.open.toUpperCase().includes('PM'); const closeIsPm = todaySchedule.close.toUpperCase().includes('PM'); const openTotal = (openIsPm && openHour !== 12 ? openHour + 12 : openHour) * 60 + (openMin || 0); const closeTotal = (closeIsPm && closeHour !== 12 ? closeHour + 12 : closeHour) * 60 + (closeMin || 0); const nowTotal = now.getHours() * 60 + now.getMinutes(); return nowTotal >= openTotal && nowTotal < closeTotal; } export function ScheduleCard({ schedules, onSuggestEdit }: ScheduleCardProps) { const today = getCurrentDay(); return (
No data yet
) : (