feat: add update and delete functionality for courses, events, and species; enhance attendance tracking and category creation
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import { createEventManagementApi } from '@kit/event-management/api';
|
||||
import { CreateEventForm } from '@kit/event-management/components';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
import { CmsPageShell } from '~/components/cms-page-shell';
|
||||
|
||||
interface PageProps {
|
||||
params: Promise<{ account: string; eventId: string }>;
|
||||
}
|
||||
|
||||
export default async function EditEventPage({ params }: PageProps) {
|
||||
const { account, eventId } = await params;
|
||||
const client = getSupabaseServerClient();
|
||||
|
||||
const { data: acct } = await client
|
||||
.from('accounts')
|
||||
.select('id')
|
||||
.eq('slug', account)
|
||||
.single();
|
||||
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createEventManagementApi(client);
|
||||
const event = await api.getEvent(eventId);
|
||||
if (!event) return <AccountNotFound />;
|
||||
|
||||
const e = event as Record<string, unknown>;
|
||||
|
||||
return (
|
||||
<CmsPageShell account={account} title={`${String(e.name)} — Bearbeiten`}>
|
||||
<CreateEventForm
|
||||
accountId={acct.id}
|
||||
account={account}
|
||||
eventId={eventId}
|
||||
initialData={{
|
||||
name: String(e.name ?? ''),
|
||||
description: String(e.description ?? ''),
|
||||
eventDate: String(e.event_date ?? ''),
|
||||
eventTime: String(e.event_time ?? ''),
|
||||
endDate: String(e.end_date ?? ''),
|
||||
location: String(e.location ?? ''),
|
||||
capacity: e.capacity != null ? Number(e.capacity) : undefined,
|
||||
minAge: e.min_age != null ? Number(e.min_age) : undefined,
|
||||
maxAge: e.max_age != null ? Number(e.max_age) : undefined,
|
||||
fee: Number(e.fee ?? 0),
|
||||
status: String(e.status ?? 'planned'),
|
||||
registrationDeadline: String(e.registration_deadline ?? ''),
|
||||
contactName: String(e.contact_name ?? ''),
|
||||
contactEmail: String(e.contact_email ?? ''),
|
||||
contactPhone: String(e.contact_phone ?? ''),
|
||||
}}
|
||||
/>
|
||||
</CmsPageShell>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user