mirror of
https://github.com/spliit-app/spliit.git
synced 2026-03-03 19:46:13 +01:00
* Add basic activity log * Add database migration * Fix layout * Fix types --------- Co-authored-by: Sebastien Castiel <sebastien@castiel.me>
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { cached } from '@/app/cached-functions'
|
|
import { GroupForm } from '@/components/group-form'
|
|
import { getGroupExpensesParticipants, updateGroup } from '@/lib/api'
|
|
import { groupFormSchema } from '@/lib/schemas'
|
|
import { Metadata } from 'next'
|
|
import { notFound, redirect } from 'next/navigation'
|
|
|
|
export const metadata: Metadata = {
|
|
title: 'Settings',
|
|
}
|
|
|
|
export default async function EditGroupPage({
|
|
params: { groupId },
|
|
}: {
|
|
params: { groupId: string }
|
|
}) {
|
|
const group = await cached.getGroup(groupId)
|
|
if (!group) notFound()
|
|
|
|
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}`)
|
|
}
|
|
|
|
const protectedParticipantIds = await getGroupExpensesParticipants(groupId)
|
|
return (
|
|
<GroupForm
|
|
group={group}
|
|
onSubmit={updateGroupAction}
|
|
protectedParticipantIds={protectedParticipantIds}
|
|
/>
|
|
)
|
|
}
|