add/delete notes

This commit is contained in:
Michael Dausmann
2023-04-14 00:24:22 +10:00
parent 6a7e7ec9ac
commit 8b2348f6a3
5 changed files with 55 additions and 6 deletions

View File

@@ -11,7 +11,7 @@ export const notesRouter = router({
notes,
}
}),
getById: publicProcedure
getById: publicProcedure
.input(z.object({ note_id: z.number() }))
.query(async ({ ctx, input }) => {
const notesService = new NotesService();
@@ -20,4 +20,22 @@ export const notesRouter = router({
note,
}
}),
createNote: protectedProcedure
.input(z.object({ note_text: z.string() }))
.mutation(async ({ ctx, input }) => {
const notesService = new NotesService();
const note = (ctx.activeAccountId)?await notesService.createNote(ctx.activeAccountId, input.note_text):null;
return {
note,
}
}),
deleteNote: protectedProcedure
.input(z.object({ note_id: z.number() }))
.mutation(async ({ ctx, input }) => {
const notesService = new NotesService();
const note = (ctx.activeAccountId)?await notesService.deleteNote(input.note_id):null;
return {
note,
}
}),
})