import { Card, CardContent } from "@/components/ui/card"; import { Checkbox } from "../ui/checkbox"; import type { ScheduleConfig } from "@/types/config"; import { formatDate } from "@/lib/utils"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "../ui/select"; import { RefreshCw } from "lucide-react"; interface ScheduleConfigFormProps { config: ScheduleConfig; setConfig: React.Dispatch>; onAutoSave?: (config: ScheduleConfig) => void; isAutoSaving?: boolean; } export function ScheduleConfigForm({ config, setConfig, onAutoSave, isAutoSaving = false, }: ScheduleConfigFormProps) { const handleChange = ( e: React.ChangeEvent ) => { const { name, value, type } = e.target; const newConfig = { ...config, [name]: type === "checkbox" ? (e.target as HTMLInputElement).checked : value, }; setConfig(newConfig); // Trigger auto-save for schedule config changes if (onAutoSave) { onAutoSave(newConfig); } }; // Predefined intervals const intervals: { value: number; label: string }[] = [ // { value: 120, label: "2 minutes" }, //for testing { value: 900, label: "15 minutes" }, { value: 1800, label: "30 minutes" }, { value: 3600, label: "1 hour" }, { value: 7200, label: "2 hours" }, { value: 14400, label: "4 hours" }, { value: 28800, label: "8 hours" }, { value: 43200, label: "12 hours" }, { value: 86400, label: "1 day" }, { value: 172800, label: "2 days" }, { value: 604800, label: "1 week" }, ]; return ( {isAutoSaving && (
Auto-saving...
)}
handleChange({ target: { name: "enabled", type: "checkbox", checked: Boolean(checked), value: "", }, } as React.ChangeEvent) } />
{config.enabled && (

How often the mirroring process should run.

)}
{config.lastRun ? formatDate(config.lastRun) : "Never"}
{config.nextRun && config.enabled && (
{formatDate(config.nextRun)}
)}
); }