Use a pinia store to manage session state
Replace the convoluted useAccountSession composable with a pinia store that in addition allows for the consolidation of all session related functions to grouped into one module.
This commit is contained in:
parent
c47452a8b4
commit
fae8b4e2e4
21 changed files with 181 additions and 118 deletions
|
@ -77,6 +77,7 @@ definePageMeta({
|
|||
|
||||
const schedule = await useSchedule();
|
||||
const { data: accounts } = await useAccounts();
|
||||
const sessionStore = useSessionStore();
|
||||
|
||||
const route = useRoute();
|
||||
const crewFilter = computed({
|
||||
|
@ -90,14 +91,14 @@ const crewFilter = computed({
|
|||
}),
|
||||
});
|
||||
const eventSlotFilter = computed(() => {
|
||||
if (crewFilter.value === undefined || !session.value) {
|
||||
if (crewFilter.value === undefined || !sessionStore.account) {
|
||||
return () => true;
|
||||
}
|
||||
const cid = parseInt(crewFilter.value);
|
||||
return (slot: TimeSlot) => slot.assigned?.some(id => id === cid) || false;
|
||||
});
|
||||
const shiftSlotFilter = computed(() => {
|
||||
if (crewFilter.value === undefined || !session.value) {
|
||||
if (crewFilter.value === undefined || !sessionStore.account) {
|
||||
return () => true;
|
||||
}
|
||||
const cid = parseInt(crewFilter.value);
|
||||
|
@ -126,6 +127,5 @@ const roleFilter = computed({
|
|||
}),
|
||||
});
|
||||
|
||||
const { data: session } = await useAccountSession();
|
||||
const isAdmin = computed(() => session.value?.account.type === "admin")
|
||||
const isAdmin = computed(() => sessionStore.account?.type === "admin")
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue