Refactor user storage and update

Rename accounts to users to be consistent with the new naming scheme
where account only referes to the logged in user of the session and
implement live updates of users via a user store which listens for
updates from the event stream.
This commit is contained in:
Hornwitser 2025-06-23 00:17:22 +02:00
parent 6336ccdb96
commit 3be7f8be05
24 changed files with 331 additions and 182 deletions

View file

@ -11,11 +11,11 @@
:selected="crewFilter === undefined"
>&lt;All Crew&gt;</option>
<option
v-for="account in accounts?.filter(a => a.type === 'crew' || a.type === 'admin')"
:key="account.id"
:value="String(account.id)"
:selected="crewFilter === String(account.id)"
>{{ account.name }}</option>
v-for="user in [...usersStore.users.values()].filter(a => a.type === 'crew' || a.type === 'admin')"
:key="user.id"
:value="String(user.id)"
:selected="crewFilter === String(user.id)"
>{{ user.name }}</option>
</select>
</label>
<Timetable :schedule :eventSlotFilter :shiftSlotFilter />
@ -104,7 +104,8 @@ const tabs = [
];
const schedule = await useSchedule();
const { data: accounts } = await useAccounts();
const usersStore = useUsersStore();
await usersStore.fetch();
const accountStore = useAccountStore();
const route = useRoute();

View file

@ -30,13 +30,13 @@
value="assigned"
:selected='filter === "assigned"'
>Assigned to Me</option>
<optgroup v-if="accountStore.isCrew && accounts" label="Crew">
<optgroup v-if="accountStore.isCrew" label="Crew">
<option
v-for="account in accounts.filter(a => a.type === 'crew' || a.type === 'admin')"
:key="account.id"
:value="`crew-${account.id}`"
:selected="filter === `crew-${account.id}`"
>{{ account.name }}</option>
v-for="user in [...usersStore.users.values()].filter(a => a.type === 'crew' || a.type === 'admin')"
:key="user.id"
:value="`crew-${user.id}`"
:selected="filter === `crew-${user.id}`"
>{{ user.name }}</option>
</optgroup>
</select>
</label>
@ -55,7 +55,8 @@
<script setup lang="ts">
const accountStore = useAccountStore();
const { data: accounts } = await useAccounts();
const usersStore = useUsersStore();
await usersStore.fetch();
const schedule = await useSchedule();
const route = useRoute();