"use client"; import { Field, Input, Select } from "@/components/ui/field"; import type { Cadence } from "@/lib/schedule-types"; // A RECURRING REPORT'S CADENCE, as fields (R5): Create's recurring form and a // schedule's "Edit cadence" share them. Daily · Weekly on a day · Every N days, // at a time on the editor's clock. The value is the cadence common parses // (lib/report/schedule/cadence.ts), so a field never says what the editor // would not keep. const DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; export const DEFAULT_CADENCE: Cadence = { kind: "weekly", dow: 1, at: "06:00" }; export default function CadenceFields({ value, onChange, disabled, autoFocus }: { value: Cadence; onChange: (c: Cadence) => void; disabled?: boolean; autoFocus?: boolean }) { const at = value.at; return (
{value.kind === "weekly" && ( )} {value.kind === "every" && ( onChange({ kind: "every", days: Math.max(2, Math.min(365, Math.round(Number(e.target.value) || 2))), at })} /> )} onChange({ ...value, at: e.target.value || at })} />
); }