feat: complete CMS v2 with Docker, Fischerei, Meetings, Verband modules + UX audit fixes
Major changes: - Docker Compose: full Supabase stack (11 services) equivalent to supabase CLI - Fischerei module: 16 DB tables, waters/species/stocking/catch books/competitions - Sitzungsprotokolle module: meeting protocols, agenda items, task tracking - Verbandsverwaltung module: federation management, member clubs, contacts, fees - Per-account module activation via Modules page toggle - Site Builder: live CMS data in Puck blocks (courses, events, membership registration) - Public registration APIs: course signup, event registration, membership application - Document generation: PDF member cards, Excel reports, HTML labels - Landing page: real Com.BISS content (no filler text) - UX audit fixes: AccountNotFound component, shared status badges, confirm dialog, pagination, duplicate heading removal, emoji→badge replacement, a11y fixes - QA: healthcheck fix, API auth fix, enum mismatch fix, password required attribute
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
'use client';
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useTransition } from 'react';
|
||||
|
||||
import { Fish, FileSignature, Building2 } from 'lucide-react';
|
||||
import { toast } from '@kit/ui/sonner';
|
||||
|
||||
import { Switch } from '@kit/ui/switch';
|
||||
|
||||
import { toggleModuleAction } from '../_lib/server/toggle-module';
|
||||
|
||||
interface ModuleDefinition {
|
||||
key: string;
|
||||
label: string;
|
||||
description: string;
|
||||
icon: React.ReactNode;
|
||||
}
|
||||
|
||||
const AVAILABLE_MODULES: ModuleDefinition[] = [
|
||||
{
|
||||
key: 'fischerei',
|
||||
label: 'Fischerei',
|
||||
description:
|
||||
'Gewässer, Fischarten, Besatz, Fangbücher und Wettbewerbe verwalten',
|
||||
icon: <Fish className="h-5 w-5" />,
|
||||
},
|
||||
{
|
||||
key: 'meetings',
|
||||
label: 'Sitzungsprotokolle',
|
||||
description:
|
||||
'Sitzungsprotokolle, Tagesordnungspunkte und Beschlüsse verwalten',
|
||||
icon: <FileSignature className="h-5 w-5" />,
|
||||
},
|
||||
{
|
||||
key: 'verband',
|
||||
label: 'Verbandsverwaltung',
|
||||
description:
|
||||
'Mitgliedsvereine, Kontaktpersonen, Beiträge und Statistiken verwalten',
|
||||
icon: <Building2 className="h-5 w-5" />,
|
||||
},
|
||||
];
|
||||
|
||||
interface ModuleTogglesProps {
|
||||
accountId: string;
|
||||
features: Record<string, boolean>;
|
||||
}
|
||||
|
||||
export function ModuleToggles({ accountId, features }: ModuleTogglesProps) {
|
||||
const router = useRouter();
|
||||
const [isPending, startTransition] = useTransition();
|
||||
|
||||
const handleToggle = (moduleKey: string, enabled: boolean) => {
|
||||
startTransition(async () => {
|
||||
const result = await toggleModuleAction(accountId, moduleKey, enabled);
|
||||
|
||||
if (result.success) {
|
||||
toast.success(
|
||||
enabled ? 'Modul aktiviert' : 'Modul deaktiviert',
|
||||
);
|
||||
|
||||
router.refresh();
|
||||
} else {
|
||||
toast.error('Fehler beim Aktualisieren des Moduls');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<div>
|
||||
<h2 className="text-xl font-semibold">Verfügbare Module</h2>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
Aktivieren oder deaktivieren Sie Module für Ihren Verein
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="divide-y rounded-lg border">
|
||||
{AVAILABLE_MODULES.map((mod) => {
|
||||
const isEnabled = features[mod.key] === true;
|
||||
|
||||
return (
|
||||
<div
|
||||
key={mod.key}
|
||||
className="flex items-center justify-between gap-4 p-4"
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="text-muted-foreground">{mod.icon}</div>
|
||||
<div>
|
||||
<p className="font-medium">{mod.label}</p>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{mod.description}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Switch
|
||||
checked={isEnabled}
|
||||
onCheckedChange={(checked) =>
|
||||
handleToggle(mod.key, Boolean(checked))
|
||||
}
|
||||
disabled={isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
'use server';
|
||||
|
||||
import { revalidatePath } from 'next/cache';
|
||||
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
export async function toggleModuleAction(
|
||||
accountId: string,
|
||||
moduleKey: string,
|
||||
enabled: boolean,
|
||||
) {
|
||||
const client = getSupabaseServerClient();
|
||||
|
||||
// Read current features
|
||||
const { data: settings } = await client
|
||||
.from('account_settings')
|
||||
.select('features')
|
||||
.eq('account_id', accountId)
|
||||
.maybeSingle();
|
||||
|
||||
const currentFeatures =
|
||||
(settings?.features as Record<string, boolean>) ?? {};
|
||||
const newFeatures = { ...currentFeatures, [moduleKey]: enabled };
|
||||
|
||||
// Upsert
|
||||
const { error } = await client.from('account_settings').upsert(
|
||||
{
|
||||
account_id: accountId,
|
||||
features: newFeatures,
|
||||
},
|
||||
{ onConflict: 'account_id' },
|
||||
);
|
||||
|
||||
if (error) {
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
|
||||
revalidatePath(`/home`, 'layout');
|
||||
return { success: true };
|
||||
}
|
||||
@@ -1,7 +1,14 @@
|
||||
import Link from 'next/link';
|
||||
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { createModuleBuilderApi } from '@kit/module-builder/api';
|
||||
|
||||
import { CmsPageShell } from '~/components/cms-page-shell';
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
|
||||
import { ModuleToggles } from './_components/module-toggles';
|
||||
|
||||
interface ModulesPageProps {
|
||||
params: Promise<{ account: string }>;
|
||||
}
|
||||
@@ -19,48 +26,59 @@ export default async function ModulesPage({ params }: ModulesPageProps) {
|
||||
.single();
|
||||
|
||||
if (!accountData) {
|
||||
return <div>Account not found</div>;
|
||||
return <AccountNotFound />;
|
||||
}
|
||||
|
||||
// Load account features
|
||||
const { data: settings } = await client
|
||||
.from('account_settings')
|
||||
.select('features')
|
||||
.eq('account_id', accountData.id)
|
||||
.maybeSingle();
|
||||
|
||||
const features = (settings?.features as Record<string, boolean>) ?? {};
|
||||
|
||||
const modules = await api.modules.listModules(accountData.id);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold">Module</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Verwalten Sie Ihre Datenmodule
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<CmsPageShell
|
||||
account={account}
|
||||
title="Module"
|
||||
description="Verwalten Sie Ihre Datenmodule"
|
||||
>
|
||||
<div className="flex flex-col gap-8">
|
||||
<ModuleToggles accountId={accountData.id} features={features} />
|
||||
|
||||
{modules.length === 0 ? (
|
||||
<div className="flex flex-col items-center justify-center py-12 text-center">
|
||||
<p className="text-muted-foreground">
|
||||
Noch keine Module vorhanden. Erstellen Sie Ihr erstes Modul.
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||
{modules.map((module: Record<string, unknown>) => (
|
||||
<div
|
||||
key={module.id as string}
|
||||
className="rounded-lg border p-4 hover:bg-accent/50 transition-colors"
|
||||
>
|
||||
<h3 className="font-semibold">{String(module.display_name)}</h3>
|
||||
{module.description ? (
|
||||
<p className="text-sm text-muted-foreground mt-1">
|
||||
{String(module.description)}
|
||||
</p>
|
||||
) : null}
|
||||
<div className="mt-2 text-xs text-muted-foreground">
|
||||
Status: {String(module.status)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{modules.length === 0 ? (
|
||||
<div className="flex flex-col items-center justify-center py-12 text-center">
|
||||
<p className="text-muted-foreground">
|
||||
Noch keine Module vorhanden. Erstellen Sie Ihr erstes Modul.
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||
{modules.map((module: Record<string, unknown>) => (
|
||||
<Link
|
||||
key={module.id as string}
|
||||
href={`/home/${account}/modules/${module.id as string}`}
|
||||
className="block rounded-lg border p-4 hover:bg-accent/50 transition-colors"
|
||||
>
|
||||
<h3 className="font-semibold">
|
||||
{String(module.display_name)}
|
||||
</h3>
|
||||
{module.description ? (
|
||||
<p className="text-sm text-muted-foreground mt-1">
|
||||
{String(module.description)}
|
||||
</p>
|
||||
) : null}
|
||||
<div className="mt-2 text-xs text-muted-foreground">
|
||||
Status: {String(module.status)}
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CmsPageShell>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user