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
94 lines
3.2 KiB
TypeScript
94 lines
3.2 KiB
TypeScript
import { Users } from 'lucide-react';
|
|
import { getTranslations } from 'next-intl/server';
|
|
|
|
import { createMemberManagementApi } from '@kit/member-management/api';
|
|
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
|
|
|
import { AccountNotFound } from '~/components/account-not-found';
|
|
import { CmsPageShell } from '~/components/cms-page-shell';
|
|
import { EmptyState } from '~/components/empty-state';
|
|
|
|
import { CreateDepartmentDialog } from './create-department-dialog';
|
|
import { DeleteDepartmentButton } from './delete-department-button';
|
|
|
|
interface Props {
|
|
params: Promise<{ account: string }>;
|
|
}
|
|
|
|
export default async function DepartmentsPage({ params }: Props) {
|
|
const { account } = await params;
|
|
const client = getSupabaseServerClient();
|
|
const t = await getTranslations('members');
|
|
const { data: acct } = await client
|
|
.from('accounts')
|
|
.select('id')
|
|
.eq('slug', account)
|
|
.single();
|
|
if (!acct) return <AccountNotFound />;
|
|
|
|
const api = createMemberManagementApi(client);
|
|
const departments = await api.listDepartments(acct.id);
|
|
|
|
return (
|
|
<CmsPageShell
|
|
account={account}
|
|
title={t('departments.title')}
|
|
description={t('departments.subtitle')}
|
|
>
|
|
<div className="space-y-4">
|
|
<div className="flex items-center justify-end">
|
|
<CreateDepartmentDialog accountId={acct.id} />
|
|
</div>
|
|
|
|
{departments.length === 0 ? (
|
|
<EmptyState
|
|
icon={<Users className="h-8 w-8" />}
|
|
title={t('departments.noDepartments')}
|
|
description={t('departments.createFirst')}
|
|
/>
|
|
) : (
|
|
<div className="overflow-x-auto rounded-md border">
|
|
<table className="w-full min-w-[640px] text-sm">
|
|
<thead>
|
|
<tr className="bg-muted/50 border-b">
|
|
<th scope="col" className="p-3 text-left font-medium">
|
|
{t('departments.name')}
|
|
</th>
|
|
<th scope="col" className="p-3 text-left font-medium">
|
|
{t('departments.description')}
|
|
</th>
|
|
<th scope="col" className="p-3 text-left font-medium">
|
|
{t('departments.actions')}
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{departments.map((dept: Record<string, unknown>) => (
|
|
<tr
|
|
key={String(dept.id)}
|
|
className="hover:bg-muted/30 border-b"
|
|
>
|
|
<td className="p-3 font-medium">{String(dept.name)}</td>
|
|
<td className="text-muted-foreground p-3">
|
|
{String(dept.description ?? '—')}
|
|
</td>
|
|
<td className="p-3">
|
|
<div className="flex items-center gap-2">
|
|
<DeleteDepartmentButton
|
|
departmentId={String(dept.id)}
|
|
departmentName={String(dept.name)}
|
|
accountId={acct.id}
|
|
/>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</CmsPageShell>
|
|
);
|
|
}
|