// composables/states.ts
import { Membership, Note } from ".prisma/client"
export type AppState = {
activeMembership?: Membership
notes: Note[]
}
export const appState = () => useState<AppState>('appState', () => ({
notes: []
}));
// pages/dashboard.vue
const theAppState = appState();
watch(theAppState.value, (newAppState) => {
if(newAppState.activeMembership){
const { data: foundNotes } = $client.notes.getForCurrentUser.useQuery({account_id: newAppState.activeMembership.account_id});
if(foundNotes.value?.notes){
theAppState.value.notes = foundNotes.value.notes;
}
}
});
// composables/states.ts
import { Membership, Note } from ".prisma/client"
export type AppState = {
activeMembership?: Membership
notes: Note[]
}
export const appState = () => useState<AppState>('appState', () => ({
notes: []
}));
// pages/dashboard.vue
const theAppState = appState();
watch(theAppState.value, (newAppState) => {
if(newAppState.activeMembership){
const { data: foundNotes } = $client.notes.getForCurrentUser.useQuery({account_id: newAppState.activeMembership.account_id});
if(foundNotes.value?.notes){
theAppState.value.notes = foundNotes.value.notes;
}
}
});