import { useState, useEffect } from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from "@/components/ui/dialog"; import { Service } from "@/types/service.types"; import { ServiceUptimeHistory } from "@/components/services/ServiceUptimeHistory"; import { useTheme } from "@/contexts/ThemeContext"; import { DateRangeFilter, DateRangeOption } from "@/components/services/DateRangeFilter"; interface ServiceHistoryDialogProps { isOpen: boolean; onOpenChange: (open: boolean) => void; selectedService: Service | null; } export const ServiceHistoryDialog = ({ isOpen, onOpenChange, selectedService, }: ServiceHistoryDialogProps) => { const { theme } = useTheme(); const [startDate, setStartDate] = useState(new Date(Date.now() - 24 * 60 * 60 * 1000)); // Default to 24h ago const [endDate, setEndDate] = useState(new Date()); // Reset date range when dialog opens to ensure fresh data useEffect(() => { if (isOpen) { setStartDate(new Date(Date.now() - 24 * 60 * 60 * 1000)); setEndDate(new Date()); } }, [isOpen]); // Handle date range filter changes const handleDateRangeChange = (start: Date, end: Date, option: DateRangeOption) => { console.log(`ServiceHistoryDialog: Date range changed to ${start.toISOString()} - ${end.toISOString()}`); setStartDate(start); setEndDate(end); }; return ( {selectedService?.name} - Uptime History Showing the most recent uptime checks for this service. {selectedService?.interval && ( Checked every {selectedService.interval} seconds. )}
{selectedService && ( )}
); };