// frontend/src/components/settings/ScheduleSection.jsx import { CalendarClock, Clock, PlayCircle } from 'lucide-react'; import { SCHEDULE_TYPE, DEFAULT_CRON, DEFAULT_TIME, getScheduleSummary, buildDailyCron, buildWeeklyCron } from '../../utils/schedule'; export default function ScheduleSection({ schedule = {}, onUpdate }) { const enabled = schedule.enabled !== false; const type = schedule.type || SCHEDULE_TYPE.DAILY; const time = schedule.time || DEFAULT_TIME; const dayOfWeek = schedule.dayOfWeek || '1'; const cron = schedule.cron || DEFAULT_CRON; const setEnabled = (val) => onUpdate('schedule', { ...schedule, enabled: val }); const setType = (val) => { if (val === SCHEDULE_TYPE.DAILY) { onUpdate('schedule', { ...schedule, type: val, cron: buildDailyCron(time) }); } else if (val === SCHEDULE_TYPE.WEEKLY) { onUpdate('schedule', { ...schedule, type: val, dayOfWeek, cron: buildWeeklyCron(dayOfWeek, time) }); } else { onUpdate('schedule', { ...schedule, type: val, cron: schedule.cron || DEFAULT_CRON }); } }; const setTime = (val) => { const newCron = type === SCHEDULE_TYPE.WEEKLY ? buildWeeklyCron(dayOfWeek, val) : buildDailyCron(val); onUpdate('schedule', { ...schedule, type, time: val, cron: newCron }); }; const setDay = (val) => { onUpdate('schedule', { ...schedule, type, dayOfWeek: val, cron: buildWeeklyCron(val, time) }); }; const setCron = (val) => { onUpdate('schedule', { ...schedule, type: SCHEDULE_TYPE.CRON, cron: val }); }; return (