User can add/edit flights
This commit is contained in:
@@ -6,10 +6,11 @@ import AirlineSearchBox from '@/Components/FlightsGoneBy/AirlineSearchBox.vue'
|
||||
import AircraftSearchBox from '@/Components/FlightsGoneBy/AircraftSearchBox.vue'
|
||||
import AirportSearchBox from '@/Components/FlightsGoneBy/AirportSearchBox.vue'
|
||||
import type { SeatType, FlightReason, FlightClass} from '@/Types/types'
|
||||
import { ref } from 'vue'
|
||||
import { ref, watch, computed } from 'vue'
|
||||
|
||||
defineOptions({ layout: MainLayout })
|
||||
|
||||
|
||||
const props = defineProps<{
|
||||
flight?: {
|
||||
id: number
|
||||
@@ -162,6 +163,33 @@ const airlineOptionsData = ref<{ value: number; title: string }[]>(props.flight
|
||||
const fromOptionsData = ref<{ value: number; title: string; country_code: string }[]>(props.flight?.from_options ?? [])
|
||||
const toOptionsData = ref<{ value: number; title: string; country_code: string }[]>(props.flight?.to_options ?? [])
|
||||
const aircraftOptionsData = ref<{ value: number; title: string }[]>(props.flight?.aircraft_options ?? [])
|
||||
|
||||
|
||||
watch(() => form.departure_date, (newVal) => {
|
||||
if (!newVal) return
|
||||
const dep = new Date(newVal)
|
||||
const arr = new Date(dep.getTime() + 60 * 60 * 1000)
|
||||
|
||||
// Format in local time, not UTC
|
||||
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())}`
|
||||
})
|
||||
|
||||
const arrivalMin = computed(() => {
|
||||
if (!form.departure_date) return undefined
|
||||
const pad = (n: number) => String(n).padStart(2, '0')
|
||||
const d = new Date(form.departure_date)
|
||||
d.setDate(d.getDate() - 2)
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`
|
||||
})
|
||||
|
||||
const arrivalMax = computed(() => {
|
||||
if (!form.departure_date) return undefined
|
||||
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>
|
||||
|
||||
<template>
|
||||
@@ -221,6 +249,8 @@ const aircraftOptionsData = ref<{ value: number; title: string }[]>(props.flight
|
||||
type="datetime-local"
|
||||
:disabled="!lookupComplete"
|
||||
:error-messages="submitForm.errors.arrival_date"
|
||||
:min="arrivalMin"
|
||||
:max="arrivalMax"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
Reference in New Issue
Block a user