mirror of
https://github.com/spliit-app/spliit.git
synced 2026-03-08 05:09:05 +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
30
src/app/groups/[groupId]/edit/edit-group.tsx
Normal file
30
src/app/groups/[groupId]/edit/edit-group.tsx
Normal 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}
|
||||
/>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user