Refaktoring verejneho profilu, pridani zobrazeni udalosti

This commit is contained in:
Michal Kváček
2023-10-14 22:43:16 +02:00
parent 5b47c56c6f
commit 4c8952117b
12 changed files with 228 additions and 49 deletions
@@ -0,0 +1,52 @@
<script setup>
import {fetchFlights, flights, loading as flightsLoading} from "src/composables/objects/flight";
import {fetchUser, user as pilot} from "src/composables/objects/user";
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";
const props = defineProps({
loggedUser: {
type: Object,
required: false
},
username: {
type: String,
required: true
}
});
// TODO: onmounted presunout do child komponent, stejne jako fetch dat
onMounted(() => {
fetchUser(props.username).then(user => {
useAppStore().setPageTitle(user.publicUsername);
useAppStore().setBreadcrumbs([
{to: {name: 'homepage'}, label: "Polétání.cz"},
{label: `@${user.publicUsername}`},
])
})
fetchFlights(props.username);
})
</script>
<template>
<PublicFlightEventSwitcher :username="username" />
<FlightsListSkeleton v-if="flightsLoading"/>
<q-banner class="bg-primary text-white" v-else-if="!flightsLoading && 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>