import { useState } from "react"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Spinner } from "@/components/ui/spinner"; import { Check, X, Clock, ChevronRight } from "lucide-react"; export interface TimeSlot { date: string; time: string; duration?: string; } export interface MeetingTimePickerProps { status: "inProgress" | "executing" | "complete"; respond?: (response: string) => void; reasonForScheduling?: string; meetingDuration?: number; title?: string; timeSlots?: TimeSlot[]; } export function MeetingTimePicker({ status, respond, reasonForScheduling, meetingDuration, title = "Schedule a Meeting", timeSlots = [ { date: "Tomorrow", time: "2:00 PM", duration: "30 min" }, { date: "Friday", time: "10:00 AM", duration: "30 min" }, { date: "Next Monday", time: "3:00 PM", duration: "30 min" }, ], }: MeetingTimePickerProps) { const displayTitle = reasonForScheduling || title; const slots = meetingDuration ? timeSlots.map((slot) => ({ ...slot, duration: `${meetingDuration} min` })) : timeSlots; const [selectedSlot, setSelectedSlot] = useState(null); const [declined, setDeclined] = useState(false); const handleSelectSlot = (slot: TimeSlot) => { setSelectedSlot(slot); respond?.( `Meeting scheduled for ${slot.date} at ${slot.time}${slot.duration ? ` (${slot.duration})` : ""}.`, ); }; const handleDecline = () => { setDeclined(true); respond?.( "The user declined all proposed meeting times. Please suggest alternative times or ask for their availability.", ); }; // Confirmed state if (selectedSlot) { return (

Meeting Scheduled

{selectedSlot.date} at {selectedSlot.time}

{selectedSlot.duration && ( {selectedSlot.duration} )}
); } // Declined state if (declined) { return (

No Time Selected

Looking for a better time that works for you

); } // Selection state return (

{displayTitle}

{status === "inProgress" ? "Finding available times..." : "Pick a time that works for you"}

{status === "inProgress" && (
)} {status === "executing" && (
{slots.map((slot, index) => ( ))}
)}
); }