43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { notFound, redirect } from 'next/navigation';
|
|
import { api_anlage_getSelected } from '@/actions/rk/api-anlage';
|
|
import { api_groups, api_groups_byId } from '@/actions/rk2/api-groups';
|
|
import Breadcrumbs from '@/components/ui/navigation/breadcrumbs';
|
|
import { GroupEdit } from '@/components/rk2/groups/groupEdit';
|
|
|
|
export default async function GroupEditPage({
|
|
params,
|
|
}: {
|
|
params: Promise<{ id: string }>;
|
|
}) {
|
|
const { id } = await params;
|
|
const anlage = await api_anlage_getSelected();
|
|
if (!anlage?.id) {
|
|
redirect('/projekte');
|
|
}
|
|
|
|
const groups = await api_groups();
|
|
let group;
|
|
if (id !== 'new') {
|
|
const result = await api_groups_byId(id);
|
|
if (!result.success || !result.data) {
|
|
notFound();
|
|
}
|
|
group = result.data;
|
|
}
|
|
|
|
const breadcrumb = [
|
|
{ label: 'Anlage', href: '/' },
|
|
{ label: 'Gruppen', href: '/groups' },
|
|
{ label: group?.name ?? 'Neue Gruppe' },
|
|
];
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
<Breadcrumbs items={breadcrumb} />
|
|
<div className="max-w-3xl">
|
|
<GroupEdit anlage={anlage} selectedGroup={group} groups={groups} />
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|