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
|
@ -8,18 +8,18 @@
|
|||
<li>
|
||||
<NuxtLink to="/schedule">Schedule</NuxtLink>
|
||||
</li>
|
||||
<li v-if="sessionStore.account?.type === 'admin' || sessionStore.account?.type === 'crew'">
|
||||
<li v-if="accountStore.canEdit">
|
||||
<NuxtLink to="/edit">Edit</NuxtLink>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="account">
|
||||
<template v-if="sessionStore.account">
|
||||
{{ sessionStore.account.name }}
|
||||
(s:{{ sessionStore.id }} a:{{ sessionStore.account.id }}{{ sessionStore.push ? " push" : null }})
|
||||
{{ sessionStore.account.type }}
|
||||
<template v-if="accountStore.valid">
|
||||
{{ accountStore.name }}
|
||||
(s:{{ sessionStore.id }} a:{{ accountStore.id }}{{ sessionStore.push ? " push" : null }})
|
||||
{{ accountStore.type }}
|
||||
<NuxtLink to="/account/settings">Settings</NuxtLink>
|
||||
<LogOutButton v-if="sessionStore.account.type !== 'anonymous'"/>
|
||||
<LogOutButton v-if="accountStore.type !== 'anonymous'"/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<NuxtLink to="/login">Log In</NuxtLink>
|
||||
|
@ -29,6 +29,7 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
const accountStore = useAccountStore();
|
||||
const sessionStore = useSessionStore();
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue