refactor and restructure pinia store and trpc routers + add members list to account store

This commit is contained in:
Michael Dausmann
2023-04-05 00:28:30 +10:00
parent 10b0d6da3d
commit f2bbe8596a
12 changed files with 214 additions and 119 deletions

View File

@@ -5,19 +5,21 @@
middleware: ['auth'],
});
const store = useAppStore();
const { notes } = storeToRefs(store); // ensure the notes list is reactive
const authStore = useAuthStore();
const { activeMembership } = storeToRefs(authStore);
const notesStore = useNotesStore();
const { notes } = storeToRefs(notesStore); // ensure the notes list is reactive
watchEffect(async () => {
if (activeMembership.value) {
await notesStore.fetchNotesForCurrentUser();
}
})
</script>
<template>
<div>
<h3>Notes Dashboard</h3>
<p v-for="note in notes">{{ note.note_text }}</p>
<button @click.prevent="store.changeAccountPlan(2)">Change active Account Plan to 2</button>
<button @click.prevent="store.joinUserToAccount(4)">Join user 4 to active account</button>
<button @click.prevent="store.changeUserAccessWithinAccount(4, 'OWNER')">Change user 4 access within account 5 to OWNER (SHOULD FAIL)</button>
<button @click.prevent="store.changeUserAccessWithinAccount(4, 'ADMIN')">Change user 4 access within account 5 to ADMIN</button>
<button @click.prevent="store.claimOwnershipOfAccount()">Claim Ownership of current account for current user</button>
</div>
</template>