import type { MaintenanceSchedule, TargetList } from '@/types' export function getScheduleSummary(schedule: MaintenanceSchedule | null, targetList?: TargetList | null): string { if (!schedule) return 'No schedule configured' const parts = schedule.cron_expression.split(' ') const min = parts[0] ?? '0' const hour = parts[1] ?? '0' const timeStr = `${hour.padStart(2, '0')}:${min.padStart(2, '0')}` const dayOfWeek = parts[4] const dayOfMonth = parts[2] let freqStr = 'Custom' if (dayOfMonth === '1') { freqStr = 'Monthly (1st)' } else if (dayOfMonth === '*' && parts[3] === '*') { if (dayOfWeek === '*') freqStr = 'Daily' else if (dayOfWeek === '1') freqStr = 'Every Monday' else if (dayOfWeek === '5') freqStr = 'Every Friday' } const targetStr = targetList ? ` \u00b7 ${targetList.targets.length} target${targetList.targets.length !== 1 ? 's' : ''}` : '' return `${freqStr} at ${timeStr} ${schedule.timezone}${targetStr}` }