Form updates

This commit is contained in:
Josh Dredge
2026-06-12 09:00:13 +10:00
parent 0f12250644
commit 9dbacaa4ac
+6 -12
View File
@@ -188,30 +188,24 @@ const aircraftOptionsData = ref<{ value: number; title: string }[]>(props.flight
watch(() => form.departure_date, (newVal) => { watch(() => form.departure_date, (newVal) => {
if (!newVal) return if (!newVal || form.arrival_date) return
const dep = new Date(newVal) const dep = new Date(newVal)
const arr = new Date(dep.getTime() + 60 * 60 * 1000) const arr = new Date(dep.getTime() + 60 * 60 * 1000)
// Format in local time, not UTC
const pad = (n: number) => String(n).padStart(2, '0') const pad = (n: number) => String(n).padStart(2, '0')
form.arrival_date = `${arr.getFullYear()}-${pad(arr.getMonth() + 1)}-${pad(arr.getDate())}T${pad(arr.getHours())}:${pad(arr.getMinutes())}` form.arrival_date = `${arr.getFullYear()}-${pad(arr.getMonth() + 1)}-${pad(arr.getDate())}T${pad(arr.getHours())}:${pad(arr.getMinutes())}`
}) })
const arrivalMin = computed(() => { const getArrivalBound = (form, offsetDays: number) => {
if (!form.departure_date) return undefined if (!form.departure_date) return undefined
const pad = (n: number) => String(n).padStart(2, '0') const pad = (n: number) => String(n).padStart(2, '0')
const d = new Date(form.departure_date) const d = new Date(form.departure_date)
d.setDate(d.getDate() - 2) d.setDate(d.getDate() + offsetDays)
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}` return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`
}) }
const arrivalMax = computed(() => { const arrivalMin = computed(() => getArrivalBound(form, -2))
if (!form.departure_date) return undefined const arrivalMax = computed(() => getArrivalBound(form, 3))
const pad = (n: number) => String(n).padStart(2, '0')
const d = new Date(form.departure_date)
d.setDate(d.getDate() + 3)
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`
})
</script> </script>
<template> <template>