56 lines
1.8 KiB
Vue
56 lines
1.8 KiB
Vue
<script setup>
|
|
import {computed, onMounted} from "vue";
|
|
import {useAircraftsStore} from "stores/Aircrafts";
|
|
import {useFlightsStore} from "stores/Flights";
|
|
import {useRouter} from "vue-router";
|
|
import {usePointsOfInterestStore} from "stores/PointsOfInterest";
|
|
import {storeToRefs} from "pinia";
|
|
import {useAirportsStore} from "stores/Airports";
|
|
import {useAppStore} from "stores/App";
|
|
import FlightFormSteps from "components/flights/form/FlightFormSteps.vue";
|
|
import FlightFormBasic from "components/flights/form/FlightFormBasic.vue";
|
|
import FlightEditBasicInfoSkeleton from "components/flights/skeletons/FlightEditBasicInfoSkeleton.vue";
|
|
|
|
useAppStore().setPageTitle("Nový let");
|
|
useAppStore().setBreadcrumbs([
|
|
{to: {name: "myFlights"}, label: "Moje lety"},
|
|
{label: "Nový"}
|
|
]);
|
|
|
|
onMounted(() => {
|
|
useAircraftsStore().fetch({})
|
|
usePointsOfInterestStore().fetch({})
|
|
useAirportsStore().fetch()
|
|
});
|
|
|
|
const {isMutationRunning} = storeToRefs(useFlightsStore());
|
|
const {aircrafts} = storeToRefs(useAircraftsStore());
|
|
const {pointsOfInterest} = storeToRefs(usePointsOfInterestStore());
|
|
const {airports} = storeToRefs(useAirportsStore());
|
|
|
|
const loading = computed(() => [
|
|
useAircraftsStore().isQueryRunning, usePointsOfInterestStore().isQueryRunning, useAirportsStore().isQueryRunning
|
|
].some(i => i.value))
|
|
|
|
const $router = useRouter();
|
|
const handleSave = (formData) => {
|
|
useFlightsStore().create(formData).then((flight) => {
|
|
$router.push({name: "editFlightPhotos", params: {id: flight.id}});
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<FlightFormSteps :disabled="['copilot', 'track', 'photos', 'notes']"/>
|
|
|
|
<FlightEditBasicInfoSkeleton v-if="loading"/>
|
|
<FlightFormBasic
|
|
v-else
|
|
:is-request-pending="isMutationRunning"
|
|
:aircrafts="aircrafts"
|
|
:airports="airports"
|
|
:locations="pointsOfInterest"
|
|
@save="handleSave"
|
|
/>
|
|
</template>
|