mirror of
https://github.com/spliit-app/spliit.git
synced 2026-03-05 12:16:13 +01:00
Use tRPC in other group pages (#249)
* Use tRPC in group edition + group layout * Use tRPC in group modals * Use tRPC in group stats * Use tRPC in group activity
This commit is contained in:
committed by
GitHub
parent
66e15e419e
commit
210c12b7ef
19
src/trpc/routers/groups/get.procedure.ts
Normal file
19
src/trpc/routers/groups/get.procedure.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { getGroup, getGroupExpensesParticipants } from '@/lib/api'
|
||||
import { baseProcedure } from '@/trpc/init'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
|
||||
export const getGroupProcedure = baseProcedure
|
||||
.input(z.object({ groupId: z.string().min(1) }))
|
||||
.query(async ({ input: { groupId } }) => {
|
||||
const group = await getGroup(groupId)
|
||||
if (!group) {
|
||||
throw new TRPCError({
|
||||
code: 'NOT_FOUND',
|
||||
message: 'Group not found.',
|
||||
})
|
||||
}
|
||||
|
||||
const participantsWithExpenses = await getGroupExpensesParticipants(groupId)
|
||||
return { group, participantsWithExpenses }
|
||||
})
|
||||
Reference in New Issue
Block a user