57 lines
1.6 KiB
Vue
57 lines
1.6 KiB
Vue
<script setup>
|
|
import FlightsListSkeleton from "components/flights/FlightsListSkeleton.vue";
|
|
import FlightsList from "components/flights/FlightsList.vue";
|
|
import PublicFlightEventSwitcher from "components/navigation/PublicFlightEventSwitcher.vue";
|
|
import {onMounted} from "vue";
|
|
import {useAppStore} from "stores/App";
|
|
import {useUserStore} from "stores/User";
|
|
import {useFlightsStore} from "stores/Flights";
|
|
import {storeToRefs} from "pinia";
|
|
|
|
const props = defineProps({
|
|
loggedUser: {
|
|
type: Object,
|
|
required: false
|
|
},
|
|
|
|
username: {
|
|
type: String,
|
|
required: true
|
|
}
|
|
});
|
|
|
|
onMounted(() => {
|
|
useUserStore().fetchPublicUserDetail(props.username).then(user => {
|
|
useAppStore().setPageTitle(user.publicUsername);
|
|
useAppStore().setBreadcrumbs([
|
|
{to: {name: 'homepage'}, label: "Polétání.cz"},
|
|
{label: `@${user.publicUsername}`},
|
|
])
|
|
})
|
|
|
|
useFlightsStore().fetch(props.username);
|
|
});
|
|
|
|
const {flights, isQueryRunning: areFlightsLoading} = storeToRefs(useFlightsStore());
|
|
const {publicUser: pilot} = storeToRefs(useUserStore());
|
|
</script>
|
|
|
|
<template>
|
|
<PublicFlightEventSwitcher :username="username" />
|
|
|
|
<FlightsListSkeleton v-if="areFlightsLoading"/>
|
|
|
|
<q-banner class="bg-primary text-white" v-else-if="!areFlightsLoading && flights.length === 0">
|
|
Tento pilot zatím nepublikoval žádný let.
|
|
</q-banner>
|
|
|
|
<template v-else>
|
|
<FlightsList
|
|
:items="flights"
|
|
:displayVisibilityInfo="loggedUser.id === pilot.id"
|
|
:route-detail="{name: 'publicFlightDetail', params: {username: username}}"
|
|
class="q-mb-md"
|
|
/>
|
|
</template>
|
|
</template>
|