import React from "react"; interface AvailabilityData { generalAvailableAfter: string; generalAvailableBefore: string; specifyTimesPerDay: boolean; weeklyTimes: { sunday: { availableAfter: string; availableBefore: string }; monday: { availableAfter: string; availableBefore: string }; tuesday: { availableAfter: string; availableBefore: string }; wednesday: { availableAfter: string; availableBefore: string }; thursday: { availableAfter: string; availableBefore: string }; friday: { availableAfter: string; availableBefore: string }; saturday: { availableAfter: string; availableBefore: string }; }; } interface AvailabilitySettingsProps { data: AvailabilityData; onChange: (field: string, value: string | boolean) => void; onWeeklyTimeChange: ( day: string, field: "availableAfter" | "availableBefore", value: string ) => void; } const AvailabilitySettings: React.FC = ({ data, onChange, onWeeklyTimeChange, }) => { const generateTimeOptions = () => { const options = []; for (let hour = 0; hour < 24; hour++) { const time24 = `${hour.toString().padStart(2, "0")}:00`; const hour12 = hour === 0 ? 12 : hour > 12 ? hour - 12 : hour; const period = hour < 12 ? "AM" : "PM"; const time12 = `${hour12}:00 ${period}`; options.push({ value: time24, label: time12 }); } return options; }; const handleGeneralChange = ( e: React.ChangeEvent ) => { const { name, value, type } = e.target; if (type === "checkbox") { const checked = (e.target as HTMLInputElement).checked; onChange(name, checked); } else { onChange(name, value); } }; return (
{/* General Times */}
{/* Checkbox for day-specific times */}
{/* Weekly Times */} {data.specifyTimesPerDay && (
Weekly Schedule
{Object.entries(data.weeklyTimes).map(([day, times]) => (
))}
)}
); }; export default AvailabilitySettings;