client side state for activeMembership and fetch notes based on same

This commit is contained in:
Michael Dausmann
2023-02-13 23:51:52 +11:00
parent 90a1e4ef65
commit bb9f4dfd1d
8 changed files with 63 additions and 15 deletions

View File

@@ -1,12 +1,13 @@
import NotesService from '~~/lib/services/notes.service';
import { protectedProcedure, router } from '../trpc'
import { protectedProcedure, router } from '../trpc';
import { z } from 'zod';
export const notesRouter = router({
getForCurrentUser: protectedProcedure
.query(async ({ ctx }) => {
.input(z.object({ account_id: z.number() }))
.query(async ({ ctx, input }) => {
const notesService = new NotesService(ctx.prisma);
console.log(`fetching notes for account_id: ${ctx.dbUser.memberships[0].account_id}`);
const notes = await notesService.getNotesForAccountId(ctx.dbUser.memberships[0].account_id);
const notes = await notesService.getNotesForAccountId(input.account_id);
return {
notes,
}