- fix(member-detail): display gender in German (Männlich/Weiblich/Divers) instead of raw English enum values (male/female/diverse) - fix(member-detail): display country names in German (Österreich, Deutschland) instead of raw ISO codes (AT, DE) - fix(member-statistics): total member count was always 0 getStatistics() returns per-status counts without a total key; now computes total by summing all status counts - fix(i18n): add 56 breadcrumb segment translations for DE and EN Breadcrumbs were showing English path segments (Courses, Calendar, Registrations) because translation keys for URL path segments were missing. Added all segment-level route translations so breadcrumbs now display in German throughout the app.
106 lines
3.3 KiB
TypeScript
106 lines
3.3 KiB
TypeScript
import {
|
|
Users,
|
|
UserCheck,
|
|
UserMinus,
|
|
Clock,
|
|
BarChart3,
|
|
TrendingUp,
|
|
} from 'lucide-react';
|
|
import { getTranslations } from 'next-intl/server';
|
|
|
|
import { createMemberServices } from '@kit/member-management/services';
|
|
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
|
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
|
|
|
|
import { AccountNotFound } from '~/components/account-not-found';
|
|
import { CmsPageShell } from '~/components/cms-page-shell';
|
|
import { StatsCard } from '~/components/stats-card';
|
|
import { StatsBarChart, StatsPieChart } from '~/components/stats-charts';
|
|
|
|
interface PageProps {
|
|
params: Promise<{ account: string }>;
|
|
}
|
|
|
|
export default async function MemberStatisticsPage({ params }: PageProps) {
|
|
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 { query } = createMemberServices(client);
|
|
const statsRaw = await query.getStatistics(acct.id);
|
|
|
|
// Compute total from individual status counts
|
|
const total = Object.values(statsRaw).reduce((a, b) => a + b, 0);
|
|
const stats = { ...statsRaw, total };
|
|
|
|
const statusChartData = [
|
|
{ name: t('status.active'), value: stats.active ?? 0 },
|
|
{ name: t('status.inactive'), value: stats.inactive ?? 0 },
|
|
{ name: t('status.pending'), value: stats.pending ?? 0 },
|
|
{ name: t('status.resigned'), value: stats.resigned ?? 0 },
|
|
];
|
|
|
|
return (
|
|
<CmsPageShell account={account} title={t('statistics.title')}>
|
|
<div className="flex w-full flex-col gap-6">
|
|
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
|
<StatsCard
|
|
title={t('statistics.totalMembers')}
|
|
value={stats.total ?? 0}
|
|
icon={<Users className="h-5 w-5" />}
|
|
/>
|
|
<StatsCard
|
|
title={t('status.active')}
|
|
value={stats.active ?? 0}
|
|
icon={<UserCheck className="h-5 w-5" />}
|
|
/>
|
|
<StatsCard
|
|
title={t('status.inactive')}
|
|
value={stats.inactive ?? 0}
|
|
icon={<UserMinus className="h-5 w-5" />}
|
|
/>
|
|
<StatsCard
|
|
title={t('status.pending')}
|
|
value={stats.pending ?? 0}
|
|
icon={<Clock className="h-5 w-5" />}
|
|
/>
|
|
</div>
|
|
|
|
<div className="grid grid-cols-1 gap-6 lg:grid-cols-2">
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle className="flex items-center gap-2">
|
|
<BarChart3 className="h-5 w-5" />
|
|
{t('statistics.title')}
|
|
</CardTitle>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<StatsBarChart data={statusChartData} />
|
|
</CardContent>
|
|
</Card>
|
|
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle className="flex items-center gap-2">
|
|
<TrendingUp className="h-5 w-5" />
|
|
{t('statistics.totalMembers')}
|
|
</CardTitle>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<StatsPieChart data={statusChartData} />
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
</div>
|
|
</CmsPageShell>
|
|
);
|
|
}
|