mirror of
https://github.com/spliit-app/spliit.git
synced 2026-02-26 09:26:12 +01:00
24 lines
654 B
TypeScript
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 }
|
|
},
|
|
)
|