fix: resolve lint issues in maintenance schedule and editor page
Move getScheduleSummary to scheduleUtils.ts to satisfy react-refresh only-export-components rule. Add onScheduleLoaded to useEffect deps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -76,7 +76,7 @@ export function MaintenanceScheduleSection({ treeId, onScheduleLoaded }: Mainten
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
load()
|
load()
|
||||||
}, [treeId])
|
}, [treeId, onScheduleLoaded])
|
||||||
|
|
||||||
const hydrateFromSchedule = (s: MaintenanceSchedule) => {
|
const hydrateFromSchedule = (s: MaintenanceSchedule) => {
|
||||||
const parts = s.cron_expression.split(' ')
|
const parts = s.cron_expression.split(' ')
|
||||||
@@ -239,26 +239,3 @@ export function MaintenanceScheduleSection({ treeId, onScheduleLoaded }: Mainten
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
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}`
|
|
||||||
}
|
|
||||||
|
|||||||
24
frontend/src/components/procedural-editor/scheduleUtils.ts
Normal file
24
frontend/src/components/procedural-editor/scheduleUtils.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
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}`
|
||||||
|
}
|
||||||
@@ -5,7 +5,8 @@ import { treesApi } from '@/api/trees'
|
|||||||
import { useProceduralEditorStore } from '@/store/proceduralEditorStore'
|
import { useProceduralEditorStore } from '@/store/proceduralEditorStore'
|
||||||
import { CollapsibleEditorSection } from '@/components/procedural-editor/CollapsibleEditorSection'
|
import { CollapsibleEditorSection } from '@/components/procedural-editor/CollapsibleEditorSection'
|
||||||
import { IntakeFormBuilder } from '@/components/procedural-editor/IntakeFormBuilder'
|
import { IntakeFormBuilder } from '@/components/procedural-editor/IntakeFormBuilder'
|
||||||
import { MaintenanceScheduleSection, getScheduleSummary } from '@/components/procedural-editor/MaintenanceScheduleSection'
|
import { MaintenanceScheduleSection } from '@/components/procedural-editor/MaintenanceScheduleSection'
|
||||||
|
import { getScheduleSummary } from '@/components/procedural-editor/scheduleUtils'
|
||||||
import { StepList } from '@/components/procedural-editor/StepList'
|
import { StepList } from '@/components/procedural-editor/StepList'
|
||||||
import { TagInput } from '@/components/common/TagInput'
|
import { TagInput } from '@/components/common/TagInput'
|
||||||
import { toast } from '@/lib/toast'
|
import { toast } from '@/lib/toast'
|
||||||
|
|||||||
Reference in New Issue
Block a user