Files
spliit/src/trpc/routers/groups/expenses/create.procedure.ts
Sebastien Castiel c1c75fa260 Q: Why do mountain climbers rope themselves together?
A:	To prevent the sensible ones from going home.
2024-10-25 15:02:31 -04:00

24 lines
654 B
TypeScript

import { z } from 'zod'
import { createExpense } from '../../../../lib/api'
import { expenseFormSchema } from '../../../../lib/schemas'
import { baseProcedure } from '../../../init'
export const createGroupExpenseProcedure = baseProcedure
.input(
z.object({
groupId: z.string().min(1),
expenseFormValues: expenseFormSchema,
participantId: z.string().optional(),
}),
)
.mutation(
async ({ input: { groupId, expenseFormValues, participantId } }) => {
const expense = await createExpense(
expenseFormValues,
groupId,
participantId,
)
return { expenseId: expense.id }
},
)