Ne uplne otestovany prepis storu

This commit is contained in:
Michal Kváček
2023-11-19 00:44:01 +01:00
parent e65491e00b
commit f9d70a5d57
76 changed files with 1445 additions and 1463 deletions
@@ -5,43 +5,46 @@ import {useRoute, useRouter} from "vue-router";
import {useQuasar} from "quasar";
import AircraftDetailSkeleton from "components/aircrafts/AircraftDetailSkeleton.vue";
import {successObject} from "src/composables/dialog";
import {loading, aircraft, fetchAircraft} from "src/composables/objects/aircraft";
import {useAppStore} from "stores/App";
import FlightsList from "components/flights/FlightsList.vue";
import AircraftDetailCard from "components/aircrafts/AircraftDetailCard.vue";
import {poi} from "src/composables/objects/poi";
import AccessDeniedBanner from "components/banners/AccessDeniedBanner.vue";
import {storeToRefs} from "pinia";
import {useUserStore} from "stores/User";
const $q = useQuasar();
const $router = useRouter();
const aircraftId = parseInt(useRoute().params.id);
onMounted(() => {
fetchAircraft(aircraftId);
useAircraftsStore().fetchDetail(aircraftId);
})
const deleteAircraft = (id) => {
useAircraftsStore().delete(id).then(() => {
$router.push({name: "aircrafts"});
$q.notify(successObject("Letadlo úspěšně odstraněno"));
});
}
const {aircraft, isQueryRunning} = storeToRefs(useAircraftsStore());
watch(() => aircraft.value, (newVal) => {
if (!newVal) return;
watch(aircraft, (newVal) => {
useAppStore().setPageTitle(newVal.callSign);
useAppStore().setBreadcrumbs([
{label: "Letadla", to: {name: "aircrafts"}},
{label: newVal.callSign}
])
});
const deleteAircraft = (id) => {
useAircraftsStore().destroy(id).then(() => {
$router.push({name: "aircrafts"});
$q.notify(successObject("Letadlo úspěšně odstraněno"));
});
}
</script>
<template>
<AircraftDetailSkeleton v-if="loading || !aircraft"/>
<AircraftDetailSkeleton v-if="isQueryRunning || !aircraft"/>
<template v-else>
<AircraftDetailCard :aircraft="aircraft" @delete="deleteAircraft" />
<AircraftDetailCard
:aircraft="aircraft"
@delete="deleteAircraft"
/>
<q-card class="flight-detail-card" flat>
<h3>Lety</h3>