import React from 'react'; import { Clock } from 'lucide-react'; import { useTranslations } from 'next-intl'; import { TimeSlot } from '@/types/bookings'; interface TimeSlotSelectorProps { timeSlots: (TimeSlot & { availableCapacity?: number })[]; selectedTimeSlot: string; onTimeSlotChange: (slotId: string) => void; loading?: boolean; error?: string | null; } const TimeSlotSelector: React.FC = ({ timeSlots, selectedTimeSlot, onTimeSlotChange, loading = false, error = null, }) => { const t = useTranslations('bookingForm'); return (

{t('availableTimes')}

{loading ? (
Loading available times...
) : error ? (

{error}

) : timeSlots.length === 0 ? (

No available time slots for this date

) : (
{timeSlots .sort((a, b) => a.start_time.localeCompare(b.start_time)) .map((slot) => { const isAvailable = slot.is_active; // Format time to display as '11:30—12:30' in Tbilisi timezone (UTC+4) const formatTime = (time: string) => { // If it's already in HH:MM format, return as is if (time.match(/^\d{2}:\d{2}$/)) { return time; } // If it's ISO format or contains date, extract time portion in Tbilisi timezone if (time.includes('T') || time.includes(' ') || time.includes('Z')) { const date = new Date(time); return date.toLocaleTimeString('en-US', { timeZone: 'Asia/Tbilisi', hour12: false, hour: '2-digit', minute: '2-digit' }); } return time; }; const formattedTime = `${formatTime(slot.start_time)}—${formatTime(slot.end_time)}`; return ( ); })}
)}
); }; export default TimeSlotSelector;