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:
@@ -14,6 +14,7 @@ import { CmsPageShell } from '~/components/cms-page-shell';
|
||||
|
||||
interface PageProps {
|
||||
params: Promise<{ account: string }>;
|
||||
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
||||
}
|
||||
|
||||
const WEEKDAYS = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'];
|
||||
@@ -51,8 +52,9 @@ function isDateInRange(
|
||||
return date >= checkIn && date < checkOut;
|
||||
}
|
||||
|
||||
export default async function BookingCalendarPage({ params }: PageProps) {
|
||||
export default async function BookingCalendarPage({ params, searchParams }: PageProps) {
|
||||
const { account } = await params;
|
||||
const search = await searchParams;
|
||||
const t = await getTranslations('bookings');
|
||||
const client = getSupabaseServerClient();
|
||||
|
||||
@@ -73,8 +75,15 @@ export default async function BookingCalendarPage({ params }: PageProps) {
|
||||
const api = createBookingManagementApi(client);
|
||||
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = now.getMonth();
|
||||
const year = Number(search.year) || now.getFullYear();
|
||||
const month = search.month != null ? Number(search.month) - 1 : now.getMonth();
|
||||
|
||||
// Compute prev/next month for navigation links
|
||||
const prevMonth = month === 0 ? 12 : month;
|
||||
const prevYear = month === 0 ? year - 1 : year;
|
||||
const nextMonth = month === 11 ? 1 : month + 2;
|
||||
const nextYear = month === 11 ? year + 1 : year;
|
||||
|
||||
const daysInMonth = getDaysInMonth(year, month);
|
||||
const firstWeekday = getFirstWeekday(year, month);
|
||||
|
||||
@@ -160,10 +169,12 @@ export default async function BookingCalendarPage({ params }: PageProps) {
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
disabled
|
||||
asChild
|
||||
aria-label={t('calendar.previousMonth')}
|
||||
>
|
||||
<ChevronLeft className="h-4 w-4" aria-hidden="true" />
|
||||
<Link href={`/home/${account}/bookings/calendar?year=${prevYear}&month=${prevMonth}`}>
|
||||
<ChevronLeft className="h-4 w-4" aria-hidden="true" />
|
||||
</Link>
|
||||
</Button>
|
||||
<CardTitle>
|
||||
{MONTH_NAMES[month]} {year}
|
||||
@@ -171,10 +182,12 @@ export default async function BookingCalendarPage({ params }: PageProps) {
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
disabled
|
||||
asChild
|
||||
aria-label={t('calendar.nextMonth')}
|
||||
>
|
||||
<ChevronRight className="h-4 w-4" aria-hidden="true" />
|
||||
<Link href={`/home/${account}/bookings/calendar?year=${nextYear}&month=${nextMonth}`}>
|
||||
<ChevronRight className="h-4 w-4" aria-hidden="true" />
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</CardHeader>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { FolderTree } from 'lucide-react';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
import { createCourseManagementApi } from '@kit/course-management/api';
|
||||
import { DeleteRefDataButton } from '@kit/course-management/components';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
|
||||
|
||||
@@ -67,6 +68,7 @@ export default async function CategoriesPage({ params }: PageProps) {
|
||||
<th scope="col" className="p-3 text-left font-medium">
|
||||
{t('common.parent')}
|
||||
</th>
|
||||
<th scope="col" className="w-16 p-3" />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -80,6 +82,13 @@ export default async function CategoriesPage({ params }: PageProps) {
|
||||
{String(cat.description ?? '—')}
|
||||
</td>
|
||||
<td className="p-3">{String(cat.parent_id ?? '—')}</td>
|
||||
<td className="p-3 text-right">
|
||||
<DeleteRefDataButton
|
||||
id={String(cat.id)}
|
||||
type="category"
|
||||
itemName={String(cat.name)}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { GraduationCap } from 'lucide-react';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
import { createCourseManagementApi } from '@kit/course-management/api';
|
||||
import { DeleteRefDataButton } from '@kit/course-management/components';
|
||||
import { formatCurrencyAmount } from '@kit/shared/dates';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
|
||||
@@ -74,6 +75,7 @@ export default async function InstructorsPage({ params }: PageProps) {
|
||||
<th scope="col" className="p-3 text-right font-medium">
|
||||
{t('instructors.hourlyRate')}
|
||||
</th>
|
||||
<th scope="col" className="w-16 p-3" />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -96,6 +98,13 @@ export default async function InstructorsPage({ params }: PageProps) {
|
||||
? formatCurrencyAmount(inst.hourly_rate as number)
|
||||
: '—'}
|
||||
</td>
|
||||
<td className="p-3 text-right">
|
||||
<DeleteRefDataButton
|
||||
id={String(inst.id)}
|
||||
type="instructor"
|
||||
itemName={`${inst.first_name} ${inst.last_name}`}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { MapPin } from 'lucide-react';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
import { createCourseManagementApi } from '@kit/course-management/api';
|
||||
import { DeleteRefDataButton } from '@kit/course-management/components';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
|
||||
|
||||
@@ -70,6 +71,7 @@ export default async function LocationsPage({ params }: PageProps) {
|
||||
<th scope="col" className="p-3 text-right font-medium">
|
||||
{t('list.capacity')}
|
||||
</th>
|
||||
<th scope="col" className="w-16 p-3" />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -89,6 +91,13 @@ export default async function LocationsPage({ params }: PageProps) {
|
||||
<td className="p-3 text-right">
|
||||
{String(loc.capacity ?? '—')}
|
||||
</td>
|
||||
<td className="p-3 text-right">
|
||||
<DeleteRefDataButton
|
||||
id={String(loc.id)}
|
||||
type="location"
|
||||
itemName={String(loc.name)}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
|
||||
@@ -26,13 +26,19 @@ export default async function DocumentTemplatesPage({ params }: PageProps) {
|
||||
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
// Document templates are stored locally for now — placeholder for future DB integration
|
||||
const templates: Array<{
|
||||
id: string;
|
||||
name: string;
|
||||
type: string;
|
||||
description: string;
|
||||
}> = [];
|
||||
// Fetch document templates from DB
|
||||
const { data: templates } = await client
|
||||
.from('document_templates')
|
||||
.select('id, name, template_type, description')
|
||||
.eq('account_id', acct.id)
|
||||
.order('name');
|
||||
|
||||
const templatesList = (templates ?? []).map((t: any) => ({
|
||||
id: String(t.id),
|
||||
name: String(t.name),
|
||||
type: String(t.template_type ?? '—'),
|
||||
description: String(t.description ?? ''),
|
||||
}));
|
||||
|
||||
return (
|
||||
<CmsPageShell account={account} title={t('templates.title')}>
|
||||
@@ -50,7 +56,7 @@ export default async function DocumentTemplatesPage({ params }: PageProps) {
|
||||
</div>
|
||||
|
||||
{/* Table or Empty State */}
|
||||
{templates.length === 0 ? (
|
||||
{templatesList.length === 0 ? (
|
||||
<EmptyState
|
||||
icon={<FileText className="h-8 w-8" />}
|
||||
title={t('templates.noTemplates')}
|
||||
@@ -61,7 +67,7 @@ export default async function DocumentTemplatesPage({ params }: PageProps) {
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>
|
||||
{t('templates.allTemplates', { count: templates.length })}
|
||||
{t('templates.allTemplates', { count: templatesList.length })}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
@@ -81,7 +87,7 @@ export default async function DocumentTemplatesPage({ params }: PageProps) {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{templates.map((template) => (
|
||||
{templatesList.map((template) => (
|
||||
<tr
|
||||
key={template.id}
|
||||
className="hover:bg-muted/30 border-b"
|
||||
|
||||
@@ -24,6 +24,29 @@ export default async function StatisticsPage({ params }: Props) {
|
||||
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
// Fetch actual statistics from existing tables
|
||||
const [watersResult, speciesResult, stockingResult, catchBooksResult, leasesResult, permitsResult] = await Promise.allSettled([
|
||||
client.from('waters').select('id', { count: 'exact' }).eq('account_id', acct.id),
|
||||
client.from('fish_species').select('id', { count: 'exact' }).eq('account_id', acct.id),
|
||||
client.from('fish_stocking').select('id, quantity, cost_total', { count: 'exact' }).eq('account_id', acct.id),
|
||||
client.from('catch_books').select('id, status', { count: 'exact' }).eq('account_id', acct.id),
|
||||
client.from('fishing_leases').select('id', { count: 'exact' }).eq('account_id', acct.id).eq('status', 'active'),
|
||||
client.from('fishing_permits').select('id', { count: 'exact' }).eq('account_id', acct.id),
|
||||
]);
|
||||
|
||||
const waterCount = watersResult.status === 'fulfilled' ? (watersResult.value.count ?? 0) : 0;
|
||||
const speciesCount = speciesResult.status === 'fulfilled' ? (speciesResult.value.count ?? 0) : 0;
|
||||
const stockingData = stockingResult.status === 'fulfilled' ? (stockingResult.value.data ?? []) : [];
|
||||
const stockingCount = stockingData.length;
|
||||
const stockingCost = stockingData.reduce((sum: number, s: any) => sum + (Number(s.cost_total) || 0), 0);
|
||||
const catchBookCount = catchBooksResult.status === 'fulfilled' ? (catchBooksResult.value.count ?? 0) : 0;
|
||||
const catchBookData = catchBooksResult.status === 'fulfilled' ? (catchBooksResult.value.data ?? []) : [];
|
||||
const pendingCatchBooks = catchBookData.filter((cb: any) => cb.status === 'submitted').length;
|
||||
const leaseCount = leasesResult.status === 'fulfilled' ? (leasesResult.value.count ?? 0) : 0;
|
||||
const permitCount = permitsResult.status === 'fulfilled' ? (permitsResult.value.count ?? 0) : 0;
|
||||
|
||||
const formatCurrency = (v: number) => new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(v);
|
||||
|
||||
return (
|
||||
<CmsPageShell account={account} title={t('pages.statisticsTitle')}>
|
||||
<FischereiTabNavigation account={account} activeTab="statistics" />
|
||||
@@ -33,22 +56,27 @@ export default async function StatisticsPage({ params }: Props) {
|
||||
Fangstatistiken und Auswertungen
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<Card><CardContent className="p-6"><p className="text-muted-foreground text-sm">Gewässer</p><p className="text-2xl font-bold">{waterCount}</p></CardContent></Card>
|
||||
<Card><CardContent className="p-6"><p className="text-muted-foreground text-sm">Fischarten</p><p className="text-2xl font-bold">{speciesCount}</p></CardContent></Card>
|
||||
<Card><CardContent className="p-6"><p className="text-muted-foreground text-sm">Besatzaktionen</p><p className="text-2xl font-bold">{stockingCount}</p><p className="text-muted-foreground text-xs">{formatCurrency(stockingCost)} Gesamtkosten</p></CardContent></Card>
|
||||
<Card><CardContent className="p-6"><p className="text-muted-foreground text-sm">Fangbücher</p><p className="text-2xl font-bold">{catchBookCount}</p>{pendingCatchBooks > 0 && <p className="text-xs text-amber-600">{pendingCatchBooks} zur Prüfung</p>}</CardContent></Card>
|
||||
<Card><CardContent className="p-6"><p className="text-muted-foreground text-sm">Aktive Pachten</p><p className="text-2xl font-bold">{leaseCount}</p></CardContent></Card>
|
||||
<Card><CardContent className="p-6"><p className="text-muted-foreground text-sm">Erlaubnisscheine</p><p className="text-2xl font-bold">{permitCount}</p></CardContent></Card>
|
||||
</div>
|
||||
|
||||
{waterCount === 0 && speciesCount === 0 && (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Fangstatistiken</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="flex flex-col items-center justify-center rounded-lg border border-dashed p-12 text-center">
|
||||
<h3 className="text-lg font-semibold">
|
||||
Noch keine Daten vorhanden
|
||||
</h3>
|
||||
<CardContent className="p-6">
|
||||
<div className="flex flex-col items-center justify-center rounded-lg border border-dashed p-8 text-center">
|
||||
<h3 className="text-lg font-semibold">Noch keine Daten vorhanden</h3>
|
||||
<p className="text-muted-foreground mt-1 max-w-sm text-sm">
|
||||
Sobald Fangbücher eingereicht und geprüft werden, erscheinen
|
||||
hier Statistiken und Auswertungen.
|
||||
Sobald Gewässer, Fischarten und Fangbücher angelegt werden, erscheinen hier detaillierte Statistiken.
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
</CmsPageShell>
|
||||
);
|
||||
|
||||
@@ -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