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"; interface ScheduleConfigFormProps { config: ScheduleConfig; setConfig: React.Dispatch>; } export function ScheduleConfigForm({ config, setConfig, }: ScheduleConfigFormProps) { const handleChange = ( e: React.ChangeEvent ) => { const { name, value, type } = e.target; setConfig({ ...config, [name]: type === "checkbox" ? (e.target as HTMLInputElement).checked : value, }); }; // Convert seconds to human-readable format const formatInterval = (seconds: number): string => { if (seconds < 60) return `${seconds} seconds`; if (seconds < 3600) return `${Math.floor(seconds / 60)} minutes`; if (seconds < 86400) return `${Math.floor(seconds / 3600)} hours`; return `${Math.floor(seconds / 86400)} days`; }; // 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 (
handleChange({ target: { name: "enabled", type: "checkbox", checked: Boolean(checked), value: "", }, } as React.ChangeEvent) } />

How often the mirroring process should run.

{config.lastRun && (
{formatDate(config.lastRun)}
)} {config.nextRun && config.enabled && (
{formatDate(config.nextRun)}
)}
); }