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

29
stores/notes.store.ts Normal file
View File

@@ -0,0 +1,29 @@
import { Note } from ".prisma/client"
import { defineStore } from "pinia"
import { useAuthStore } from './auth.store'
interface State {
notes: Note[]
}
export const useNotesStore = defineStore('notes', {
state: (): State => {
return {
notes: [],
}
},
actions: {
async fetchNotesForCurrentUser() {
const authStore = useAuthStore();
if(!authStore.activeMembership) { return; }
const { $client } = useNuxtApp();
const { notes } = await $client.notes.getForCurrentUser.query({account_id: authStore.activeMembership.account_id});
if(notes){
this.notes = notes;
}
},
}
});