import { TimeSlot, Participant } from '@/types/calendar'; import { days, hours } from '@/data/mockData'; import { cn } from '@/lib/utils'; import { Popover, PopoverContent, PopoverTrigger, } from '@/components/ui/popover'; import { Button } from '@/components/ui/button'; import { Check, X } from 'lucide-react'; interface AvailabilityHeatmapProps { slots: TimeSlot[]; selectedParticipants: Participant[]; onSlotSelect: (slot: TimeSlot) => void; showPartialAvailability?: boolean; } export const AvailabilityHeatmap = ({ slots, selectedParticipants, onSlotSelect, showPartialAvailability = false, }: AvailabilityHeatmapProps) => { const getSlot = (day: string, hour: number) => { return slots.find((s) => s.day === day && s.hour === hour); }; const getEffectiveAvailability = (slot: TimeSlot) => { if (slot.availability === 'partial' && !showPartialAvailability) { return 'none'; } return slot.availability; }; const formatHour = (hour: number) => { return `${hour.toString().padStart(2, '0')}:00`; }; const getWeekDateRange = () => { const now = new Date(); const monday = new Date(now); monday.setDate(now.getDate() - now.getDay() + 1); const friday = new Date(monday); friday.setDate(monday.getDate() + 4); const format = (d: Date) => d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }); return `${format(monday)} – ${format(friday)}`; }; if (selectedParticipants.length === 0) { return (

Select participants to view availability

Add people from the search above to see their common free times

); } return (

Common Availability — Week of {getWeekDateRange()}

{selectedParticipants.length} participant{selectedParticipants.length > 1 ? 's' : ''}: {selectedParticipants.map(p => p.name.split(' ')[0]).join(', ')}

{/* Header */}
{days.map((day) => (
{day}
))}
{/* Grid */}
{hours.map((hour) => (
{formatHour(hour)}
{days.map((day) => { const slot = getSlot(day, hour); if (!slot) return
; const effectiveAvailability = getEffectiveAvailability(slot); return ( )}
); })}
))}
{/* Legend */}
All free
{showPartialAvailability && (
Partial
)}
No overlap
); };