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,49 @@
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import { createFischereiApi } from '@kit/fischerei/api';
|
||||
import {
|
||||
FischereiTabNavigation,
|
||||
CreateSpeciesForm,
|
||||
} from '@kit/fischerei/components';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
import { CmsPageShell } from '~/components/cms-page-shell';
|
||||
|
||||
interface Props {
|
||||
params: Promise<{ account: string; speciesId: string }>;
|
||||
}
|
||||
|
||||
export default async function EditSpeciesPage({ params }: Props) {
|
||||
const { account, speciesId } = await params;
|
||||
const client = getSupabaseServerClient();
|
||||
|
||||
const { data: acct } = await client
|
||||
.from('accounts')
|
||||
.select('id')
|
||||
.eq('slug', account)
|
||||
.single();
|
||||
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createFischereiApi(client);
|
||||
|
||||
let species;
|
||||
|
||||
try {
|
||||
species = await api.getSpecies(speciesId);
|
||||
} catch {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<CmsPageShell account={account} title="Fischart bearbeiten">
|
||||
<FischereiTabNavigation account={account} activeTab="species" />
|
||||
<CreateSpeciesForm
|
||||
accountId={acct.id}
|
||||
account={account}
|
||||
species={species}
|
||||
/>
|
||||
</CmsPageShell>
|
||||
);
|
||||
}
|
||||
@@ -63,6 +63,7 @@ export default async function SpeciesPage({ params, searchParams }: Props) {
|
||||
page={page}
|
||||
pageSize={50}
|
||||
account={account}
|
||||
accountId={acct.id}
|
||||
/>
|
||||
</CmsPageShell>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import { createFischereiApi } from '@kit/fischerei/api';
|
||||
import {
|
||||
FischereiTabNavigation,
|
||||
CreateStockingForm,
|
||||
} from '@kit/fischerei/components';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
import { CmsPageShell } from '~/components/cms-page-shell';
|
||||
|
||||
interface Props {
|
||||
params: Promise<{ account: string; stockingId: string }>;
|
||||
}
|
||||
|
||||
export default async function EditStockingPage({ params }: Props) {
|
||||
const { account, stockingId } = await params;
|
||||
const client = getSupabaseServerClient();
|
||||
|
||||
const { data: acct } = await client
|
||||
.from('accounts')
|
||||
.select('id')
|
||||
.eq('slug', account)
|
||||
.single();
|
||||
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createFischereiApi(client);
|
||||
|
||||
let stocking;
|
||||
|
||||
try {
|
||||
stocking = await api.getStocking(stockingId);
|
||||
} catch {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// Load waters and species lists for form dropdowns
|
||||
const [watersResult, speciesResult] = await Promise.all([
|
||||
api.listWaters(acct.id, { pageSize: 200 }),
|
||||
api.listSpecies(acct.id, { pageSize: 200 }),
|
||||
]);
|
||||
|
||||
const waters = watersResult.data.map((w: Record<string, unknown>) => ({
|
||||
id: String(w.id),
|
||||
name: String(w.name),
|
||||
}));
|
||||
|
||||
const speciesList = speciesResult.data.map((s: Record<string, unknown>) => ({
|
||||
id: String(s.id),
|
||||
name: String(s.name),
|
||||
}));
|
||||
|
||||
return (
|
||||
<CmsPageShell account={account} title="Besatz bearbeiten">
|
||||
<FischereiTabNavigation account={account} activeTab="stocking" />
|
||||
<CreateStockingForm
|
||||
accountId={acct.id}
|
||||
account={account}
|
||||
waters={waters}
|
||||
species={speciesList}
|
||||
stocking={stocking}
|
||||
/>
|
||||
</CmsPageShell>
|
||||
);
|
||||
}
|
||||
@@ -87,6 +87,7 @@ export default async function StockingPage({ params, searchParams }: Props) {
|
||||
page={page}
|
||||
pageSize={25}
|
||||
account={account}
|
||||
accountId={acct.id}
|
||||
/>
|
||||
</CmsPageShell>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import { createFischereiApi } from '@kit/fischerei/api';
|
||||
import {
|
||||
FischereiTabNavigation,
|
||||
CreateWaterForm,
|
||||
} from '@kit/fischerei/components';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
import { CmsPageShell } from '~/components/cms-page-shell';
|
||||
|
||||
interface Props {
|
||||
params: Promise<{ account: string; waterId: string }>;
|
||||
}
|
||||
|
||||
export default async function EditWaterPage({ params }: Props) {
|
||||
const { account, waterId } = await params;
|
||||
const client = getSupabaseServerClient();
|
||||
|
||||
const { data: acct } = await client
|
||||
.from('accounts')
|
||||
.select('id')
|
||||
.eq('slug', account)
|
||||
.single();
|
||||
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createFischereiApi(client);
|
||||
|
||||
let water;
|
||||
|
||||
try {
|
||||
water = await api.getWater(waterId);
|
||||
} catch {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<CmsPageShell account={account} title="Gewässer bearbeiten">
|
||||
<FischereiTabNavigation account={account} activeTab="waters" />
|
||||
<CreateWaterForm accountId={acct.id} account={account} water={water} />
|
||||
</CmsPageShell>
|
||||
);
|
||||
}
|
||||
@@ -44,6 +44,7 @@ export default async function WatersPage({ params, searchParams }: Props) {
|
||||
page={page}
|
||||
pageSize={25}
|
||||
account={account}
|
||||
accountId={acct.id}
|
||||
/>
|
||||
</CmsPageShell>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user