mirror of
https://github.com/spliit-app/spliit.git
synced 2026-03-07 20:59:05 +01:00
* Use tRPC for recent groups page * Use tRPC for adding group by URL * Use tRPC for saving visited group * Group context
26 lines
742 B
TypeScript
26 lines
742 B
TypeScript
'use client'
|
|
|
|
import { GroupForm } from '@/components/group-form'
|
|
import { trpc } from '@/trpc/client'
|
|
import { useCurrentGroup } from '../current-group-context'
|
|
|
|
export const EditGroup = () => {
|
|
const { groupId } = useCurrentGroup()
|
|
const { data, isLoading } = trpc.groups.getDetails.useQuery({ groupId })
|
|
const { mutateAsync } = trpc.groups.update.useMutation()
|
|
const utils = trpc.useUtils()
|
|
|
|
if (isLoading) return <></>
|
|
|
|
return (
|
|
<GroupForm
|
|
group={data?.group}
|
|
onSubmit={async (groupFormValues, participantId) => {
|
|
await mutateAsync({ groupId, participantId, groupFormValues })
|
|
await utils.groups.invalidate()
|
|
}}
|
|
protectedParticipantIds={data?.participantsWithExpenses}
|
|
/>
|
|
)
|
|
}
|