Vylepseni SSR, pridani meta informaci, zatim dost WIP

This commit is contained in:
Michal Kváček
2023-11-28 11:35:53 +01:00
parent 86605ad53e
commit 11cc6ad107
28 changed files with 371 additions and 403 deletions
@@ -1,55 +1,45 @@
<script>
import {useCopilotsStore} from "stores/Copilots";
export default {
preFetch({currentRoute}) {
return useCopilotsStore().fetchDetail(currentRoute.params.id, currentRoute.params.username);
}
}
</script>
<script setup>
import {useRoute} from "vue-router";
import {onMounted} from "vue";
import FlightsList from "components/flights/FlightsList.vue";
import {useAppStore} from "stores/App";
import BasicListSkeleton from "components/basicSkeletons/BasicListSkeleton.vue";
import {useUserStore} from "stores/User";
import {useCopilotsStore} from "stores/Copilots";
import {storeToRefs} from "pinia";
const $route = useRoute();
const copilotId = parseInt($route.params.id);
const props = defineProps({
loggedUser: {
pilot: {
type: Object,
required: false
},
username: {
type: String,
required: true
}
});
const {copilot, isQueryRunning} = storeToRefs(useCopilotsStore());
const {publicUser, isQueryRunning: isPilotQueryRunning} = storeToRefs(useUserStore());
onMounted(() => {
Promise.all([
useUserStore().fetchPublicUserDetail(props.username),
useCopilotsStore().fetchDetail(copilotId, props.username)
]).then(() => {
useAppStore().setPageTitle(`${publicUser.value.name} + ${copilot.value.name}`);
useAppStore().setBreadcrumbs([
{to: {name: 'homepage'}, label: "Polétání.cz"},
{to: {name: "publicProfileDetail", params: {username: props.username}}, label: `@${props.username}`},
{label: publicUser.value.name}
]);
});
});
useAppStore().setPageTitle(`${pilot.name} + ${copilot.value.name}`);
useAppStore().setBreadcrumbs([
{to: {name: 'homepage'}, label: "Polétání.cz"},
{to: {name: "publicProfileDetail", params: {username: props.username}}, label: `@${props.username}`},
{label: props.pilot.name}
]);
</script>
<template>
<BasicListSkeleton v-if="isQueryRunning || isPilotQueryRunning || !copilot" class="q-mb-md"/>
<BasicListSkeleton v-if="isQueryRunning || !copilot" class="q-mb-md"/>
<template v-else>
<h3>Společné lety</h3>
<FlightsList
:items="copilot.flights"
:route-detail="{name: 'publicFlightDetail', params: {username: username}}"
:route-detail="{name: 'publicFlightDetail', params: {username: pilot.publicUsername}}"
class="q-mb-md"
/>
</template>