Prevent removing participants with expenses

This commit is contained in:
Sebastien Castiel
2023-12-07 20:12:40 -05:00
parent fb6cff2fe3
commit 6f077f141e
6 changed files with 129 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
import { GroupForm } from '@/components/group-form'
import { getGroup, updateGroup } from '@/lib/api'
import { getGroup, getGroupExpensesParticipants, updateGroup } from '@/lib/api'
import { groupFormSchema } from '@/lib/schemas'
import { Metadata } from 'next'
import { notFound, redirect } from 'next/navigation'
@@ -23,5 +23,12 @@ export default async function EditGroupPage({
redirect(`/groups/${group.id}`)
}
return <GroupForm group={group} onSubmit={updateGroupAction} />
const protectedParticipantIds = await getGroupExpensesParticipants(groupId)
return (
<GroupForm
group={group}
onSubmit={updateGroupAction}
protectedParticipantIds={protectedParticipantIds}
/>
)
}