Use a pinia store to manage account state
All checks were successful
/ build (push) Successful in 3m29s
/ deploy (push) Successful in 47s

Refactor the existing scattered code dealing with the account state into
a pinia store.
This commit is contained in:
Hornwitser 2025-05-24 20:01:23 +02:00
parent fae8b4e2e4
commit e722876aae
12 changed files with 126 additions and 98 deletions

View file

@ -19,7 +19,7 @@
</select>
</label>
<h2>Locations</h2>
<LocationsTable :edit="isAdmin" />
<LocationsTable :edit="accountStore.canEditPublic" />
<h2>Schedule</h2>
<label>
Location Filter:
@ -77,7 +77,7 @@ definePageMeta({
const schedule = await useSchedule();
const { data: accounts } = await useAccounts();
const sessionStore = useSessionStore();
const accountStore = useAccountStore();
const route = useRoute();
const crewFilter = computed({
@ -91,14 +91,14 @@ const crewFilter = computed({
}),
});
const eventSlotFilter = computed(() => {
if (crewFilter.value === undefined || !sessionStore.account) {
if (crewFilter.value === undefined || !accountStore.valid) {
return () => true;
}
const cid = parseInt(crewFilter.value);
return (slot: TimeSlot) => slot.assigned?.some(id => id === cid) || false;
});
const shiftSlotFilter = computed(() => {
if (crewFilter.value === undefined || !sessionStore.account) {
if (crewFilter.value === undefined || !accountStore.valid) {
return () => true;
}
const cid = parseInt(crewFilter.value);
@ -126,6 +126,4 @@ const roleFilter = computed({
},
}),
});
const isAdmin = computed(() => sessionStore.account?.type === "admin")
</script>