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
|
@ -38,7 +38,7 @@
|
|||
<td>
|
||||
<input
|
||||
type="checkbox"
|
||||
:disabled="!canEditPublic"
|
||||
:disabled="!accountStore.canEditPublic"
|
||||
:value="!event.crew"
|
||||
:checked="!event.crew"
|
||||
@change="editEvent(event, { crew: !($event as any).target.value })"
|
||||
|
@ -75,7 +75,7 @@
|
|||
<td>
|
||||
<input
|
||||
type="checkbox"
|
||||
:disabled="!canEditPublic"
|
||||
:disabled="!accountStore.canEditPublic"
|
||||
v-model="newEventPublic"
|
||||
>
|
||||
</td>
|
||||
|
@ -135,11 +135,10 @@ defineProps<{
|
|||
}>();
|
||||
|
||||
const schedule = await useSchedule();
|
||||
const sessionStore = useSessionStore();
|
||||
const canEditPublic = computed(() => sessionStore.account?.type === "admin");
|
||||
const accountStore = useAccountStore();
|
||||
|
||||
function canEdit(event: ScheduleEvent) {
|
||||
return event.crew || canEditPublic.value;
|
||||
return event.crew || accountStore.canEditPublic;
|
||||
}
|
||||
|
||||
const changes = ref<ChangeRecord<ScheduleEvent>[]>([]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue