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:
Sebastien Castiel
2024-10-19 21:29:53 -04:00
committed by GitHub
parent 66e15e419e
commit 210c12b7ef
35 changed files with 709 additions and 498 deletions

View File

@@ -0,0 +1,30 @@
'use client'
import { GroupForm } from '@/components/group-form'
import { trpc } from '@/trpc/client'
export const EditGroup = ({ groupId }: { groupId: string }) => {
const { data, isLoading } = trpc.groups.get.useQuery({ groupId })
const { mutateAsync, isPending } = trpc.groups.update.useMutation()
const utils = trpc.useUtils()
// async function updateGroupAction(values: unknown, participantId?: string) {
// 'use server'
// const groupFormValues = groupFormSchema.parse(values)
// const group = await updateGroup(groupId, groupFormValues, participantId)
// redirect(`/groups/${group.id}`)
// }
if (isLoading) return <></>
return (
<GroupForm
group={data?.group}
onSubmit={async (groupFormValues, participantId) => {
await mutateAsync({ groupId, participantId, groupFormValues })
await utils.groups.invalidate()
}}
protectedParticipantIds={data?.participantsWithExpenses}
/>
)
}