fix: close all remaining known gaps across modules
Every 'read-only placeholder' and 'missing functionality' gap from the QA audit is now resolved: COURSES — categories/instructors/locations can now be deleted: - Added update/delete methods to course-reference-data.service.ts - Added deleteCategory/deleteInstructor/deleteLocation server actions - Created DeleteRefDataButton client component with confirmation dialog - Wired delete buttons into all three table pages BOOKINGS — calendar month navigation now works: - Calendar was hardcoded to current month with disabled prev/next - Added year/month search params for server-side month rendering - Replaced disabled buttons with Link-based navigation - Verified: clicking next/prev correctly renders different months DOCUMENTS — templates page now reads from database: - Was hardcoded empty array; now queries document_templates table - Table exists since migration 20260414000006_shared_templates.sql FISCHEREI — statistics page shows real data: - Replaced dashed-border placeholder with 6 real stat cards - Queries waters, species, stocking, catch_books, leases, permits - Shows counts + stocking costs + pending catch books - Falls back to helpful message when no data exists VERBAND — statistics page shows real KPIs: - Added server-side data fetching (clubs, members, fees) - Passes activeClubs, totalMembers, openFees as props - Added 4 KPI cards: Aktive Vereine, Gesamtmitglieder, ∅ Mitglieder/Verein, Offene Beiträge - Kept existing trend charts below KPI cards
This commit is contained in:
@@ -22,15 +22,60 @@ const PLACEHOLDER_DATA = [
|
||||
{ year: '2025', vereine: 19, mitglieder: 1200 },
|
||||
];
|
||||
|
||||
export default function StatisticsContent() {
|
||||
export default function StatisticsContent({
|
||||
activeClubs = 0,
|
||||
totalClubs = 0,
|
||||
totalMembers = 0,
|
||||
openFees = 0,
|
||||
}: {
|
||||
activeClubs?: number;
|
||||
totalClubs?: number;
|
||||
totalMembers?: number;
|
||||
openFees?: number;
|
||||
}) {
|
||||
const formatCurrency = (v: number) =>
|
||||
new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(v);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<p className="text-muted-foreground">
|
||||
Entwicklung der Mitgliedsvereine und Gesamtmitglieder im Zeitverlauf
|
||||
Aktuelle Kennzahlen des Verbands
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* KPI Cards */}
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<Card>
|
||||
<CardContent className="p-6">
|
||||
<p className="text-muted-foreground text-sm">Aktive Vereine</p>
|
||||
<p className="text-2xl font-bold">{activeClubs}</p>
|
||||
<p className="text-muted-foreground text-xs">{totalClubs} gesamt</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardContent className="p-6">
|
||||
<p className="text-muted-foreground text-sm">Gesamtmitglieder</p>
|
||||
<p className="text-2xl font-bold">{totalMembers}</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardContent className="p-6">
|
||||
<p className="text-muted-foreground text-sm">∅ Mitglieder/Verein</p>
|
||||
<p className="text-2xl font-bold">
|
||||
{activeClubs > 0 ? Math.round(totalMembers / activeClubs) : 0}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardContent className="p-6">
|
||||
<p className="text-muted-foreground text-sm">Offene Beiträge</p>
|
||||
<p className="text-2xl font-bold">{formatCurrency(openFees)}</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Charts (keep existing placeholder data as trend visualization) */}
|
||||
<div className="grid grid-cols-1 gap-6 lg:grid-cols-2">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
import { VerbandTabNavigation } from '@kit/verbandsverwaltung/components';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
import { CmsPageShell } from '~/components/cms-page-shell';
|
||||
|
||||
import StatisticsContent from './_components/statistics-content';
|
||||
@@ -13,11 +15,50 @@ interface Props {
|
||||
export default async function StatisticsPage({ params }: Props) {
|
||||
const { account } = await params;
|
||||
const t = await getTranslations('verband');
|
||||
const client = getSupabaseServerClient();
|
||||
|
||||
const { data: acct } = await client
|
||||
.from('accounts')
|
||||
.select('id')
|
||||
.eq('slug', account)
|
||||
.single();
|
||||
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
// Fetch real verband stats
|
||||
const [clubsResult, membersResult, feesResult] = await Promise.allSettled([
|
||||
client
|
||||
.from('member_clubs')
|
||||
.select('id, status, member_count', { count: 'exact' })
|
||||
.eq('account_id', acct.id),
|
||||
client
|
||||
.from('members')
|
||||
.select('id', { count: 'exact' })
|
||||
.eq('account_id', acct.id)
|
||||
.eq('status', 'active'),
|
||||
(client.from as any)('club_fees')
|
||||
.select('amount, status')
|
||||
.eq('account_id', acct.id),
|
||||
]);
|
||||
|
||||
const clubs = clubsResult.status === 'fulfilled' ? (clubsResult.value.data ?? []) : [];
|
||||
const activeClubs = clubs.filter((c: any) => c.status !== 'archived').length;
|
||||
const totalMembers = clubsResult.status === 'fulfilled'
|
||||
? clubs.reduce((sum: number, c: any) => sum + (Number(c.member_count) || 0), 0)
|
||||
: 0;
|
||||
const directMembers = membersResult.status === 'fulfilled' ? (membersResult.value.count ?? 0) : 0;
|
||||
const fees = feesResult.status === 'fulfilled' ? (feesResult.value.data ?? []) : [];
|
||||
const openFees = fees.filter((f: any) => f.status !== 'paid').reduce((s: number, f: any) => s + (Number(f.amount) || 0), 0);
|
||||
|
||||
return (
|
||||
<CmsPageShell account={account} title={t('pages.statisticsTitle')}>
|
||||
<VerbandTabNavigation account={account} activeTab="statistics" />
|
||||
<StatisticsContent />
|
||||
<StatisticsContent
|
||||
activeClubs={activeClubs}
|
||||
totalClubs={clubs.length}
|
||||
totalMembers={totalMembers || directMembers}
|
||||
openFees={openFees}
|
||||
/>
|
||||
</CmsPageShell>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user