Skip to content

Commit

Permalink
Fix inspection frequency being uneditable
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Nov 9, 2023
1 parent 6dd329c commit bbbf69c
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,18 @@ function MissionDefinitionEditDialog({

const updateInspectionFrequencyFormDays = (newDay: string) => {
if (!Number(newDay) && newDay !== '') return
newDay = newDay === '' ? '0' : newDay
if (!form.inspectionFrequency) return newDay + '.00:00:00'
const inspectionArray = form.inspectionFrequency.split(':')
if (!inspectionArray || inspectionArray.length < 2) return newDay + '.00:00:00'
setForm({ ...form, inspectionFrequency: newDay + '.00:' + inspectionArray[1] + ':00' })

const formatInspectionFrequency = (dayStr: string) => {
dayStr = dayStr === '' ? '0' : dayStr
if (!form.inspectionFrequency) return dayStr + '.00:00:00'

const inspectionArray = form.inspectionFrequency.split(':')
if (!inspectionArray || inspectionArray.length < 2) return dayStr + '.00:00:00'

return dayStr + '.00:' + inspectionArray[1] + ':00'
}

setForm({ ...form, inspectionFrequency: formatInspectionFrequency(newDay) })
}

const getDayAndHoursFromInspectionFrequency = (inspectionFrequency: string | undefined): [number, number] => {
Expand Down

0 comments on commit bbbf69c

Please sign in to comment.