Use a pinia store to manage account state
Refactor the existing scattered code dealing with the account state into a pinia store.
This commit is contained in:
parent
fae8b4e2e4
commit
e722876aae
12 changed files with 126 additions and 98 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue