Files
myeasycms-v2/apps/web/app/[locale]/home/[account]/fischerei/leases/page.tsx
Zaid Marzguioui b26e5aaafa
Some checks failed
Workflow / ʦ TypeScript (push) Failing after 6m20s
Workflow / ⚫️ Test (push) Has been skipped
feat: pre-existing local changes — fischerei, verband, modules, members, packages
Commits all remaining uncommitted local work:

- apps/web: fischerei, verband, modules, members-cms, documents,
  newsletter, meetings, site-builder, courses, bookings, events,
  finance pages and components
- apps/web: marketing page updates, layout, paths config,
  next.config.mjs, styles/makerkit.css
- apps/web/i18n: documents, fischerei, marketing, verband (de+en)
- packages/features: finance, fischerei, member-management,
  module-builder, newsletter, sitzungsprotokolle, verbandsverwaltung
  server APIs and components
- packages/ui: button.tsx updates
- pnpm-lock.yaml
2026-04-02 01:19:54 +02:00

103 lines
3.0 KiB
TypeScript

import Link from 'next/link';
import { Plus } from 'lucide-react';
import { getTranslations } from 'next-intl/server';
import { createFischereiApi } from '@kit/fischerei/api';
import {
FischereiTabNavigation,
LeasesDataTable,
} from '@kit/fischerei/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Button } from '@kit/ui/button';
import { ListToolbar } from '@kit/ui/list-toolbar';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}
export default async function LeasesPage({ params, searchParams }: Props) {
const { account } = await params;
const search = await searchParams;
const client = getSupabaseServerClient();
const t = await getTranslations('fischerei');
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
const api = createFischereiApi(client);
const page = Number(search.page) || 1;
const waterId = (search.waterId as string) || undefined;
const activeParam = search.active as string | undefined;
const active =
activeParam === 'true' ? true : activeParam === 'false' ? false : undefined;
const [result, watersResult] = await Promise.all([
api.listLeases(acct.id, {
waterId,
active,
page,
pageSize: 25,
}),
api.listWaters(acct.id, { pageSize: 200 }),
]);
const waterOptions = [
{ value: '', label: 'Alle Gewässer' },
...watersResult.data.map((w) => ({
value: String(w.id),
label: String(w.name),
})),
];
return (
<CmsPageShell account={account} title={t('pages.leasesTitle')}>
<FischereiTabNavigation account={account} activeTab="leases" />
<div className="flex w-full flex-col gap-6">
<div className="flex items-center justify-between">
<div>
<p className="text-muted-foreground">
Gewässerpachtverträge verwalten
</p>
</div>
<Button size="sm" data-test="leases-new-btn" asChild>
<Link href={`/home/${account}/fischerei/leases/new`}>
<Plus className="mr-2 h-4 w-4" />
Neue Pacht
</Link>
</Button>
</div>
<ListToolbar
showSearch={false}
filters={[
{ param: 'waterId', label: 'Gewässer', options: waterOptions },
{
param: 'active',
label: 'Status',
options: [
{ value: '', label: 'Alle' },
{ value: 'true', label: 'Aktiv' },
{ value: 'false', label: 'Archiviert' },
],
},
]}
/>
<LeasesDataTable
data={result.data}
total={result.total}
accountId={acct.id}
/>
</div>
</CmsPageShell>
);
}