Add account hierarchy framework with migrations, RLS policies, and UI components

This commit is contained in:
T. Zehetbauer
2026-03-31 22:18:04 +02:00
parent 7e7da0b465
commit 59546ad6d2
262 changed files with 11671 additions and 3927 deletions

View File

@@ -49,26 +49,24 @@ export const TeamAccountLayoutMobileNavigation = (
) => {
const signOut = useSignOut();
const Links = props.config.routes.map(
(item, index) => {
if ('children' in item) {
return item.children.map((child) => {
return (
<DropdownLink
key={child.path}
Icon={child.Icon}
path={child.path}
label={child.label}
/>
);
});
}
const Links = props.config.routes.map((item, index) => {
if ('children' in item) {
return item.children.map((child) => {
return (
<DropdownLink
key={child.path}
Icon={child.Icon}
path={child.path}
label={child.label}
/>
);
});
}
if ('divider' in item) {
return <DropdownMenuSeparator key={index} />;
}
},
);
if ('divider' in item) {
return <DropdownMenuSeparator key={index} />;
}
});
return (
<DropdownMenu>

View File

@@ -10,6 +10,7 @@ import {
User,
} from 'lucide-react';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
@@ -21,8 +22,8 @@ import {
CardTitle,
} from '@kit/ui/card';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
params: Promise<{ account: string; bookingId: string }>;
@@ -124,9 +125,7 @@ export default async function BookingDetailPage({ params }: PageProps) {
{STATUS_LABEL[status] ?? status}
</Badge>
</div>
<p className="text-muted-foreground text-sm">
ID: {bookingId}
</p>
<p className="text-muted-foreground text-sm">ID: {bookingId}</p>
</div>
</div>
</div>
@@ -144,7 +143,7 @@ export default async function BookingDetailPage({ params }: PageProps) {
{room ? (
<div className="space-y-2">
<div className="flex justify-between">
<span className="text-sm text-muted-foreground">
<span className="text-muted-foreground text-sm">
Zimmernummer
</span>
<span className="font-medium">
@@ -153,14 +152,14 @@ export default async function BookingDetailPage({ params }: PageProps) {
</div>
{room.name && (
<div className="flex justify-between">
<span className="text-sm text-muted-foreground">
<span className="text-muted-foreground text-sm">
Name
</span>
<span className="font-medium">{String(room.name)}</span>
</div>
)}
<div className="flex justify-between">
<span className="text-sm text-muted-foreground">Typ</span>
<span className="text-muted-foreground text-sm">Typ</span>
<span className="font-medium">
{String(room.room_type ?? '—')}
</span>
@@ -186,29 +185,25 @@ export default async function BookingDetailPage({ params }: PageProps) {
{guest ? (
<div className="space-y-2">
<div className="flex justify-between">
<span className="text-sm text-muted-foreground">Name</span>
<span className="text-muted-foreground text-sm">Name</span>
<span className="font-medium">
{String(guest.first_name)} {String(guest.last_name)}
</span>
</div>
{guest.email && (
<div className="flex justify-between">
<span className="text-sm text-muted-foreground">
<span className="text-muted-foreground text-sm">
E-Mail
</span>
<span className="font-medium">
{String(guest.email)}
</span>
<span className="font-medium">{String(guest.email)}</span>
</div>
)}
{guest.phone && (
<div className="flex justify-between">
<span className="text-sm text-muted-foreground">
<span className="text-muted-foreground text-sm">
Telefon
</span>
<span className="font-medium">
{String(guest.phone)}
</span>
<span className="font-medium">{String(guest.phone)}</span>
</div>
)}
</div>
@@ -231,56 +226,30 @@ export default async function BookingDetailPage({ params }: PageProps) {
<CardContent>
<div className="space-y-2">
<div className="flex justify-between">
<span className="text-sm text-muted-foreground">
<span className="text-muted-foreground text-sm">
Check-in
</span>
<span className="font-medium">
{booking.check_in
? new Date(String(booking.check_in)).toLocaleDateString(
'de-DE',
{
weekday: 'short',
day: '2-digit',
month: '2-digit',
year: 'numeric',
},
)
: '—'}
{formatDate(booking.check_in)}
</span>
</div>
<div className="flex justify-between">
<span className="text-sm text-muted-foreground">
<span className="text-muted-foreground text-sm">
Check-out
</span>
<span className="font-medium">
{booking.check_out
? new Date(String(booking.check_out)).toLocaleDateString(
'de-DE',
{
weekday: 'short',
day: '2-digit',
month: '2-digit',
year: 'numeric',
},
)
: '—'}
{formatDate(booking.check_out)}
</span>
</div>
<div className="flex justify-between">
<span className="text-sm text-muted-foreground">
<span className="text-muted-foreground text-sm">
Erwachsene
</span>
<span className="font-medium">
{booking.adults ?? '—'}
</span>
<span className="font-medium">{booking.adults ?? '—'}</span>
</div>
<div className="flex justify-between">
<span className="text-sm text-muted-foreground">
Kinder
</span>
<span className="font-medium">
{booking.children ?? 0}
</span>
<span className="text-muted-foreground text-sm">Kinder</span>
<span className="font-medium">{booking.children ?? 0}</span>
</div>
</div>
</CardContent>
@@ -294,7 +263,7 @@ export default async function BookingDetailPage({ params }: PageProps) {
<CardContent>
<div className="space-y-2">
<div className="flex justify-between">
<span className="text-sm text-muted-foreground">
<span className="text-muted-foreground text-sm">
Gesamtpreis
</span>
<span className="text-2xl font-bold">
@@ -305,7 +274,7 @@ export default async function BookingDetailPage({ params }: PageProps) {
</div>
{booking.notes && (
<div className="border-t pt-2">
<span className="text-sm text-muted-foreground">
<span className="text-muted-foreground text-sm">
Notizen
</span>
<p className="mt-1 text-sm">{String(booking.notes)}</p>
@@ -320,9 +289,7 @@ export default async function BookingDetailPage({ params }: PageProps) {
<Card>
<CardHeader>
<CardTitle>Aktionen</CardTitle>
<CardDescription>
Status der Buchung ändern
</CardDescription>
<CardDescription>Status der Buchung ändern</CardDescription>
</CardHeader>
<CardContent>
<div className="flex flex-wrap gap-3">
@@ -350,10 +317,10 @@ export default async function BookingDetailPage({ params }: PageProps) {
)}
{status === 'cancelled' || status === 'checked_out' ? (
<p className="text-sm text-muted-foreground py-2">
<p className="text-muted-foreground py-2 text-sm">
Diese Buchung ist{' '}
{status === 'cancelled' ? 'storniert' : 'abgeschlossen'} keine
weiteren Aktionen verfügbar.
{status === 'cancelled' ? 'storniert' : 'abgeschlossen'}
keine weiteren Aktionen verfügbar.
</p>
) : null}
</div>

View File

@@ -2,15 +2,14 @@ import Link from 'next/link';
import { ArrowLeft, ChevronLeft, ChevronRight } from 'lucide-react';
import { createBookingManagementApi } from '@kit/booking-management/api';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createBookingManagementApi } from '@kit/booking-management/api';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
params: Promise<{ account: string }>;
@@ -43,7 +42,11 @@ function getFirstWeekday(year: number, month: number): number {
return day === 0 ? 6 : day - 1;
}
function isDateInRange(date: string, checkIn: string, checkOut: string): boolean {
function isDateInRange(
date: string,
checkIn: string,
checkOut: string,
): boolean {
return date >= checkIn && date < checkOut;
}
@@ -101,7 +104,11 @@ export default async function BookingCalendarPage({ params }: PageProps) {
}
// Build calendar grid cells
const cells: Array<{ day: number | null; occupied: boolean; isToday: boolean }> = [];
const cells: Array<{
day: number | null;
occupied: boolean;
isToday: boolean;
}> = [];
// Empty cells before first day
for (let i = 0; i < firstWeekday; i++) {
@@ -158,11 +165,11 @@ export default async function BookingCalendarPage({ params }: PageProps) {
</CardHeader>
<CardContent>
{/* Weekday Header */}
<div className="grid grid-cols-7 gap-1 mb-1">
<div className="mb-1 grid grid-cols-7 gap-1">
{WEEKDAYS.map((day) => (
<div
key={day}
className="text-center text-xs font-medium text-muted-foreground py-2"
className="text-muted-foreground py-2 text-center text-xs font-medium"
>
{day}
</div>
@@ -180,13 +187,13 @@ export default async function BookingCalendarPage({ params }: PageProps) {
: cell.occupied
? 'bg-primary/15 text-primary font-semibold'
: 'bg-muted/30 hover:bg-muted/50'
} ${cell.isToday ? 'ring-2 ring-primary ring-offset-1' : ''}`}
} ${cell.isToday ? 'ring-primary ring-2 ring-offset-1' : ''}`}
>
{cell.day !== null && (
<>
<span>{cell.day}</span>
{cell.occupied && (
<span className="absolute bottom-1 left-1/2 -translate-x-1/2 h-1.5 w-1.5 rounded-full bg-primary" />
<span className="bg-primary absolute bottom-1 left-1/2 h-1.5 w-1.5 -translate-x-1/2 rounded-full" />
)}
</>
)}
@@ -195,17 +202,17 @@ export default async function BookingCalendarPage({ params }: PageProps) {
</div>
{/* Legend */}
<div className="mt-4 flex items-center gap-4 text-xs text-muted-foreground">
<div className="text-muted-foreground mt-4 flex items-center gap-4 text-xs">
<div className="flex items-center gap-1.5">
<span className="inline-block h-3 w-3 rounded-sm bg-primary/15" />
<span className="bg-primary/15 inline-block h-3 w-3 rounded-sm" />
Belegt
</div>
<div className="flex items-center gap-1.5">
<span className="inline-block h-3 w-3 rounded-sm bg-muted/30" />
<span className="bg-muted/30 inline-block h-3 w-3 rounded-sm" />
Frei
</div>
<div className="flex items-center gap-1.5">
<span className="inline-block h-3 w-3 rounded-sm ring-2 ring-primary" />
<span className="ring-primary inline-block h-3 w-3 rounded-sm ring-2" />
Heute
</div>
</div>
@@ -217,7 +224,7 @@ export default async function BookingCalendarPage({ params }: PageProps) {
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-muted-foreground">
<p className="text-muted-foreground text-sm">
Buchungen in diesem Monat
</p>
<p className="text-2xl font-bold">{bookings.data.length}</p>

View File

@@ -1,14 +1,13 @@
import { UserCircle, Plus } from 'lucide-react';
import { createBookingManagementApi } from '@kit/booking-management/api';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createBookingManagementApi } from '@kit/booking-management/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { AccountNotFound } from '~/components/account-not-found';
interface PageProps {
params: Promise<{ account: string }>;
@@ -62,7 +61,7 @@ export default async function GuestsPage({ params }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Name</th>
<th className="p-3 text-left font-medium">E-Mail</th>
<th className="p-3 text-left font-medium">Telefon</th>
@@ -72,9 +71,13 @@ export default async function GuestsPage({ params }: PageProps) {
</thead>
<tbody>
{guests.map((guest: Record<string, unknown>) => (
<tr key={String(guest.id)} className="border-b hover:bg-muted/30">
<tr
key={String(guest.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">
{String(guest.last_name ?? '')}, {String(guest.first_name ?? '')}
{String(guest.last_name ?? '')},{' '}
{String(guest.first_name ?? '')}
</td>
<td className="p-3">{String(guest.email ?? '—')}</td>
<td className="p-3">{String(guest.phone ?? '—')}</td>

View File

@@ -1,15 +1,22 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createBookingManagementApi } from '@kit/booking-management/api';
import { CreateBookingForm } from '@kit/booking-management/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
interface Props { params: Promise<{ account: string }> }
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
}
export default async function NewBookingPage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) {
return (
<CmsPageShell account={account} title="Neue Buchung">
@@ -22,13 +29,20 @@ export default async function NewBookingPage({ params }: Props) {
const rooms = await api.listRooms(acct.id);
return (
<CmsPageShell account={account} title="Neue Buchung" description="Buchung erstellen">
<CreateBookingForm
accountId={acct.id}
account={account}
<CmsPageShell
account={account}
title="Neue Buchung"
description="Buchung erstellen"
>
<CreateBookingForm
accountId={acct.id}
account={account}
rooms={(rooms ?? []).map((r: Record<string, unknown>) => ({
id: String(r.id), roomNumber: String(r.room_number), name: String(r.name ?? ''), pricePerNight: Number(r.price_per_night ?? 0)
}))}
id: String(r.id),
roomNumber: String(r.room_number),
name: String(r.name ?? ''),
pricePerNight: Number(r.price_per_night ?? 0),
}))}
/>
</CmsPageShell>
);

View File

@@ -2,18 +2,18 @@ import Link from 'next/link';
import { BedDouble, CalendarCheck, Plus, Euro, Search } from 'lucide-react';
import { createBookingManagementApi } from '@kit/booking-management/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { Input } from '@kit/ui/input';
import { createBookingManagementApi } from '@kit/booking-management/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { StatsCard } from '~/components/stats-card';
import { AccountNotFound } from '~/components/account-not-found';
interface PageProps {
params: Promise<{ account: string }>;
@@ -42,7 +42,10 @@ const STATUS_LABEL: Record<string, string> = {
no_show: 'Nicht erschienen',
};
export default async function BookingsPage({ params, searchParams }: PageProps) {
export default async function BookingsPage({
params,
searchParams,
}: PageProps) {
const { account } = await params;
const search = await searchParams;
const client = getSupabaseServerClient();
@@ -148,7 +151,7 @@ export default async function BookingsPage({ params, searchParams }: PageProps)
{/* Search */}
<form className="flex items-center gap-2">
<div className="relative max-w-sm flex-1">
<Search className="absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
<Search className="text-muted-foreground absolute top-1/2 left-2.5 h-4 w-4 -translate-y-1/2" />
<Input
name="q"
defaultValue={searchQuery}
@@ -200,7 +203,7 @@ export default async function BookingsPage({ params, searchParams }: PageProps)
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Zimmer</th>
<th className="p-3 text-left font-medium">Gast</th>
<th className="p-3 text-left font-medium">Anreise</th>
@@ -211,13 +214,19 @@ export default async function BookingsPage({ params, searchParams }: PageProps)
</thead>
<tbody>
{bookingsData.map((booking) => {
const room = booking.room as Record<string, string> | null;
const guest = booking.guest as Record<string, string> | null;
const room = booking.room as Record<
string,
string
> | null;
const guest = booking.guest as Record<
string,
string
> | null;
return (
<tr
key={String(booking.id)}
className="border-b hover:bg-muted/30"
className="hover:bg-muted/30 border-b"
>
<td className="p-3">
<Link
@@ -235,18 +244,10 @@ export default async function BookingsPage({ params, searchParams }: PageProps)
: '—'}
</td>
<td className="p-3">
{booking.check_in
? new Date(
String(booking.check_in),
).toLocaleDateString('de-DE')
: '—'}
{formatDate(booking.check_in)}
</td>
<td className="p-3">
{booking.check_out
? new Date(
String(booking.check_out),
).toLocaleDateString('de-DE')
: '—'}
{formatDate(booking.check_out)}
</td>
<td className="p-3">
<Badge
@@ -274,14 +275,12 @@ export default async function BookingsPage({ params, searchParams }: PageProps)
{/* Pagination */}
{totalPages > 1 && !searchQuery && (
<div className="flex items-center justify-between border-t px-2 py-4">
<p className="text-sm text-muted-foreground">
<p className="text-muted-foreground text-sm">
Seite {page} von {totalPages} ({total} Einträge)
</p>
<div className="flex items-center gap-2">
{page > 1 ? (
<Link
href={`/home/${account}/bookings?page=${page - 1}`}
>
<Link href={`/home/${account}/bookings?page=${page - 1}`}>
<Button variant="outline" size="sm">
Zurück
</Button>
@@ -293,9 +292,7 @@ export default async function BookingsPage({ params, searchParams }: PageProps)
)}
{page < totalPages ? (
<Link
href={`/home/${account}/bookings?page=${page + 1}`}
>
<Link href={`/home/${account}/bookings?page=${page + 1}`}>
<Button variant="outline" size="sm">
Weiter
</Button>

View File

@@ -1,15 +1,14 @@
import { BedDouble, Plus } from 'lucide-react';
import { createBookingManagementApi } from '@kit/booking-management/api';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createBookingManagementApi } from '@kit/booking-management/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { AccountNotFound } from '~/components/account-not-found';
interface PageProps {
params: Promise<{ account: string }>;
@@ -63,26 +62,37 @@ export default async function RoomsPage({ params }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Zimmernr.</th>
<th className="p-3 text-left font-medium">Name</th>
<th className="p-3 text-left font-medium">Typ</th>
<th className="p-3 text-right font-medium">Kapazität</th>
<th className="p-3 text-right font-medium">Preis/Nacht</th>
<th className="p-3 text-right font-medium">
Preis/Nacht
</th>
<th className="p-3 text-center font-medium">Aktiv</th>
</tr>
</thead>
<tbody>
{rooms.map((room: Record<string, unknown>) => (
<tr key={String(room.id)} className="border-b hover:bg-muted/30">
<tr
key={String(room.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-mono text-xs">
{String(room.room_number ?? '—')}
</td>
<td className="p-3 font-medium">{String(room.name ?? '—')}</td>
<td className="p-3">
<Badge variant="outline">{String(room.room_type ?? '—')}</Badge>
<td className="p-3 font-medium">
{String(room.name ?? '—')}
</td>
<td className="p-3">
<Badge variant="outline">
{String(room.room_type ?? '—')}
</Badge>
</td>
<td className="p-3 text-right">
{String(room.capacity ?? '—')}
</td>
<td className="p-3 text-right">{String(room.capacity ?? '—')}</td>
<td className="p-3 text-right">
{room.price_per_night != null
? `${Number(room.price_per_night).toFixed(2)}`

View File

@@ -1,11 +1,11 @@
import { ClipboardCheck, Calendar } from 'lucide-react';
import { createCourseManagementApi } from '@kit/course-management/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createCourseManagementApi } from '@kit/course-management/api';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
@@ -14,7 +14,10 @@ interface PageProps {
searchParams: Promise<Record<string, string | string[] | undefined>>;
}
export default async function AttendancePage({ params, searchParams }: PageProps) {
export default async function AttendancePage({
params,
searchParams,
}: PageProps) {
const { account, courseId } = await params;
const search = await searchParams;
const client = getSupabaseServerClient();
@@ -28,14 +31,21 @@ export default async function AttendancePage({ params, searchParams }: PageProps
if (!course) return <div>Kurs nicht gefunden</div>;
const selectedSessionId = (search.session as string) ?? (sessions.length > 0 ? String((sessions[0] as Record<string, unknown>).id) : null);
const selectedSessionId =
(search.session as string) ??
(sessions.length > 0
? String((sessions[0] as Record<string, unknown>).id)
: null);
const attendance = selectedSessionId
? await api.getAttendance(selectedSessionId)
: [];
const attendanceMap = new Map(
attendance.map((a: Record<string, unknown>) => [String(a.participant_id), Boolean(a.present)]),
attendance.map((a: Record<string, unknown>) => [
String(a.participant_id),
Boolean(a.present),
]),
);
return (
@@ -70,9 +80,12 @@ export default async function AttendancePage({ params, searchParams }: PageProps
key={String(s.id)}
href={`/home/${account}/courses/${courseId}/attendance?session=${String(s.id)}`}
>
<Badge variant={isSelected ? 'default' : 'outline'} className="cursor-pointer px-3 py-1">
<Badge
variant={isSelected ? 'default' : 'outline'}
className="cursor-pointer px-3 py-1"
>
{s.session_date
? new Date(String(s.session_date)).toLocaleDateString('de-DE')
? formatDate(s.session_date as string)
: String(s.id)}
</Badge>
</a>
@@ -92,28 +105,38 @@ export default async function AttendancePage({ params, searchParams }: PageProps
</CardHeader>
<CardContent>
{participants.length === 0 ? (
<p className="py-6 text-center text-sm text-muted-foreground">
<p className="text-muted-foreground py-6 text-center text-sm">
Keine Teilnehmer in diesem Kurs
</p>
) : (
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<th className="p-3 text-left font-medium">Teilnehmer</th>
<th className="p-3 text-center font-medium">Anwesend</th>
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">
Teilnehmer
</th>
<th className="p-3 text-center font-medium">
Anwesend
</th>
</tr>
</thead>
<tbody>
{participants.map((p: Record<string, unknown>) => (
<tr key={String(p.id)} className="border-b hover:bg-muted/30">
<tr
key={String(p.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">
{String(p.last_name ?? '')}, {String(p.first_name ?? '')}
{String(p.last_name ?? '')},{' '}
{String(p.first_name ?? '')}
</td>
<td className="p-3 text-center">
<input
type="checkbox"
defaultChecked={attendanceMap.get(String(p.id)) ?? false}
defaultChecked={
attendanceMap.get(String(p.id)) ?? false
}
className="h-4 w-4 rounded border-gray-300"
aria-label={`Anwesenheit ${String(p.last_name)}`}
/>

View File

@@ -1,14 +1,21 @@
import Link from 'next/link';
import { GraduationCap, Users, Calendar, Euro, User, Clock } from 'lucide-react';
import {
GraduationCap,
Users,
Calendar,
Euro,
User,
Clock,
} from 'lucide-react';
import { createCourseManagementApi } from '@kit/course-management/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createCourseManagementApi } from '@kit/course-management/api';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
@@ -16,13 +23,22 @@ interface PageProps {
}
const STATUS_LABEL: Record<string, string> = {
planned: 'Geplant', open: 'Offen', running: 'Laufend',
completed: 'Abgeschlossen', cancelled: 'Abgesagt',
planned: 'Geplant',
open: 'Offen',
running: 'Laufend',
completed: 'Abgeschlossen',
cancelled: 'Abgesagt',
};
const STATUS_VARIANT: Record<string, 'secondary' | 'default' | 'info' | 'outline' | 'destructive'> = {
planned: 'secondary', open: 'default', running: 'info',
completed: 'outline', cancelled: 'destructive',
const STATUS_VARIANT: Record<
string,
'secondary' | 'default' | 'info' | 'outline' | 'destructive'
> = {
planned: 'secondary',
open: 'default',
running: 'info',
completed: 'outline',
cancelled: 'destructive',
};
export default async function CourseDetailPage({ params }: PageProps) {
@@ -47,19 +63,21 @@ export default async function CourseDetailPage({ params }: PageProps) {
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
<Card>
<CardContent className="flex items-center gap-3 p-4">
<GraduationCap className="h-5 w-5 text-primary" />
<GraduationCap className="text-primary h-5 w-5" />
<div>
<p className="text-xs text-muted-foreground">Name</p>
<p className="text-muted-foreground text-xs">Name</p>
<p className="font-semibold">{String(c.name)}</p>
</div>
</CardContent>
</Card>
<Card>
<CardContent className="flex items-center gap-3 p-4">
<Clock className="h-5 w-5 text-primary" />
<Clock className="text-primary h-5 w-5" />
<div>
<p className="text-xs text-muted-foreground">Status</p>
<Badge variant={STATUS_VARIANT[String(c.status)] ?? 'secondary'}>
<p className="text-muted-foreground text-xs">Status</p>
<Badge
variant={STATUS_VARIANT[String(c.status)] ?? 'secondary'}
>
{STATUS_LABEL[String(c.status)] ?? String(c.status)}
</Badge>
</div>
@@ -67,31 +85,33 @@ export default async function CourseDetailPage({ params }: PageProps) {
</Card>
<Card>
<CardContent className="flex items-center gap-3 p-4">
<User className="h-5 w-5 text-primary" />
<User className="text-primary h-5 w-5" />
<div>
<p className="text-xs text-muted-foreground">Dozent</p>
<p className="font-semibold">{String(c.instructor_id ?? '—')}</p>
</div>
</CardContent>
</Card>
<Card>
<CardContent className="flex items-center gap-3 p-4">
<Calendar className="h-5 w-5 text-primary" />
<div>
<p className="text-xs text-muted-foreground">Beginn Ende</p>
<p className="text-muted-foreground text-xs">Dozent</p>
<p className="font-semibold">
{c.start_date ? new Date(String(c.start_date)).toLocaleDateString('de-DE') : '—'}
{' '}
{c.end_date ? new Date(String(c.end_date)).toLocaleDateString('de-DE') : '—'}
{String(c.instructor_id ?? '—')}
</p>
</div>
</CardContent>
</Card>
<Card>
<CardContent className="flex items-center gap-3 p-4">
<Euro className="h-5 w-5 text-primary" />
<Calendar className="text-primary h-5 w-5" />
<div>
<p className="text-xs text-muted-foreground">Gebühr</p>
<p className="text-muted-foreground text-xs">Beginn Ende</p>
<p className="font-semibold">
{formatDate(c.start_date as string)}
{' '}
{formatDate(c.end_date as string)}
</p>
</div>
</CardContent>
</Card>
<Card>
<CardContent className="flex items-center gap-3 p-4">
<Euro className="text-primary h-5 w-5" />
<div>
<p className="text-muted-foreground text-xs">Gebühr</p>
<p className="font-semibold">
{c.fee != null ? `${Number(c.fee).toFixed(2)}` : '—'}
</p>
@@ -100,9 +120,9 @@ export default async function CourseDetailPage({ params }: PageProps) {
</Card>
<Card>
<CardContent className="flex items-center gap-3 p-4">
<Users className="h-5 w-5 text-primary" />
<Users className="text-primary h-5 w-5" />
<div>
<p className="text-xs text-muted-foreground">Teilnehmer</p>
<p className="text-muted-foreground text-xs">Teilnehmer</p>
<p className="font-semibold">
{participants.length} / {String(c.capacity ?? '∞')}
</p>
@@ -116,14 +136,16 @@ export default async function CourseDetailPage({ params }: PageProps) {
<CardHeader className="flex flex-row items-center justify-between">
<CardTitle>Teilnehmer</CardTitle>
<Link href={`/home/${account}/courses/${courseId}/participants`}>
<Button variant="outline" size="sm">Alle anzeigen</Button>
<Button variant="outline" size="sm">
Alle anzeigen
</Button>
</Link>
</CardHeader>
<CardContent>
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Name</th>
<th className="p-3 text-left font-medium">E-Mail</th>
<th className="p-3 text-left font-medium">Status</th>
@@ -132,15 +154,36 @@ export default async function CourseDetailPage({ params }: PageProps) {
</thead>
<tbody>
{participants.length === 0 ? (
<tr><td colSpan={4} className="p-6 text-center text-muted-foreground">Keine Teilnehmer</td></tr>
) : participants.map((p: Record<string, unknown>) => (
<tr key={String(p.id)} className="border-b hover:bg-muted/30">
<td className="p-3 font-medium">{String(p.last_name ?? '')}, {String(p.first_name ?? '')}</td>
<td className="p-3">{String(p.email ?? '—')}</td>
<td className="p-3"><Badge variant="outline">{String(p.status ?? '—')}</Badge></td>
<td className="p-3">{p.enrolled_at ? new Date(String(p.enrolled_at)).toLocaleDateString('de-DE') : '—'}</td>
<tr>
<td
colSpan={4}
className="text-muted-foreground p-6 text-center"
>
Keine Teilnehmer
</td>
</tr>
))}
) : (
participants.map((p: Record<string, unknown>) => (
<tr
key={String(p.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">
{String(p.last_name ?? '')},{' '}
{String(p.first_name ?? '')}
</td>
<td className="p-3">{String(p.email ?? '—')}</td>
<td className="p-3">
<Badge variant="outline">
{String(p.status ?? '—')}
</Badge>
</td>
<td className="p-3">
{formatDate(p.enrolled_at as string)}
</td>
</tr>
))
)}
</tbody>
</table>
</div>
@@ -152,14 +195,16 @@ export default async function CourseDetailPage({ params }: PageProps) {
<CardHeader className="flex flex-row items-center justify-between">
<CardTitle>Termine</CardTitle>
<Link href={`/home/${account}/courses/${courseId}/attendance`}>
<Button variant="outline" size="sm">Anwesenheit</Button>
<Button variant="outline" size="sm">
Anwesenheit
</Button>
</Link>
</CardHeader>
<CardContent>
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Datum</th>
<th className="p-3 text-left font-medium">Beginn</th>
<th className="p-3 text-left font-medium">Ende</th>
@@ -168,15 +213,35 @@ export default async function CourseDetailPage({ params }: PageProps) {
</thead>
<tbody>
{sessions.length === 0 ? (
<tr><td colSpan={4} className="p-6 text-center text-muted-foreground">Keine Termine</td></tr>
) : sessions.map((s: Record<string, unknown>) => (
<tr key={String(s.id)} className="border-b hover:bg-muted/30">
<td className="p-3">{s.session_date ? new Date(String(s.session_date)).toLocaleDateString('de-DE') : '—'}</td>
<td className="p-3">{String(s.start_time ?? '—')}</td>
<td className="p-3">{String(s.end_time ?? '—')}</td>
<td className="p-3">{s.cancelled ? <Badge variant="destructive">Ja</Badge> : '—'}</td>
<tr>
<td
colSpan={4}
className="text-muted-foreground p-6 text-center"
>
Keine Termine
</td>
</tr>
))}
) : (
sessions.map((s: Record<string, unknown>) => (
<tr
key={String(s.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3">
{formatDate(s.session_date as string)}
</td>
<td className="p-3">{String(s.start_time ?? '—')}</td>
<td className="p-3">{String(s.end_time ?? '—')}</td>
<td className="p-3">
{s.cancelled ? (
<Badge variant="destructive">Ja</Badge>
) : (
'—'
)}
</td>
</tr>
))
)}
</tbody>
</table>
</div>

View File

@@ -2,13 +2,13 @@ import Link from 'next/link';
import { Plus, Users } from 'lucide-react';
import { createCourseManagementApi } from '@kit/course-management/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createCourseManagementApi } from '@kit/course-management/api';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
@@ -16,7 +16,10 @@ interface PageProps {
params: Promise<{ account: string; courseId: string }>;
}
const STATUS_VARIANT: Record<string, 'secondary' | 'default' | 'info' | 'outline' | 'destructive'> = {
const STATUS_VARIANT: Record<
string,
'secondary' | 'default' | 'info' | 'outline' | 'destructive'
> = {
enrolled: 'default',
waitlisted: 'secondary',
cancelled: 'destructive',
@@ -49,7 +52,8 @@ export default async function ParticipantsPage({ params }: PageProps) {
<div>
<h1 className="text-2xl font-bold">Teilnehmer</h1>
<p className="text-muted-foreground">
{String((course as Record<string, unknown>).name)} {participants.length} Teilnehmer
{String((course as Record<string, unknown>).name)} {' '}
{participants.length} Teilnehmer
</p>
</div>
<Button>
@@ -74,31 +78,39 @@ export default async function ParticipantsPage({ params }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Name</th>
<th className="p-3 text-left font-medium">E-Mail</th>
<th className="p-3 text-left font-medium">Telefon</th>
<th className="p-3 text-left font-medium">Status</th>
<th className="p-3 text-left font-medium">Anmeldedatum</th>
<th className="p-3 text-left font-medium">
Anmeldedatum
</th>
</tr>
</thead>
<tbody>
{participants.map((p: Record<string, unknown>) => (
<tr key={String(p.id)} className="border-b hover:bg-muted/30">
<tr
key={String(p.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">
{String(p.last_name ?? '')}, {String(p.first_name ?? '')}
{String(p.last_name ?? '')},{' '}
{String(p.first_name ?? '')}
</td>
<td className="p-3">{String(p.email ?? '—')}</td>
<td className="p-3">{String(p.phone ?? '—')}</td>
<td className="p-3">
<Badge variant={STATUS_VARIANT[String(p.status)] ?? 'secondary'}>
<Badge
variant={
STATUS_VARIANT[String(p.status)] ?? 'secondary'
}
>
{STATUS_LABEL[String(p.status)] ?? String(p.status)}
</Badge>
</td>
<td className="p-3">
{p.enrolled_at
? new Date(String(p.enrolled_at)).toLocaleDateString('de-DE')
: '—'}
{formatDate(p.enrolled_at as string)}
</td>
</tr>
))}

View File

@@ -2,15 +2,15 @@ import Link from 'next/link';
import { ArrowLeft, ChevronLeft, ChevronRight } from 'lucide-react';
import { createCourseManagementApi } from '@kit/course-management/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createCourseManagementApi } from '@kit/course-management/api';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
params: Promise<{ account: string }>;
@@ -86,7 +86,11 @@ export default async function CourseCalendarPage({ params }: PageProps) {
}
// Build calendar grid
const cells: Array<{ day: number | null; hasCourse: boolean; isToday: boolean }> = [];
const cells: Array<{
day: number | null;
hasCourse: boolean;
isToday: boolean;
}> = [];
for (let i = 0; i < firstWeekday; i++) {
cells.push({ day: null, hasCourse: false, isToday: false });
@@ -96,7 +100,10 @@ export default async function CourseCalendarPage({ params }: PageProps) {
cells.push({
day: d,
hasCourse: courseDates.has(d),
isToday: d === now.getDate() && month === now.getMonth() && year === now.getFullYear(),
isToday:
d === now.getDate() &&
month === now.getMonth() &&
year === now.getFullYear(),
});
}
@@ -120,9 +127,7 @@ export default async function CourseCalendarPage({ params }: PageProps) {
<ArrowLeft className="h-4 w-4" />
</Button>
</Link>
<p className="text-muted-foreground">
Kurstermine im Überblick
</p>
<p className="text-muted-foreground">Kurstermine im Überblick</p>
</div>
</div>
@@ -143,11 +148,11 @@ export default async function CourseCalendarPage({ params }: PageProps) {
</CardHeader>
<CardContent>
{/* Weekday Header */}
<div className="grid grid-cols-7 gap-1 mb-1">
<div className="mb-1 grid grid-cols-7 gap-1">
{WEEKDAYS.map((day) => (
<div
key={day}
className="text-center text-xs font-medium text-muted-foreground py-2"
className="text-muted-foreground py-2 text-center text-xs font-medium"
>
{day}
</div>
@@ -163,15 +168,15 @@ export default async function CourseCalendarPage({ params }: PageProps) {
cell.day === null
? 'bg-transparent'
: cell.hasCourse
? 'bg-emerald-500/15 text-emerald-700 dark:text-emerald-400 font-semibold'
? 'bg-emerald-500/15 font-semibold text-emerald-700 dark:text-emerald-400'
: 'bg-muted/30 hover:bg-muted/50'
} ${cell.isToday ? 'ring-2 ring-primary ring-offset-1' : ''}`}
} ${cell.isToday ? 'ring-primary ring-2 ring-offset-1' : ''}`}
>
{cell.day !== null && (
<>
<span>{cell.day}</span>
{cell.hasCourse && (
<span className="absolute bottom-1 left-1/2 -translate-x-1/2 h-1.5 w-1.5 rounded-full bg-emerald-500" />
<span className="absolute bottom-1 left-1/2 h-1.5 w-1.5 -translate-x-1/2 rounded-full bg-emerald-500" />
)}
</>
)}
@@ -180,17 +185,17 @@ export default async function CourseCalendarPage({ params }: PageProps) {
</div>
{/* Legend */}
<div className="mt-4 flex items-center gap-4 text-xs text-muted-foreground">
<div className="text-muted-foreground mt-4 flex items-center gap-4 text-xs">
<div className="flex items-center gap-1.5">
<span className="inline-block h-3 w-3 rounded-sm bg-emerald-500/15" />
Kurstag
</div>
<div className="flex items-center gap-1.5">
<span className="inline-block h-3 w-3 rounded-sm bg-muted/30" />
<span className="bg-muted/30 inline-block h-3 w-3 rounded-sm" />
Frei
</div>
<div className="flex items-center gap-1.5">
<span className="inline-block h-3 w-3 rounded-sm ring-2 ring-primary" />
<span className="ring-primary inline-block h-3 w-3 rounded-sm ring-2" />
Heute
</div>
</div>
@@ -204,7 +209,7 @@ export default async function CourseCalendarPage({ params }: PageProps) {
</CardHeader>
<CardContent>
{activeCourses.length === 0 ? (
<p className="text-sm text-muted-foreground">
<p className="text-muted-foreground text-sm">
Keine aktiven Kurse in diesem Monat.
</p>
) : (
@@ -221,18 +226,19 @@ export default async function CourseCalendarPage({ params }: PageProps) {
>
{String(course.name)}
</Link>
<p className="text-xs text-muted-foreground">
{course.start_date
? new Date(String(course.start_date)).toLocaleDateString('de-DE')
: '—'}{' '}
{' '}
{course.end_date
? new Date(String(course.end_date)).toLocaleDateString('de-DE')
: '—'}
<p className="text-muted-foreground text-xs">
{formatDate(course.start_date as string)} {' '}
{formatDate(course.end_date as string)}
</p>
</div>
<Badge variant={String(course.status) === 'running' ? 'info' : 'default'}>
{String(course.status) === 'running' ? 'Laufend' : 'Offen'}
<Badge
variant={
String(course.status) === 'running' ? 'info' : 'default'
}
>
{String(course.status) === 'running'
? 'Laufend'
: 'Offen'}
</Badge>
</div>
))}

View File

@@ -1,14 +1,13 @@
import { FolderTree, Plus } from 'lucide-react';
import { createCourseManagementApi } from '@kit/course-management/api';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createCourseManagementApi } from '@kit/course-management/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { AccountNotFound } from '~/components/account-not-found';
interface PageProps {
params: Promise<{ account: string }>;
@@ -56,17 +55,24 @@ export default async function CategoriesPage({ params }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Name</th>
<th className="p-3 text-left font-medium">Beschreibung</th>
<th className="p-3 text-left font-medium">Übergeordnet</th>
<th className="p-3 text-left font-medium">
Beschreibung
</th>
<th className="p-3 text-left font-medium">
Übergeordnet
</th>
</tr>
</thead>
<tbody>
{categories.map((cat: Record<string, unknown>) => (
<tr key={String(cat.id)} className="border-b hover:bg-muted/30">
<tr
key={String(cat.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">{String(cat.name)}</td>
<td className="p-3 text-muted-foreground">
<td className="text-muted-foreground p-3">
{String(cat.description ?? '—')}
</td>
<td className="p-3">{String(cat.parent_id ?? '—')}</td>

View File

@@ -1,14 +1,13 @@
import { GraduationCap, Plus } from 'lucide-react';
import { createCourseManagementApi } from '@kit/course-management/api';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createCourseManagementApi } from '@kit/course-management/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { AccountNotFound } from '~/components/account-not-found';
interface PageProps {
params: Promise<{ account: string }>;
@@ -56,23 +55,33 @@ export default async function InstructorsPage({ params }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Name</th>
<th className="p-3 text-left font-medium">E-Mail</th>
<th className="p-3 text-left font-medium">Telefon</th>
<th className="p-3 text-left font-medium">Qualifikation</th>
<th className="p-3 text-right font-medium">Stundensatz</th>
<th className="p-3 text-left font-medium">
Qualifikation
</th>
<th className="p-3 text-right font-medium">
Stundensatz
</th>
</tr>
</thead>
<tbody>
{instructors.map((inst: Record<string, unknown>) => (
<tr key={String(inst.id)} className="border-b hover:bg-muted/30">
<tr
key={String(inst.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">
{String(inst.last_name ?? '')}, {String(inst.first_name ?? '')}
{String(inst.last_name ?? '')},{' '}
{String(inst.first_name ?? '')}
</td>
<td className="p-3">{String(inst.email ?? '—')}</td>
<td className="p-3">{String(inst.phone ?? '—')}</td>
<td className="p-3">{String(inst.qualification ?? '—')}</td>
<td className="p-3">
{String(inst.qualification ?? '—')}
</td>
<td className="p-3 text-right">
{inst.hourly_rate != null
? `${Number(inst.hourly_rate).toFixed(2)}`

View File

@@ -1,14 +1,13 @@
import { MapPin, Plus } from 'lucide-react';
import { createCourseManagementApi } from '@kit/course-management/api';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createCourseManagementApi } from '@kit/course-management/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { AccountNotFound } from '~/components/account-not-found';
interface PageProps {
params: Promise<{ account: string }>;
@@ -33,7 +32,9 @@ export default async function LocationsPage({ params }: PageProps) {
<CmsPageShell account={account} title="Orte">
<div className="flex w-full flex-col gap-6">
<div className="flex items-center justify-between">
<p className="text-muted-foreground">Kurs- und Veranstaltungsorte verwalten</p>
<p className="text-muted-foreground">
Kurs- und Veranstaltungsorte verwalten
</p>
<Button>
<Plus className="mr-2 h-4 w-4" />
Neuer Ort
@@ -56,7 +57,7 @@ export default async function LocationsPage({ params }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Name</th>
<th className="p-3 text-left font-medium">Adresse</th>
<th className="p-3 text-left font-medium">Raum</th>
@@ -65,7 +66,10 @@ export default async function LocationsPage({ params }: PageProps) {
</thead>
<tbody>
{locations.map((loc: Record<string, unknown>) => (
<tr key={String(loc.id)} className="border-b hover:bg-muted/30">
<tr
key={String(loc.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">{String(loc.name)}</td>
<td className="p-3">
{[loc.street, loc.postal_code, loc.city]
@@ -74,7 +78,9 @@ export default async function LocationsPage({ params }: PageProps) {
.join(', ') || '—'}
</td>
<td className="p-3">{String(loc.room ?? '—')}</td>
<td className="p-3 text-right">{String(loc.capacity ?? '—')}</td>
<td className="p-3 text-right">
{String(loc.capacity ?? '—')}
</td>
</tr>
))}
</tbody>

View File

@@ -1,18 +1,29 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CreateCourseForm } from '@kit/course-management/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
interface Props { params: Promise<{ account: string }> }
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
}
export default async function NewCoursePage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
return (
<CmsPageShell account={account} title="Neuer Kurs" description="Kurs anlegen">
<CmsPageShell
account={account}
title="Neuer Kurs"
description="Kurs anlegen"
>
<CreateCourseForm accountId={acct.id} account={account} />
</CmsPageShell>
);

View File

@@ -1,19 +1,30 @@
import Link from 'next/link';
import { ChevronLeft, ChevronRight, GraduationCap, Plus, Users, Calendar, Euro } from 'lucide-react';
import {
ChevronLeft,
ChevronRight,
GraduationCap,
Plus,
Users,
Calendar,
Euro,
} from 'lucide-react';
import { createCourseManagementApi } from '@kit/course-management/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createCourseManagementApi } from '@kit/course-management/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { StatsCard } from '~/components/stats-card';
import { AccountNotFound } from '~/components/account-not-found';
import { COURSE_STATUS_VARIANT, COURSE_STATUS_LABEL } from '~/lib/status-badges';
import {
COURSE_STATUS_VARIANT,
COURSE_STATUS_LABEL,
} from '~/lib/status-badges';
interface PageProps {
params: Promise<{ account: string }>;
@@ -50,9 +61,7 @@ export default async function CoursesPage({ params, searchParams }: PageProps) {
<div className="flex w-full flex-col gap-6">
{/* Header */}
<div className="flex items-center justify-between">
<p className="text-muted-foreground">
Kursangebot verwalten
</p>
<p className="text-muted-foreground">Kursangebot verwalten</p>
<Link href={`/home/${account}/courses/new`}>
<Button>
@@ -104,7 +113,7 @@ export default async function CoursesPage({ params, searchParams }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Kursnr.</th>
<th className="p-3 text-left font-medium">Name</th>
<th className="p-3 text-left font-medium">Beginn</th>
@@ -116,7 +125,10 @@ export default async function CoursesPage({ params, searchParams }: PageProps) {
</thead>
<tbody>
{courses.data.map((course: Record<string, unknown>) => (
<tr key={String(course.id)} className="border-b hover:bg-muted/30">
<tr
key={String(course.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-mono text-xs">
{String(course.course_number ?? '—')}
</td>
@@ -129,20 +141,20 @@ export default async function CoursesPage({ params, searchParams }: PageProps) {
</Link>
</td>
<td className="p-3">
{course.start_date
? new Date(String(course.start_date)).toLocaleDateString('de-DE')
: '—'}
{formatDate(course.start_date as string)}
</td>
<td className="p-3">
{course.end_date
? new Date(String(course.end_date)).toLocaleDateString('de-DE')
: '—'}
{formatDate(course.end_date as string)}
</td>
<td className="p-3">
<Badge
variant={COURSE_STATUS_VARIANT[String(course.status)] ?? 'secondary'}
variant={
COURSE_STATUS_VARIANT[String(course.status)] ??
'secondary'
}
>
{COURSE_STATUS_LABEL[String(course.status)] ?? String(course.status)}
{COURSE_STATUS_LABEL[String(course.status)] ??
String(course.status)}
</Badge>
</td>
<td className="p-3 text-right">
@@ -164,7 +176,7 @@ export default async function CoursesPage({ params, searchParams }: PageProps) {
{/* Pagination */}
{totalPages > 1 && (
<div className="flex items-center justify-between border-t px-2 py-4">
<p className="text-sm text-muted-foreground">
<p className="text-muted-foreground text-sm">
Seite {page} von {totalPages} ({courses.total} Einträge)
</p>
<div className="flex items-center gap-2">

View File

@@ -1,14 +1,19 @@
import { GraduationCap, Users, Calendar, TrendingUp, BarChart3 } from 'lucide-react';
import {
GraduationCap,
Users,
Calendar,
TrendingUp,
BarChart3,
} from 'lucide-react';
import { createCourseManagementApi } from '@kit/course-management/api';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createCourseManagementApi } from '@kit/course-management/api';
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';
import { AccountNotFound } from '~/components/account-not-found';
interface PageProps {
params: Promise<{ account: string }>;
@@ -18,7 +23,11 @@ export default async function CourseStatisticsPage({ params }: PageProps) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
const api = createCourseManagementApi(client);
@@ -34,10 +43,26 @@ export default async function CourseStatisticsPage({ params }: PageProps) {
<CmsPageShell account={account} title="Kurs-Statistiken">
<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="Kurse gesamt" value={stats.totalCourses} icon={<GraduationCap className="h-5 w-5" />} />
<StatsCard title="Aktive Kurse" value={stats.openCourses} icon={<Calendar className="h-5 w-5" />} />
<StatsCard title="Teilnehmer" value={stats.totalParticipants} icon={<Users className="h-5 w-5" />} />
<StatsCard title="Abgeschlossen" value={stats.completedCourses} icon={<TrendingUp className="h-5 w-5" />} />
<StatsCard
title="Kurse gesamt"
value={stats.totalCourses}
icon={<GraduationCap className="h-5 w-5" />}
/>
<StatsCard
title="Aktive Kurse"
value={stats.openCourses}
icon={<Calendar className="h-5 w-5" />}
/>
<StatsCard
title="Teilnehmer"
value={stats.totalParticipants}
icon={<Users className="h-5 w-5" />}
/>
<StatsCard
title="Abgeschlossen"
value={stats.completedCourses}
icon={<TrendingUp className="h-5 w-5" />}
/>
</div>
<div className="grid grid-cols-1 gap-6 lg:grid-cols-2">

View File

@@ -73,7 +73,7 @@ export function GenerateDocumentForm({ accountSlug, initialType }: Props) {
setSelectedType(e.target.value);
setResult(null);
}}
className="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2"
className="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none"
>
<option value="member-card">Mitgliedsausweis</option>
<option value="invoice">Rechnung</option>
@@ -92,7 +92,8 @@ export function GenerateDocumentForm({ accountSlug, initialType }: Props) {
<p className="font-medium">Demnächst verfügbar</p>
<p className="mt-1 text-amber-700 dark:text-amber-300">
Die Generierung von &ldquo;{DOCUMENT_LABELS[selectedType]}&rdquo;
befindet sich noch in Entwicklung und wird in Kürze verfügbar sein.
befindet sich noch in Entwicklung und wird in Kürze verfügbar
sein.
</p>
</div>
</div>
@@ -118,7 +119,7 @@ export function GenerateDocumentForm({ accountSlug, initialType }: Props) {
id="format"
name="format"
disabled={isPending}
className="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:opacity-50"
className="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:opacity-50"
>
<option value="A4">A4</option>
<option value="A5">A5</option>
@@ -131,7 +132,7 @@ export function GenerateDocumentForm({ accountSlug, initialType }: Props) {
id="orientation"
name="orientation"
disabled={isPending}
className="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:opacity-50"
className="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:opacity-50"
>
<option value="portrait">Hochformat</option>
<option value="landscape">Querformat</option>
@@ -140,7 +141,7 @@ export function GenerateDocumentForm({ accountSlug, initialType }: Props) {
</div>
{/* Hint */}
<div className="text-muted-foreground rounded-md bg-muted/50 p-4 text-sm">
<div className="text-muted-foreground bg-muted/50 rounded-md p-4 text-sm">
<p>
<strong>Hinweis:</strong>{' '}
{selectedType === 'member-card'
@@ -211,11 +212,7 @@ export function GenerateDocumentForm({ accountSlug, initialType }: Props) {
* Trigger a browser download from a base64 string.
* Uses an anchor element with the download attribute set to the full filename.
*/
function downloadFile(
base64Data: string,
mimeType: string,
fileName: string,
) {
function downloadFile(base64Data: string, mimeType: string, fileName: string) {
const byteCharacters = atob(base64Data);
const byteNumbers = new Array(byteCharacters.length);
for (let i = 0; i < byteCharacters.length; i++) {

View File

@@ -2,8 +2,10 @@
import React from 'react';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createDocumentGeneratorApi } from '@kit/document-generator/api';
import { formatDate } from '@kit/shared/dates';
import { getLogger } from '@kit/shared/logger';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
export type GenerateDocumentInput = {
accountSlug: string;
@@ -55,7 +57,11 @@ export async function generateDocumentAction(
return { success: false, error: 'Unbekannter Dokumenttyp.' };
}
} catch (err) {
console.error('Document generation error:', err);
const logger = await getLogger();
logger.error(
{ error: err, context: 'document-generation' },
'Document generation error',
);
return {
success: false,
error: err instanceof Error ? err.message : 'Unbekannter Fehler.',
@@ -73,8 +79,7 @@ const LABELS: Record<string, string> = {
};
function fmtDate(d: string | null): string {
if (!d) return '';
try { return new Date(d).toLocaleDateString('de-DE'); } catch { return d; }
return formatDate(d);
}
// ═══════════════════════════════════════════════════════════════════════════
@@ -88,16 +93,28 @@ async function generateMemberCards(
): Promise<GenerateDocumentResult> {
const { data: members, error } = await client
.from('members')
.select('id, member_number, first_name, last_name, entry_date, status, date_of_birth, street, house_number, postal_code, city, email')
.select(
'id, member_number, first_name, last_name, entry_date, status, date_of_birth, street, house_number, postal_code, city, email',
)
.eq('account_id', accountId)
.eq('status', 'active')
.order('last_name');
if (error) return { success: false, error: `DB-Fehler: ${error.message}` };
if (!members?.length) return { success: false, error: 'Keine aktiven Mitglieder.' };
if (!members?.length)
return { success: false, error: 'Keine aktiven Mitglieder.' };
const { Document, Page, View, Text, StyleSheet, renderToBuffer, Svg, Rect, Circle } =
await import('@react-pdf/renderer');
const {
Document,
Page,
View,
Text,
StyleSheet,
renderToBuffer,
Svg,
Rect,
Circle,
} = await import('@react-pdf/renderer');
// — Brand colors (configurable later via account settings) —
const PRIMARY = '#1e40af';
@@ -107,7 +124,13 @@ async function generateMemberCards(
const LIGHT_GRAY = '#f1f5f9';
const s = StyleSheet.create({
page: { padding: 24, flexDirection: 'row', flexWrap: 'wrap', gap: 16, fontFamily: 'Helvetica' },
page: {
padding: 24,
flexDirection: 'row',
flexWrap: 'wrap',
gap: 16,
fontFamily: 'Helvetica',
},
// ── Card shell ──
card: {
@@ -138,10 +161,22 @@ async function generateMemberCards(
paddingHorizontal: 6,
paddingVertical: 2,
},
badgeText: { fontSize: 6, color: PRIMARY, fontFamily: 'Helvetica-Bold', textTransform: 'uppercase' as const, letterSpacing: 0.8 },
badgeText: {
fontSize: 6,
color: PRIMARY,
fontFamily: 'Helvetica-Bold',
textTransform: 'uppercase' as const,
letterSpacing: 0.8,
},
// ── Main content ──
body: { flexDirection: 'row', paddingHorizontal: 14, paddingTop: 8, gap: 12, flex: 1 },
body: {
flexDirection: 'row',
paddingHorizontal: 14,
paddingTop: 8,
gap: 12,
flex: 1,
},
// Photo column
photoCol: { width: 64, alignItems: 'center' },
@@ -165,11 +200,22 @@ async function generateMemberCards(
// Info column
infoCol: { flex: 1, justifyContent: 'center' },
memberName: { fontSize: 14, fontFamily: 'Helvetica-Bold', color: DARK, marginBottom: 6 },
memberName: {
fontSize: 14,
fontFamily: 'Helvetica-Bold',
color: DARK,
marginBottom: 6,
},
fieldGroup: { flexDirection: 'row', flexWrap: 'wrap', gap: 4 },
field: { width: '48%', marginBottom: 5 },
fieldLabel: { fontSize: 6, color: GRAY, textTransform: 'uppercase' as const, letterSpacing: 0.6, marginBottom: 1 },
fieldLabel: {
fontSize: 6,
color: GRAY,
textTransform: 'uppercase' as const,
letterSpacing: 0.6,
marginBottom: 1,
},
fieldValue: { fontSize: 8, color: DARK, fontFamily: 'Helvetica-Bold' },
// ── Footer ──
@@ -184,10 +230,16 @@ async function generateMemberCards(
},
footerLeft: { fontSize: 6, color: GRAY },
footerRight: { fontSize: 6, color: GRAY },
validDot: { width: 5, height: 5, borderRadius: 2.5, backgroundColor: '#22c55e', marginRight: 3 },
validDot: {
width: 5,
height: 5,
borderRadius: 2.5,
backgroundColor: '#22c55e',
marginRight: 3,
},
});
const today = new Date().toLocaleDateString('de-DE');
const today = formatDate(new Date());
const year = new Date().getFullYear();
const cardsPerPage = 4;
const pages: React.ReactElement[] = [];
@@ -198,51 +250,118 @@ async function generateMemberCards(
pages.push(
React.createElement(
Page,
{ key: `p${i}`, size: input.format === 'letter' ? 'LETTER' : (input.format.toUpperCase() as 'A4'|'A5'), orientation: input.orientation, style: s.page },
{
key: `p${i}`,
size:
input.format === 'letter'
? 'LETTER'
: (input.format.toUpperCase() as 'A4' | 'A5'),
orientation: input.orientation,
style: s.page,
},
...batch.map((m) =>
React.createElement(View, { key: m.id, style: s.card },
React.createElement(
View,
{ key: m.id, style: s.card },
// Accent bar
React.createElement(View, { style: s.accentBar }),
// Header
React.createElement(View, { style: s.header },
React.createElement(
View,
{ style: s.header },
React.createElement(Text, { style: s.clubName }, accountName),
React.createElement(View, { style: s.badge },
React.createElement(Text, { style: s.badgeText }, 'Mitgliedsausweis'),
React.createElement(
View,
{ style: s.badge },
React.createElement(
Text,
{ style: s.badgeText },
'Mitgliedsausweis',
),
),
),
// Body: photo + info
React.createElement(View, { style: s.body },
React.createElement(
View,
{ style: s.body },
// Photo column
React.createElement(View, { style: s.photoCol },
React.createElement(View, { style: s.photoFrame },
React.createElement(
View,
{ style: s.photoCol },
React.createElement(
View,
{ style: s.photoFrame },
React.createElement(Text, { style: s.photoIcon }, '👤'),
),
React.createElement(Text, { style: s.memberNumber }, `Nr. ${m.member_number ?? ''}`),
React.createElement(
Text,
{ style: s.memberNumber },
`Nr. ${m.member_number ?? ''}`,
),
),
// Info column
React.createElement(View, { style: s.infoCol },
React.createElement(Text, { style: s.memberName }, `${m.first_name} ${m.last_name}`),
React.createElement(View, { style: s.fieldGroup },
React.createElement(
View,
{ style: s.infoCol },
React.createElement(
Text,
{ style: s.memberName },
`${m.first_name} ${m.last_name}`,
),
React.createElement(
View,
{ style: s.fieldGroup },
// Entry date
React.createElement(View, { style: s.field },
React.createElement(Text, { style: s.fieldLabel }, 'Mitglied seit'),
React.createElement(Text, { style: s.fieldValue }, fmtDate(m.entry_date)),
React.createElement(
View,
{ style: s.field },
React.createElement(
Text,
{ style: s.fieldLabel },
'Mitglied seit',
),
React.createElement(
Text,
{ style: s.fieldValue },
fmtDate(m.entry_date),
),
),
// Date of birth
React.createElement(View, { style: s.field },
React.createElement(Text, { style: s.fieldLabel }, 'Geb.-Datum'),
React.createElement(Text, { style: s.fieldValue }, fmtDate(m.date_of_birth)),
React.createElement(
View,
{ style: s.field },
React.createElement(
Text,
{ style: s.fieldLabel },
'Geb.-Datum',
),
React.createElement(
Text,
{ style: s.fieldValue },
fmtDate(m.date_of_birth),
),
),
// Address
React.createElement(View, { style: { ...s.field, width: '100%' } },
React.createElement(Text, { style: s.fieldLabel }, 'Adresse'),
React.createElement(Text, { style: s.fieldValue },
[m.street, m.house_number].filter(Boolean).join(' ') || '',
React.createElement(
View,
{ style: { ...s.field, width: '100%' } },
React.createElement(
Text,
{ style: s.fieldLabel },
'Adresse',
),
React.createElement(Text, { style: { ...s.fieldValue, marginTop: 1 } },
React.createElement(
Text,
{ style: s.fieldValue },
[m.street, m.house_number].filter(Boolean).join(' ') ||
'',
),
React.createElement(
Text,
{ style: { ...s.fieldValue, marginTop: 1 } },
[m.postal_code, m.city].filter(Boolean).join(' ') || '',
),
),
@@ -251,12 +370,24 @@ async function generateMemberCards(
),
// Footer
React.createElement(View, { style: s.footer },
React.createElement(View, { style: { flexDirection: 'row', alignItems: 'center' } },
React.createElement(
View,
{ style: s.footer },
React.createElement(
View,
{ style: { flexDirection: 'row', alignItems: 'center' } },
React.createElement(View, { style: s.validDot }),
React.createElement(Text, { style: s.footerLeft }, `Gültig ${year}/${year + 1}`),
React.createElement(
Text,
{ style: s.footerLeft },
`Gültig ${year}/${year + 1}`,
),
),
React.createElement(
Text,
{ style: s.footerRight },
`Ausgestellt ${today}`,
),
React.createElement(Text, { style: s.footerRight }, `Ausgestellt ${today}`),
),
),
),
@@ -285,17 +416,22 @@ async function generateLabels(
): Promise<GenerateDocumentResult> {
const { data: members, error } = await client
.from('members')
.select('first_name, last_name, street, house_number, postal_code, city, salutation, title')
.select(
'first_name, last_name, street, house_number, postal_code, city, salutation, title',
)
.eq('account_id', accountId)
.eq('status', 'active')
.order('last_name');
if (error) return { success: false, error: `DB-Fehler: ${error.message}` };
if (!members?.length) return { success: false, error: 'Keine aktiven Mitglieder.' };
if (!members?.length)
return { success: false, error: 'Keine aktiven Mitglieder.' };
const api = createDocumentGeneratorApi();
const records = members.map((m) => ({
line1: [m.salutation, m.title, m.first_name, m.last_name].filter(Boolean).join(' '),
line1: [m.salutation, m.title, m.first_name, m.last_name]
.filter(Boolean)
.join(' '),
line2: [m.street, m.house_number].filter(Boolean).join(' ') || undefined,
line3: [m.postal_code, m.city].filter(Boolean).join(' ') || undefined,
}));
@@ -320,7 +456,9 @@ async function generateMemberReport(
): Promise<GenerateDocumentResult> {
const { data: members, error } = await client
.from('members')
.select('member_number, last_name, first_name, email, postal_code, city, status, entry_date')
.select(
'member_number, last_name, first_name, email, postal_code, city, status, entry_date',
)
.eq('account_id', accountId)
.order('last_name');
@@ -346,11 +484,21 @@ async function generateMemberReport(
const hdr = ws.getRow(1);
hdr.font = { bold: true, color: { argb: 'FFFFFFFF' } };
hdr.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF1E40AF' } };
hdr.fill = {
type: 'pattern',
pattern: 'solid',
fgColor: { argb: 'FF1E40AF' },
};
hdr.alignment = { vertical: 'middle', horizontal: 'center' };
hdr.height = 24;
const SL: Record<string, string> = { active: 'Aktiv', inactive: 'Inaktiv', pending: 'Ausstehend', resigned: 'Ausgetreten', excluded: 'Ausgeschlossen' };
const SL: Record<string, string> = {
active: 'Aktiv',
inactive: 'Inaktiv',
pending: 'Ausstehend',
resigned: 'Ausgetreten',
excluded: 'Ausgeschlossen',
};
for (const m of members) {
ws.addRow({
@@ -361,12 +509,17 @@ async function generateMemberReport(
plz: m.postal_code ?? '',
ort: m.city ?? '',
status: SL[m.status] ?? m.status,
eintritt: m.entry_date ? new Date(m.entry_date).toLocaleDateString('de-DE') : '',
eintritt: m.entry_date ? formatDate(m.entry_date) : '',
});
}
ws.eachRow((row, n) => {
if (n > 1 && n % 2 === 0) row.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFF1F5F9' } };
if (n > 1 && n % 2 === 0)
row.fill = {
type: 'pattern',
pattern: 'solid',
fgColor: { argb: 'FFF1F5F9' },
};
row.border = { bottom: { style: 'thin', color: { argb: 'FFE2E8F0' } } };
});
@@ -379,7 +532,8 @@ async function generateMemberReport(
return {
success: true,
data: Buffer.from(buf as ArrayBuffer).toString('base64'),
mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
mimeType:
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
fileName: `${input.title || 'Mitgliederbericht'}.xlsx`,
};
}

View File

@@ -13,10 +13,10 @@ import {
CardTitle,
} from '@kit/ui/card';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { GenerateDocumentForm } from '../_components/generate-document-form';
import { AccountNotFound } from '~/components/account-not-found';
interface PageProps {
params: Promise<{ account: string }>;

View File

@@ -13,8 +13,8 @@ import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
params: Promise<{ account: string }>;
@@ -40,32 +40,28 @@ const DOCUMENT_TYPES = [
{
id: 'labels',
title: 'Etiketten',
description:
'Adressetiketten für Serienbriefe im Avery-Format drucken.',
description: 'Adressetiketten für Serienbriefe im Avery-Format drucken.',
icon: Tag,
color: 'text-orange-600 bg-orange-50',
},
{
id: 'report',
title: 'Bericht',
description:
'Statistische Auswertungen und Berichte als PDF oder Excel.',
description: 'Statistische Auswertungen und Berichte als PDF oder Excel.',
icon: BarChart3,
color: 'text-purple-600 bg-purple-50',
},
{
id: 'letter',
title: 'Brief',
description:
'Serienbriefe mit personalisierten Platzhaltern erstellen.',
description: 'Serienbriefe mit personalisierten Platzhaltern erstellen.',
icon: Mail,
color: 'text-rose-600 bg-rose-50',
},
{
id: 'certificate',
title: 'Zertifikat',
description:
'Teilnahmebescheinigungen und Zertifikate mit Unterschrift.',
description: 'Teilnahmebescheinigungen und Zertifikate mit Unterschrift.',
icon: Award,
color: 'text-amber-600 bg-amber-50',
},
@@ -84,7 +80,11 @@ export default async function DocumentsPage({ params }: PageProps) {
if (!acct) return <AccountNotFound />;
return (
<CmsPageShell account={account} title="Dokumente" description="Dokumente erstellen und verwalten">
<CmsPageShell
account={account}
title="Dokumente"
description="Dokumente erstellen und verwalten"
>
<div className="flex w-full flex-col gap-6">
{/* Actions */}
<div className="flex items-center justify-end">
@@ -108,7 +108,7 @@ export default async function DocumentsPage({ params }: PageProps) {
</div>
</CardHeader>
<CardContent className="flex flex-1 flex-col justify-between gap-4">
<p className="text-sm text-muted-foreground">
<p className="text-muted-foreground text-sm">
{docType.description}
</p>
<Link

View File

@@ -6,9 +6,9 @@ import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { AccountNotFound } from '~/components/account-not-found';
interface PageProps {
params: Promise<{ account: string }>;
@@ -69,7 +69,7 @@ export default async function DocumentTemplatesPage({ params }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Name</th>
<th className="p-3 text-left font-medium">Typ</th>
<th className="p-3 text-left font-medium">
@@ -81,11 +81,11 @@ export default async function DocumentTemplatesPage({ params }: PageProps) {
{templates.map((template) => (
<tr
key={template.id}
className="border-b hover:bg-muted/30"
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">{template.name}</td>
<td className="p-3">{template.type}</td>
<td className="p-3 text-muted-foreground">
<td className="text-muted-foreground p-3">
{template.description}
</td>
</tr>

View File

@@ -9,13 +9,13 @@ import {
UserPlus,
} from 'lucide-react';
import { createEventManagementApi } from '@kit/event-management/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createEventManagementApi } from '@kit/event-management/api';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
@@ -32,7 +32,10 @@ const STATUS_LABEL: Record<string, string> = {
completed: 'Abgeschlossen',
};
const STATUS_VARIANT: Record<string, 'secondary' | 'default' | 'info' | 'outline' | 'destructive'> = {
const STATUS_VARIANT: Record<
string,
'secondary' | 'default' | 'info' | 'outline' | 'destructive'
> = {
draft: 'secondary',
published: 'default',
registration_open: 'info',
@@ -62,7 +65,10 @@ export default async function EventDetailPage({ params }: PageProps) {
<div className="flex items-center justify-between">
<div>
<h1 className="text-2xl font-bold">{String(e.name)}</h1>
<Badge variant={STATUS_VARIANT[String(e.status)] ?? 'secondary'} className="mt-1">
<Badge
variant={STATUS_VARIANT[String(e.status)] ?? 'secondary'}
className="mt-1"
>
{STATUS_LABEL[String(e.status)] ?? String(e.status)}
</Badge>
</div>
@@ -76,22 +82,20 @@ export default async function EventDetailPage({ params }: PageProps) {
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
<Card>
<CardContent className="flex items-center gap-3 p-4">
<CalendarDays className="h-5 w-5 text-primary" />
<CalendarDays className="text-primary h-5 w-5" />
<div>
<p className="text-xs text-muted-foreground">Datum</p>
<p className="text-muted-foreground text-xs">Datum</p>
<p className="font-semibold">
{e.event_date
? new Date(String(e.event_date)).toLocaleDateString('de-DE')
: '—'}
{formatDate(e.event_date as string)}
</p>
</div>
</CardContent>
</Card>
<Card>
<CardContent className="flex items-center gap-3 p-4">
<Clock className="h-5 w-5 text-primary" />
<Clock className="text-primary h-5 w-5" />
<div>
<p className="text-xs text-muted-foreground">Uhrzeit</p>
<p className="text-muted-foreground text-xs">Uhrzeit</p>
<p className="font-semibold">
{String(e.start_time ?? '—')} {String(e.end_time ?? '—')}
</p>
@@ -100,18 +104,18 @@ export default async function EventDetailPage({ params }: PageProps) {
</Card>
<Card>
<CardContent className="flex items-center gap-3 p-4">
<MapPin className="h-5 w-5 text-primary" />
<MapPin className="text-primary h-5 w-5" />
<div>
<p className="text-xs text-muted-foreground">Ort</p>
<p className="text-muted-foreground text-xs">Ort</p>
<p className="font-semibold">{String(e.location ?? '—')}</p>
</div>
</CardContent>
</Card>
<Card>
<CardContent className="flex items-center gap-3 p-4">
<Users className="h-5 w-5 text-primary" />
<Users className="text-primary h-5 w-5" />
<div>
<p className="text-xs text-muted-foreground">Anmeldungen</p>
<p className="text-muted-foreground text-xs">Anmeldungen</p>
<p className="font-semibold">
{registrations.length} / {String(e.capacity ?? '∞')}
</p>
@@ -127,7 +131,7 @@ export default async function EventDetailPage({ params }: PageProps) {
<CardTitle>Beschreibung</CardTitle>
</CardHeader>
<CardContent>
<p className="text-sm text-muted-foreground whitespace-pre-wrap">
<p className="text-muted-foreground text-sm whitespace-pre-wrap">
{String(e.description)}
</p>
</CardContent>
@@ -141,14 +145,14 @@ export default async function EventDetailPage({ params }: PageProps) {
</CardHeader>
<CardContent>
{registrations.length === 0 ? (
<p className="py-6 text-center text-sm text-muted-foreground">
<p className="text-muted-foreground py-6 text-center text-sm">
Noch keine Anmeldungen
</p>
) : (
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Name</th>
<th className="p-3 text-left font-medium">E-Mail</th>
<th className="p-3 text-left font-medium">Elternteil</th>
@@ -157,16 +161,20 @@ export default async function EventDetailPage({ params }: PageProps) {
</thead>
<tbody>
{registrations.map((reg: Record<string, unknown>) => (
<tr key={String(reg.id)} className="border-b hover:bg-muted/30">
<tr
key={String(reg.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">
{String(reg.last_name ?? '')}, {String(reg.first_name ?? '')}
{String(reg.last_name ?? '')},{' '}
{String(reg.first_name ?? '')}
</td>
<td className="p-3">{String(reg.email ?? '—')}</td>
<td className="p-3">{String(reg.parent_name ?? '—')}</td>
<td className="p-3">
{reg.created_at
? new Date(String(reg.created_at)).toLocaleDateString('de-DE')
: '—'}
{String(reg.parent_name ?? '—')}
</td>
<td className="p-3">
{formatDate(reg.created_at as string)}
</td>
</tr>
))}

View File

@@ -1,15 +1,15 @@
import { Ticket, Plus } from 'lucide-react';
import { getTranslations } from 'next-intl/server';
import { createEventManagementApi } from '@kit/event-management/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createEventManagementApi } from '@kit/event-management/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { AccountNotFound } from '~/components/account-not-found';
interface PageProps {
params: Promise<{ account: string }>;
@@ -37,7 +37,9 @@ export default async function HolidayPassesPage({ params }: PageProps) {
<div className="flex items-center justify-between">
<div>
<h1 className="text-2xl font-bold">{t('holidayPasses')}</h1>
<p className="text-muted-foreground">{t('holidayPassesDescription')}</p>
<p className="text-muted-foreground">
{t('holidayPassesDescription')}
</p>
</div>
<Button>
<Plus className="mr-2 h-4 w-4" />
@@ -55,23 +57,34 @@ export default async function HolidayPassesPage({ params }: PageProps) {
) : (
<Card>
<CardHeader>
<CardTitle>{t('allHolidayPasses')} ({passes.length})</CardTitle>
<CardTitle>
{t('allHolidayPasses')} ({passes.length})
</CardTitle>
</CardHeader>
<CardContent>
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">{t('name')}</th>
<th className="p-3 text-left font-medium">{t('year')}</th>
<th className="p-3 text-right font-medium">{t('price')}</th>
<th className="p-3 text-left font-medium">{t('validFrom')}</th>
<th className="p-3 text-left font-medium">{t('validUntil')}</th>
<th className="p-3 text-right font-medium">
{t('price')}
</th>
<th className="p-3 text-left font-medium">
{t('validFrom')}
</th>
<th className="p-3 text-left font-medium">
{t('validUntil')}
</th>
</tr>
</thead>
<tbody>
{passes.map((pass: Record<string, unknown>) => (
<tr key={String(pass.id)} className="border-b hover:bg-muted/30">
<tr
key={String(pass.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">{String(pass.name)}</td>
<td className="p-3">{String(pass.year ?? '—')}</td>
<td className="p-3 text-right">
@@ -80,14 +93,10 @@ export default async function HolidayPassesPage({ params }: PageProps) {
: '—'}
</td>
<td className="p-3">
{pass.valid_from
? new Date(String(pass.valid_from)).toLocaleDateString('de-DE')
: '—'}
{formatDate(pass.valid_from as string)}
</td>
<td className="p-3">
{pass.valid_until
? new Date(String(pass.valid_until)).toLocaleDateString('de-DE')
: '—'}
{formatDate(pass.valid_until as string)}
</td>
</tr>
))}

View File

@@ -1,20 +1,32 @@
import { getTranslations } from 'next-intl/server';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CreateEventForm } from '@kit/event-management/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
interface Props { params: Promise<{ account: string }> }
import { CreateEventForm } from '@kit/event-management/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
}
export default async function NewEventPage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const t = await getTranslations('cms.events');
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
return (
<CmsPageShell account={account} title={t('newEvent')} description={t('newEventDescription')}>
<CmsPageShell
account={account}
title={t('newEvent')}
description={t('newEventDescription')}
>
<CreateEventForm accountId={acct.id} account={account} />
</CmsPageShell>
);

View File

@@ -1,19 +1,26 @@
import Link from 'next/link';
import { CalendarDays, ChevronLeft, ChevronRight, MapPin, Plus, Users } from 'lucide-react';
import {
CalendarDays,
ChevronLeft,
ChevronRight,
MapPin,
Plus,
Users,
} from 'lucide-react';
import { getTranslations } from 'next-intl/server';
import { createEventManagementApi } from '@kit/event-management/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createEventManagementApi } from '@kit/event-management/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { StatsCard } from '~/components/stats-card';
import { AccountNotFound } from '~/components/account-not-found';
import { EVENT_STATUS_VARIANT, EVENT_STATUS_LABEL } from '~/lib/status-badges';
interface PageProps {
@@ -40,14 +47,14 @@ export default async function EventsPage({ params, searchParams }: PageProps) {
const events = await api.listEvents(acct.id, { page });
// Fetch registration counts for all events on this page
const eventIds = events.data.map((e: Record<string, unknown>) => String(e.id));
const eventIds = events.data.map((e: Record<string, unknown>) =>
String(e.id),
);
const registrationCounts = await api.getRegistrationCounts(eventIds);
// Pre-compute stats before rendering
const uniqueLocationCount = new Set(
events.data
.map((e: Record<string, unknown>) => e.location)
.filter(Boolean),
events.data.map((e: Record<string, unknown>) => e.location).filter(Boolean),
).size;
const totalCapacity = events.data.reduce(
@@ -63,9 +70,7 @@ export default async function EventsPage({ params, searchParams }: PageProps) {
<div className="flex items-center justify-between">
<div>
<h1 className="text-2xl font-bold">{t('title')}</h1>
<p className="text-muted-foreground">
{t('description')}
</p>
<p className="text-muted-foreground">{t('description')}</p>
</div>
<Link href={`/home/${account}/events/new`}>
@@ -107,19 +112,31 @@ export default async function EventsPage({ params, searchParams }: PageProps) {
) : (
<Card>
<CardHeader>
<CardTitle>{t('allEvents')} ({events.total})</CardTitle>
<CardTitle>
{t('allEvents')} ({events.total})
</CardTitle>
</CardHeader>
<CardContent>
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">{t('name')}</th>
<th className="p-3 text-left font-medium">{t('eventDate')}</th>
<th className="p-3 text-left font-medium">{t('eventLocation')}</th>
<th className="p-3 text-right font-medium">{t('capacity')}</th>
<th className="p-3 text-left font-medium">{t('status')}</th>
<th className="p-3 text-right font-medium">{t('registrations')}</th>
<th className="p-3 text-left font-medium">
{t('eventDate')}
</th>
<th className="p-3 text-left font-medium">
{t('eventLocation')}
</th>
<th className="p-3 text-right font-medium">
{t('capacity')}
</th>
<th className="p-3 text-left font-medium">
{t('status')}
</th>
<th className="p-3 text-right font-medium">
{t('registrations')}
</th>
</tr>
</thead>
<tbody>
@@ -130,7 +147,7 @@ export default async function EventsPage({ params, searchParams }: PageProps) {
return (
<tr
key={eventId}
className="border-b hover:bg-muted/30"
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">
<Link
@@ -141,9 +158,7 @@ export default async function EventsPage({ params, searchParams }: PageProps) {
</Link>
</td>
<td className="p-3">
{event.event_date
? new Date(String(event.event_date)).toLocaleDateString('de-DE')
: '—'}
{formatDate(event.event_date as string)}
</td>
<td className="p-3">
{String(event.location ?? '—')}
@@ -156,10 +171,12 @@ export default async function EventsPage({ params, searchParams }: PageProps) {
<td className="p-3">
<Badge
variant={
EVENT_STATUS_VARIANT[String(event.status)] ?? 'secondary'
EVENT_STATUS_VARIANT[String(event.status)] ??
'secondary'
}
>
{EVENT_STATUS_LABEL[String(event.status)] ?? String(event.status)}
{EVENT_STATUS_LABEL[String(event.status)] ??
String(event.status)}
</Badge>
</td>
<td className="p-3 text-right font-medium">
@@ -175,12 +192,17 @@ export default async function EventsPage({ params, searchParams }: PageProps) {
{/* Pagination */}
{events.totalPages > 1 && (
<div className="flex items-center justify-between pt-4">
<span className="text-sm text-muted-foreground">
{t('paginationPage', { page: events.page, totalPages: events.totalPages })}
<span className="text-muted-foreground text-sm">
{t('paginationPage', {
page: events.page,
totalPages: events.totalPages,
})}
</span>
<div className="flex gap-2">
{events.page > 1 && (
<Link href={`/home/${account}/events?page=${events.page - 1}`}>
<Link
href={`/home/${account}/events?page=${events.page - 1}`}
>
<Button variant="outline" size="sm">
<ChevronLeft className="mr-1 h-4 w-4" />
{t('paginationPrevious')}
@@ -188,7 +210,9 @@ export default async function EventsPage({ params, searchParams }: PageProps) {
</Link>
)}
{events.page < events.totalPages && (
<Link href={`/home/${account}/events?page=${events.page + 1}`}>
<Link
href={`/home/${account}/events?page=${events.page + 1}`}
>
<Button variant="outline" size="sm">
{t('paginationNext')}
<ChevronRight className="ml-1 h-4 w-4" />

View File

@@ -1,18 +1,18 @@
import Link from 'next/link';
import { CalendarDays, ClipboardList, Users } from 'lucide-react';
import { getTranslations } from 'next-intl/server';
import { createEventManagementApi } from '@kit/event-management/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createEventManagementApi } from '@kit/event-management/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { StatsCard } from '~/components/stats-card';
import { AccountNotFound } from '~/components/account-not-found';
import { EVENT_STATUS_VARIANT, EVENT_STATUS_LABEL } from '~/lib/status-badges';
interface PageProps {
@@ -64,9 +64,7 @@ export default async function EventRegistrationsPage({ params }: PageProps) {
{/* Header */}
<div>
<h1 className="text-2xl font-bold">{t('registrations')}</h1>
<p className="text-muted-foreground">
{t('registrationsOverview')}
</p>
<p className="text-muted-foreground">{t('registrationsOverview')}</p>
</div>
{/* Stats */}
@@ -108,17 +106,25 @@ export default async function EventRegistrationsPage({ params }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">
{t('event')}
</th>
<th className="p-3 text-left font-medium">{t('eventDate')}</th>
<th className="p-3 text-left font-medium">{t('status')}</th>
<th className="p-3 text-right font-medium">{t('capacity')}</th>
<th className="p-3 text-left font-medium">
{t('eventDate')}
</th>
<th className="p-3 text-left font-medium">
{t('status')}
</th>
<th className="p-3 text-right font-medium">
{t('capacity')}
</th>
<th className="p-3 text-right font-medium">
{t('registrations')}
</th>
<th className="p-3 text-right font-medium">{t('utilization')}</th>
<th className="p-3 text-right font-medium">
{t('utilization')}
</th>
</tr>
</thead>
<tbody>
@@ -133,7 +139,7 @@ export default async function EventRegistrationsPage({ params }: PageProps) {
return (
<tr
key={event.id}
className="border-b hover:bg-muted/30"
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">
<Link
@@ -143,17 +149,12 @@ export default async function EventRegistrationsPage({ params }: PageProps) {
{event.name}
</Link>
</td>
<td className="p-3">
{event.eventDate
? new Date(event.eventDate).toLocaleDateString(
'de-DE',
)
: '—'}
</td>
<td className="p-3">{formatDate(event.eventDate)}</td>
<td className="p-3">
<Badge
variant={
EVENT_STATUS_VARIANT[event.status] ?? 'secondary'
EVENT_STATUS_VARIANT[event.status] ??
'secondary'
}
>
{EVENT_STATUS_LABEL[event.status] ?? event.status}

View File

@@ -2,15 +2,15 @@ import Link from 'next/link';
import { ArrowLeft, Send, CheckCircle } from 'lucide-react';
import { createFinanceApi } from '@kit/finance/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createFinanceApi } from '@kit/finance/api';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
params: Promise<{ account: string; id: string }>;
@@ -87,7 +87,7 @@ export default async function InvoiceDetailPage({ params }: PageProps) {
<CardContent>
<dl className="grid grid-cols-2 gap-4 sm:grid-cols-4">
<div>
<dt className="text-sm font-medium text-muted-foreground">
<dt className="text-muted-foreground text-sm font-medium">
Empfänger
</dt>
<dd className="mt-1 text-sm font-semibold">
@@ -95,31 +95,23 @@ export default async function InvoiceDetailPage({ params }: PageProps) {
</dd>
</div>
<div>
<dt className="text-sm font-medium text-muted-foreground">
<dt className="text-muted-foreground text-sm font-medium">
Rechnungsdatum
</dt>
<dd className="mt-1 text-sm font-semibold">
{invoice.issue_date
? new Date(
String(invoice.issue_date),
).toLocaleDateString('de-DE')
: '—'}
{formatDate(invoice.issue_date)}
</dd>
</div>
<div>
<dt className="text-sm font-medium text-muted-foreground">
<dt className="text-muted-foreground text-sm font-medium">
Fälligkeitsdatum
</dt>
<dd className="mt-1 text-sm font-semibold">
{invoice.due_date
? new Date(String(invoice.due_date)).toLocaleDateString(
'de-DE',
)
: '—'}
{formatDate(invoice.due_date)}
</dd>
</div>
<div>
<dt className="text-sm font-medium text-muted-foreground">
<dt className="text-muted-foreground text-sm font-medium">
Gesamtbetrag
</dt>
<dd className="mt-1 text-sm font-semibold">
@@ -155,14 +147,14 @@ export default async function InvoiceDetailPage({ params }: PageProps) {
</CardHeader>
<CardContent>
{items.length === 0 ? (
<p className="py-8 text-center text-sm text-muted-foreground">
<p className="text-muted-foreground py-8 text-center text-sm">
Keine Positionen vorhanden.
</p>
) : (
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">
Beschreibung
</th>
@@ -177,7 +169,7 @@ export default async function InvoiceDetailPage({ params }: PageProps) {
{items.map((item) => (
<tr
key={String(item.id)}
className="border-b hover:bg-muted/30"
className="hover:bg-muted/30 border-b"
>
<td className="p-3">
{String(item.description ?? '—')}
@@ -199,7 +191,7 @@ export default async function InvoiceDetailPage({ params }: PageProps) {
))}
</tbody>
<tfoot>
<tr className="border-t bg-muted/30">
<tr className="bg-muted/30 border-t">
<td colSpan={3} className="p-3 text-right font-medium">
Zwischensumme
</td>

View File

@@ -1,18 +1,29 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CreateInvoiceForm } from '@kit/finance/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
interface Props { params: Promise<{ account: string }> }
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
}
export default async function NewInvoicePage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
return (
<CmsPageShell account={account} title="Neue Rechnung" description="Rechnung mit Positionen erstellen">
<CmsPageShell
account={account}
title="Neue Rechnung"
description="Rechnung mit Positionen erstellen"
>
<CreateInvoiceForm accountId={acct.id} account={account} />
</CmsPageShell>
);

View File

@@ -2,16 +2,16 @@ import Link from 'next/link';
import { FileText, Plus } from 'lucide-react';
import { createFinanceApi } from '@kit/finance/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createFinanceApi } from '@kit/finance/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { AccountNotFound } from '~/components/account-not-found';
import {
INVOICE_STATUS_VARIANT,
INVOICE_STATUS_LABEL,
@@ -77,7 +77,7 @@ export default async function InvoicesPage({ params }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Nr.</th>
<th className="p-3 text-left font-medium">Empfänger</th>
<th className="p-3 text-left font-medium">Datum</th>
@@ -92,7 +92,7 @@ export default async function InvoicesPage({ params }: PageProps) {
return (
<tr
key={String(invoice.id)}
className="border-b hover:bg-muted/30"
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-mono text-xs">
<Link
@@ -106,18 +106,10 @@ export default async function InvoicesPage({ params }: PageProps) {
{String(invoice.recipient_name ?? '—')}
</td>
<td className="p-3">
{invoice.issue_date
? new Date(
String(invoice.issue_date),
).toLocaleDateString('de-DE')
: '—'}
{formatDate(invoice.issue_date)}
</td>
<td className="p-3">
{invoice.due_date
? new Date(
String(invoice.due_date),
).toLocaleDateString('de-DE')
: '—'}
{formatDate(invoice.due_date)}
</td>
<td className="p-3 text-right">
{invoice.total_amount != null

View File

@@ -2,17 +2,17 @@ import Link from 'next/link';
import { Landmark, FileText, Euro, ArrowRight, Plus } from 'lucide-react';
import { createFinanceApi } from '@kit/finance/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createFinanceApi } from '@kit/finance/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { StatsCard } from '~/components/stats-card';
import { AccountNotFound } from '~/components/account-not-found';
import {
BATCH_STATUS_VARIANT,
BATCH_STATUS_LABEL,
@@ -61,9 +61,7 @@ export default async function FinancePage({ params }: PageProps) {
<div className="flex items-center justify-between">
<div>
<h1 className="text-2xl font-bold">Finanzen</h1>
<p className="text-muted-foreground">
SEPA-Einzüge und Rechnungen
</p>
<p className="text-muted-foreground">SEPA-Einzüge und Rechnungen</p>
</div>
<div className="flex gap-2">
<Link href={`/home/${account}/finance/invoices/new`}>
@@ -124,7 +122,7 @@ export default async function FinancePage({ params }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Status</th>
<th className="p-3 text-left font-medium">Typ</th>
<th className="p-3 text-right font-medium">Betrag</th>
@@ -135,15 +133,17 @@ export default async function FinancePage({ params }: PageProps) {
{batches.map((batch: Record<string, unknown>) => (
<tr
key={String(batch.id)}
className="border-b hover:bg-muted/30"
className="hover:bg-muted/30 border-b"
>
<td className="p-3">
<Badge
variant={
BATCH_STATUS_VARIANT[String(batch.status)] ?? 'secondary'
BATCH_STATUS_VARIANT[String(batch.status)] ??
'secondary'
}
>
{BATCH_STATUS_LABEL[String(batch.status)] ?? String(batch.status)}
{BATCH_STATUS_LABEL[String(batch.status)] ??
String(batch.status)}
</Badge>
</td>
<td className="p-3">
@@ -157,11 +157,7 @@ export default async function FinancePage({ params }: PageProps) {
: '—'}
</td>
<td className="p-3">
{batch.execution_date
? new Date(String(batch.execution_date)).toLocaleDateString('de-DE')
: batch.created_at
? new Date(String(batch.created_at)).toLocaleDateString('de-DE')
: '—'}
{formatDate(batch.execution_date ?? batch.created_at)}
</td>
</tr>
))}
@@ -196,7 +192,7 @@ export default async function FinancePage({ params }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Nr.</th>
<th className="p-3 text-left font-medium">Empfänger</th>
<th className="p-3 text-right font-medium">Betrag</th>
@@ -207,7 +203,7 @@ export default async function FinancePage({ params }: PageProps) {
{invoices.map((invoice: Record<string, unknown>) => (
<tr
key={String(invoice.id)}
className="border-b hover:bg-muted/30"
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-mono text-xs">
<Link

View File

@@ -2,16 +2,15 @@ import Link from 'next/link';
import { Euro, CreditCard, TrendingUp, ArrowRight } from 'lucide-react';
import { createFinanceApi } from '@kit/finance/api';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createFinanceApi } from '@kit/finance/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { StatsCard } from '~/components/stats-card';
import { AccountNotFound } from '~/components/account-not-found';
interface PageProps {
params: Promise<{ account: string }>;
@@ -120,12 +119,14 @@ export default async function PaymentsPage({ params }: PageProps) {
<Card>
<CardHeader className="flex flex-row items-center justify-between">
<CardTitle className="text-base">Offene Rechnungen</CardTitle>
<Badge variant={openInvoices.length > 0 ? 'default' : 'secondary'}>
<Badge
variant={openInvoices.length > 0 ? 'default' : 'secondary'}
>
{openInvoices.length}
</Badge>
</CardHeader>
<CardContent>
<p className="mb-4 text-sm text-muted-foreground">
<p className="text-muted-foreground mb-4 text-sm">
{openInvoices.length > 0
? `${openInvoices.length} Rechnungen mit einem Gesamtbetrag von ${formatCurrency(openTotal)} sind offen.`
: 'Keine offenen Rechnungen vorhanden.'}
@@ -147,7 +148,7 @@ export default async function PaymentsPage({ params }: PageProps) {
</Badge>
</CardHeader>
<CardContent>
<p className="mb-4 text-sm text-muted-foreground">
<p className="text-muted-foreground mb-4 text-sm">
{batches.length > 0
? `${batches.length} SEPA-Einzüge mit einem Gesamtvolumen von ${formatCurrency(sepaTotal)}.`
: 'Keine SEPA-Einzüge vorhanden.'}

View File

@@ -2,15 +2,15 @@ import Link from 'next/link';
import { ArrowLeft, Download } from 'lucide-react';
import { createFinanceApi } from '@kit/finance/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createFinanceApi } from '@kit/finance/api';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
params: Promise<{ account: string; batchId: string }>;
@@ -95,9 +95,7 @@ export default async function SepaBatchDetailPage({ params }: PageProps) {
{/* Summary Card */}
<Card>
<CardHeader className="flex flex-row items-center justify-between">
<CardTitle>
{String(batch.description ?? 'SEPA-Einzug')}
</CardTitle>
<CardTitle>{String(batch.description ?? 'SEPA-Einzug')}</CardTitle>
<Badge variant={STATUS_VARIANT[status] ?? 'secondary'}>
{STATUS_LABEL[status] ?? status}
</Badge>
@@ -105,7 +103,7 @@ export default async function SepaBatchDetailPage({ params }: PageProps) {
<CardContent>
<dl className="grid grid-cols-2 gap-4 sm:grid-cols-4">
<div>
<dt className="text-sm font-medium text-muted-foreground">
<dt className="text-muted-foreground text-sm font-medium">
Typ
</dt>
<dd className="mt-1 text-sm font-semibold">
@@ -115,7 +113,7 @@ export default async function SepaBatchDetailPage({ params }: PageProps) {
</dd>
</div>
<div>
<dt className="text-sm font-medium text-muted-foreground">
<dt className="text-muted-foreground text-sm font-medium">
Betrag
</dt>
<dd className="mt-1 text-sm font-semibold">
@@ -125,7 +123,7 @@ export default async function SepaBatchDetailPage({ params }: PageProps) {
</dd>
</div>
<div>
<dt className="text-sm font-medium text-muted-foreground">
<dt className="text-muted-foreground text-sm font-medium">
Anzahl
</dt>
<dd className="mt-1 text-sm font-semibold">
@@ -133,15 +131,11 @@ export default async function SepaBatchDetailPage({ params }: PageProps) {
</dd>
</div>
<div>
<dt className="text-sm font-medium text-muted-foreground">
<dt className="text-muted-foreground text-sm font-medium">
Ausführungsdatum
</dt>
<dd className="mt-1 text-sm font-semibold">
{batch.execution_date
? new Date(
String(batch.execution_date),
).toLocaleDateString('de-DE')
: '—'}
{formatDate(batch.execution_date)}
</dd>
</div>
</dl>
@@ -162,14 +156,14 @@ export default async function SepaBatchDetailPage({ params }: PageProps) {
</CardHeader>
<CardContent>
{items.length === 0 ? (
<p className="py-8 text-center text-sm text-muted-foreground">
<p className="text-muted-foreground py-8 text-center text-sm">
Keine Positionen vorhanden.
</p>
) : (
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Name</th>
<th className="p-3 text-left font-medium">IBAN</th>
<th className="p-3 text-right font-medium">Betrag</th>
@@ -182,7 +176,7 @@ export default async function SepaBatchDetailPage({ params }: PageProps) {
return (
<tr
key={String(item.id)}
className="border-b hover:bg-muted/30"
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">
{String(item.debtor_name ?? '—')}

View File

@@ -1,8 +1,8 @@
import { CreateSepaBatchForm } from '@kit/finance/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CreateSepaBatchForm } from '@kit/finance/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
@@ -21,7 +21,11 @@ export default async function NewSepaBatchPage({ params }: Props) {
if (!acct) return <AccountNotFound />;
return (
<CmsPageShell account={account} title="Neuer SEPA-Einzug" description="SEPA-Lastschrifteinzug erstellen">
<CmsPageShell
account={account}
title="Neuer SEPA-Einzug"
description="SEPA-Lastschrifteinzug erstellen"
>
<CreateSepaBatchForm accountId={acct.id} account={account} />
</CmsPageShell>
);

View File

@@ -2,20 +2,17 @@ import Link from 'next/link';
import { Landmark, Plus } from 'lucide-react';
import { createFinanceApi } from '@kit/finance/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createFinanceApi } from '@kit/finance/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { AccountNotFound } from '~/components/account-not-found';
import {
BATCH_STATUS_VARIANT,
BATCH_STATUS_LABEL,
} from '~/lib/status-badges';
import { BATCH_STATUS_VARIANT, BATCH_STATUS_LABEL } from '~/lib/status-badges';
interface PageProps {
params: Promise<{ account: string }>;
@@ -79,7 +76,7 @@ export default async function SepaPage({ params }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Status</th>
<th className="p-3 text-left font-medium">Typ</th>
<th className="p-3 text-left font-medium">
@@ -96,12 +93,13 @@ export default async function SepaPage({ params }: PageProps) {
{batches.map((batch: Record<string, unknown>) => (
<tr
key={String(batch.id)}
className="border-b hover:bg-muted/30"
className="hover:bg-muted/30 border-b"
>
<td className="p-3">
<Badge
variant={
BATCH_STATUS_VARIANT[String(batch.status)] ?? 'secondary'
BATCH_STATUS_VARIANT[String(batch.status)] ??
'secondary'
}
>
{BATCH_STATUS_LABEL[String(batch.status)] ??
@@ -130,11 +128,7 @@ export default async function SepaPage({ params }: PageProps) {
{String(batch.item_count ?? 0)}
</td>
<td className="p-3">
{batch.execution_date
? new Date(
String(batch.execution_date),
).toLocaleDateString('de-DE')
: '—'}
{formatDate(batch.execution_date)}
</td>
</tr>
))}

View File

@@ -1,9 +1,12 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createFischereiApi } from '@kit/fischerei/api';
import { FischereiTabNavigation, CatchBooksDataTable } from '@kit/fischerei/components';
import {
FischereiTabNavigation,
CatchBooksDataTable,
} from '@kit/fischerei/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;

View File

@@ -1,16 +1,22 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createFischereiApi } from '@kit/fischerei/api';
import { FischereiTabNavigation, CompetitionsDataTable } from '@kit/fischerei/components';
import {
FischereiTabNavigation,
CompetitionsDataTable,
} from '@kit/fischerei/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}
export default async function CompetitionsPage({ params, searchParams }: Props) {
export default async function CompetitionsPage({
params,
searchParams,
}: Props) {
const { account } = await params;
const search = await searchParams;
const client = getSupabaseServerClient();

View File

@@ -1,13 +1,13 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createFischereiApi } from '@kit/fischerei/api';
import { FischereiTabNavigation } from '@kit/fischerei/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { LEASE_PAYMENT_LABELS } from '@kit/fischerei/lib/fischerei-constants';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { LEASE_PAYMENT_LABELS } from '@kit/fischerei/lib/fischerei-constants';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
@@ -54,7 +54,7 @@ export default async function LeasesPage({ params, searchParams }: Props) {
<h3 className="text-lg font-semibold">
Keine Pachten vorhanden
</h3>
<p className="mt-1 max-w-sm text-sm text-muted-foreground">
<p className="text-muted-foreground mt-1 max-w-sm text-sm">
Erstellen Sie Ihren ersten Pachtvertrag.
</p>
</div>
@@ -62,22 +62,32 @@ export default async function LeasesPage({ params, searchParams }: Props) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Verpächter</th>
<th className="p-3 text-left font-medium">Gewässer</th>
<th className="p-3 text-left font-medium">Beginn</th>
<th className="p-3 text-left font-medium">Ende</th>
<th className="p-3 text-right font-medium">Jahresbetrag ()</th>
<th className="p-3 text-right font-medium">
Jahresbetrag ()
</th>
<th className="p-3 text-left font-medium">Zahlungsart</th>
</tr>
</thead>
<tbody>
{result.data.map((lease: Record<string, unknown>) => {
const waters = lease.waters as Record<string, unknown> | null;
const paymentMethod = String(lease.payment_method ?? 'ueberweisung');
const waters = lease.waters as Record<
string,
unknown
> | null;
const paymentMethod = String(
lease.payment_method ?? 'ueberweisung',
);
return (
<tr key={String(lease.id)} className="border-b hover:bg-muted/30">
<tr
key={String(lease.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">
{String(lease.lessor_name)}
</td>
@@ -85,13 +95,11 @@ export default async function LeasesPage({ params, searchParams }: Props) {
{waters ? String(waters.name) : '—'}
</td>
<td className="p-3">
{lease.start_date
? new Date(String(lease.start_date)).toLocaleDateString('de-DE')
: '—'}
{formatDate(lease.start_date)}
</td>
<td className="p-3">
{lease.end_date
? new Date(String(lease.end_date)).toLocaleDateString('de-DE')
? formatDate(lease.end_date)
: 'unbefristet'}
</td>
<td className="p-3 text-right">
@@ -101,7 +109,8 @@ export default async function LeasesPage({ params, searchParams }: Props) {
</td>
<td className="p-3">
<Badge variant="outline">
{LEASE_PAYMENT_LABELS[paymentMethod] ?? paymentMethod}
{LEASE_PAYMENT_LABELS[paymentMethod] ??
paymentMethod}
</Badge>
</td>
</tr>

View File

@@ -1,9 +1,12 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createFischereiApi } from '@kit/fischerei/api';
import { FischereiTabNavigation, FischereiDashboard } from '@kit/fischerei/components';
import {
FischereiTabNavigation,
FischereiDashboard,
} from '@kit/fischerei/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
params: Promise<{ account: string }>;

View File

@@ -1,10 +1,10 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createFischereiApi } from '@kit/fischerei/api';
import { FischereiTabNavigation } from '@kit/fischerei/components';
import { CmsPageShell } from '~/components/cms-page-shell';
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';
interface Props {
params: Promise<{ account: string }>;
@@ -45,7 +45,7 @@ export default async function PermitsPage({ params }: Props) {
<h3 className="text-lg font-semibold">
Keine Erlaubnisscheine vorhanden
</h3>
<p className="mt-1 max-w-sm text-sm text-muted-foreground">
<p className="text-muted-foreground mt-1 max-w-sm text-sm">
Erstellen Sie Ihren ersten Erlaubnisschein.
</p>
</div>
@@ -53,22 +53,36 @@ export default async function PermitsPage({ params }: Props) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Bezeichnung</th>
<th className="p-3 text-left font-medium">Kurzcode</th>
<th className="p-3 text-left font-medium">Hauptgewässer</th>
<th className="p-3 text-right font-medium">Gesamtmenge</th>
<th className="p-3 text-center font-medium">Zum Verkauf</th>
<th className="p-3 text-left font-medium">
Hauptgewässer
</th>
<th className="p-3 text-right font-medium">
Gesamtmenge
</th>
<th className="p-3 text-center font-medium">
Zum Verkauf
</th>
</tr>
</thead>
<tbody>
{permits.map((permit: Record<string, unknown>) => {
const waters = permit.waters as Record<string, unknown> | null;
const waters = permit.waters as Record<
string,
unknown
> | null;
return (
<tr key={String(permit.id)} className="border-b hover:bg-muted/30">
<td className="p-3 font-medium">{String(permit.name)}</td>
<td className="p-3 text-muted-foreground">
<tr
key={String(permit.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">
{String(permit.name)}
</td>
<td className="text-muted-foreground p-3">
{String(permit.short_code ?? '—')}
</td>
<td className="p-3">

View File

@@ -1,8 +1,11 @@
import {
FischereiTabNavigation,
CreateSpeciesForm,
} from '@kit/fischerei/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { FischereiTabNavigation, CreateSpeciesForm } from '@kit/fischerei/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;

View File

@@ -1,9 +1,12 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createFischereiApi } from '@kit/fischerei/api';
import { FischereiTabNavigation, SpeciesDataTable } from '@kit/fischerei/components';
import {
FischereiTabNavigation,
SpeciesDataTable,
} from '@kit/fischerei/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;

View File

@@ -1,9 +1,9 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { FischereiTabNavigation } from '@kit/fischerei/components';
import { CmsPageShell } from '~/components/cms-page-shell';
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';
interface Props {
params: Promise<{ account: string }>;
@@ -37,9 +37,12 @@ export default async function StatisticsPage({ params }: Props) {
</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>
<p className="mt-1 max-w-sm text-sm text-muted-foreground">
Sobald Fangbücher eingereicht und geprüft werden, erscheinen hier Statistiken und Auswertungen.
<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.
</p>
</div>
</CardContent>

View File

@@ -1,9 +1,12 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createFischereiApi } from '@kit/fischerei/api';
import { FischereiTabNavigation, CreateStockingForm } from '@kit/fischerei/components';
import {
FischereiTabNavigation,
CreateStockingForm,
} from '@kit/fischerei/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;

View File

@@ -1,9 +1,12 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createFischereiApi } from '@kit/fischerei/api';
import { FischereiTabNavigation, StockingDataTable } from '@kit/fischerei/components';
import {
FischereiTabNavigation,
StockingDataTable,
} from '@kit/fischerei/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;

View File

@@ -1,8 +1,11 @@
import {
FischereiTabNavigation,
CreateWaterForm,
} from '@kit/fischerei/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { FischereiTabNavigation, CreateWaterForm } from '@kit/fischerei/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;

View File

@@ -1,9 +1,12 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createFischereiApi } from '@kit/fischerei/api';
import { FischereiTabNavigation, WatersDataTable } from '@kit/fischerei/components';
import {
FischereiTabNavigation,
WatersDataTable,
} from '@kit/fischerei/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;

View File

@@ -70,7 +70,8 @@ function injectAccountFeatureRoutes(
account: string,
features: Record<string, boolean>,
): z.output<typeof NavigationConfigSchema> {
if (!features.fischerei && !features.meetings && !features.verband) return config;
if (!features.fischerei && !features.meetings && !features.verband)
return config;
const featureEntries: Array<{
label: string;

View File

@@ -1,9 +1,12 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createMeetingsApi } from '@kit/sitzungsprotokolle/api';
import { MeetingsTabNavigation, MeetingsDashboard } from '@kit/sitzungsprotokolle/components';
import {
MeetingsTabNavigation,
MeetingsDashboard,
} from '@kit/sitzungsprotokolle/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
params: Promise<{ account: string }>;

View File

@@ -2,18 +2,20 @@ import Link from 'next/link';
import { ArrowLeft } from 'lucide-react';
import { formatDateFull } from '@kit/shared/dates';
import { createMeetingsApi } from '@kit/sitzungsprotokolle/api';
import {
MeetingsTabNavigation,
ProtocolItemsList,
} from '@kit/sitzungsprotokolle/components';
import { MEETING_TYPE_LABELS } from '@kit/sitzungsprotokolle/lib/meetings-constants';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createMeetingsApi } from '@kit/sitzungsprotokolle/api';
import { MeetingsTabNavigation, ProtocolItemsList } from '@kit/sitzungsprotokolle/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { MEETING_TYPE_LABELS } from '@kit/sitzungsprotokolle/lib/meetings-constants';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
params: Promise<{ account: string; protocolId: string }>;
@@ -39,9 +41,12 @@ export default async function ProtocolDetailPage({ params }: PageProps) {
} catch {
return (
<CmsPageShell account={account} title="Sitzungsprotokolle">
<div className="text-center py-12">
<div className="py-12 text-center">
<h2 className="text-lg font-semibold">Protokoll nicht gefunden</h2>
<Link href={`/home/${account}/meetings/protocols`} className="mt-4 inline-block">
<Link
href={`/home/${account}/meetings/protocols`}
className="mt-4 inline-block"
>
<Button variant="outline">Zurück zur Übersicht</Button>
</Link>
</div>
@@ -72,18 +77,12 @@ export default async function ProtocolDetailPage({ params }: PageProps) {
<div className="flex items-start justify-between">
<div>
<CardTitle className="text-xl">{protocol.title}</CardTitle>
<div className="mt-2 flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
<span>
{new Date(protocol.meeting_date).toLocaleDateString('de-DE', {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
})}
</span>
<div className="text-muted-foreground mt-2 flex flex-wrap items-center gap-2 text-sm">
<span>{formatDateFull(protocol.meeting_date)}</span>
<span>·</span>
<Badge variant="secondary">
{MEETING_TYPE_LABELS[protocol.meeting_type] ?? protocol.meeting_type}
{MEETING_TYPE_LABELS[protocol.meeting_type] ??
protocol.meeting_type}
</Badge>
{protocol.is_published ? (
<Badge variant="default">Veröffentlicht</Badge>
@@ -97,20 +96,28 @@ export default async function ProtocolDetailPage({ params }: PageProps) {
<CardContent className="grid grid-cols-1 gap-4 sm:grid-cols-2">
{protocol.location && (
<div>
<p className="text-sm font-medium text-muted-foreground">Ort</p>
<p className="text-muted-foreground text-sm font-medium">Ort</p>
<p className="text-sm">{protocol.location}</p>
</div>
)}
{protocol.attendees && (
<div className="sm:col-span-2">
<p className="text-sm font-medium text-muted-foreground">Teilnehmer</p>
<p className="text-sm whitespace-pre-line">{protocol.attendees}</p>
<p className="text-muted-foreground text-sm font-medium">
Teilnehmer
</p>
<p className="text-sm whitespace-pre-line">
{protocol.attendees}
</p>
</div>
)}
{protocol.remarks && (
<div className="sm:col-span-2">
<p className="text-sm font-medium text-muted-foreground">Anmerkungen</p>
<p className="text-sm whitespace-pre-line">{protocol.remarks}</p>
<p className="text-muted-foreground text-sm font-medium">
Anmerkungen
</p>
<p className="text-sm whitespace-pre-line">
{protocol.remarks}
</p>
</div>
)}
</CardContent>

View File

@@ -1,8 +1,11 @@
import {
MeetingsTabNavigation,
CreateProtocolForm,
} from '@kit/sitzungsprotokolle/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { MeetingsTabNavigation, CreateProtocolForm } from '@kit/sitzungsprotokolle/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
params: Promise<{ account: string }>;

View File

@@ -1,16 +1,22 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createMeetingsApi } from '@kit/sitzungsprotokolle/api';
import { MeetingsTabNavigation, ProtocolsDataTable } from '@kit/sitzungsprotokolle/components';
import {
MeetingsTabNavigation,
ProtocolsDataTable,
} from '@kit/sitzungsprotokolle/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
params: Promise<{ account: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}
export default async function ProtocolsPage({ params, searchParams }: PageProps) {
export default async function ProtocolsPage({
params,
searchParams,
}: PageProps) {
const { account } = await params;
const sp = await searchParams;
const client = getSupabaseServerClient();

View File

@@ -1,9 +1,12 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createMeetingsApi } from '@kit/sitzungsprotokolle/api';
import { MeetingsTabNavigation, OpenTasksView } from '@kit/sitzungsprotokolle/components';
import {
MeetingsTabNavigation,
OpenTasksView,
} from '@kit/sitzungsprotokolle/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
params: Promise<{ account: string }>;
@@ -36,7 +39,8 @@ export default async function TasksPage({ params, searchParams }: PageProps) {
<div>
<h1 className="text-2xl font-bold">Offene Aufgaben</h1>
<p className="text-muted-foreground">
Alle offenen und in Bearbeitung befindlichen Tagesordnungspunkte über alle Protokolle.
Alle offenen und in Bearbeitung befindlichen Tagesordnungspunkte
über alle Protokolle.
</p>
</div>
<OpenTasksView

View File

@@ -1,8 +1,9 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createMemberManagementApi } from '@kit/member-management/api';
import { EditMemberForm } from '@kit/member-management/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string; memberId: string }>;
@@ -11,7 +12,11 @@ interface Props {
export default async function EditMemberPage({ params }: Props) {
const { account, memberId } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
const api = createMemberManagementApi(client);
@@ -19,7 +24,10 @@ export default async function EditMemberPage({ params }: Props) {
if (!member) return <div>Mitglied nicht gefunden</div>;
return (
<CmsPageShell account={account} title={`${String(member.first_name)} ${String(member.last_name)} bearbeiten`}>
<CmsPageShell
account={account}
title={`${String(member.first_name)} ${String(member.last_name)} bearbeiten`}
>
<EditMemberForm member={member} account={account} accountId={acct.id} />
</CmsPageShell>
);

View File

@@ -1,8 +1,9 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createMemberManagementApi } from '@kit/member-management/api';
import { MemberDetailView } from '@kit/member-management/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string; memberId: string }>;
@@ -11,7 +12,11 @@ interface Props {
export default async function MemberDetailPage({ params }: Props) {
const { account, memberId } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
const api = createMemberManagementApi(client);
@@ -19,7 +24,10 @@ export default async function MemberDetailPage({ params }: Props) {
if (!member) return <div>Mitglied nicht gefunden</div>;
return (
<CmsPageShell account={account} title={`${String(member.first_name)} ${String(member.last_name)}`}>
<CmsPageShell
account={account}
title={`${String(member.first_name)} ${String(member.last_name)}`}
>
<MemberDetailView member={member} account={account} accountId={acct.id} />
</CmsPageShell>
);

View File

@@ -1,8 +1,9 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createMemberManagementApi } from '@kit/member-management/api';
import { ApplicationWorkflow } from '@kit/member-management/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
@@ -11,15 +12,27 @@ interface Props {
export default async function ApplicationsPage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
const api = createMemberManagementApi(client);
const applications = await api.listApplications(acct.id);
return (
<CmsPageShell account={account} title="Aufnahmeanträge" description="Mitgliedsanträge bearbeiten">
<ApplicationWorkflow applications={applications} accountId={acct.id} account={account} />
<CmsPageShell
account={account}
title="Aufnahmeanträge"
description="Mitgliedsanträge bearbeiten"
>
<ApplicationWorkflow
applications={applications}
accountId={acct.id}
account={account}
/>
</CmsPageShell>
);
}

View File

@@ -1,9 +1,11 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createMemberManagementApi } from '@kit/member-management/api';
import { CreditCard } from 'lucide-react';
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 { AccountNotFound } from '~/components/account-not-found';
/** All active members are fetched for the card overview. */
const CARDS_PAGE_SIZE = 100;
@@ -15,15 +17,26 @@ interface Props {
export default async function MemberCardsPage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
const api = createMemberManagementApi(client);
const result = await api.listMembers(acct.id, { status: 'active', pageSize: CARDS_PAGE_SIZE });
const result = await api.listMembers(acct.id, {
status: 'active',
pageSize: CARDS_PAGE_SIZE,
});
const members = result.data;
return (
<CmsPageShell account={account} title="Mitgliedsausweise" description="Ausweise erstellen und verwalten">
<CmsPageShell
account={account}
title="Mitgliedsausweise"
description="Ausweise erstellen und verwalten"
>
{members.length === 0 ? (
<EmptyState
icon={<CreditCard className="h-8 w-8" />}

View File

@@ -1,12 +1,14 @@
'use client';
import { useCallback, useState } from 'react';
import { useAction } from 'next-safe-action/hooks';
import { useRouter } from 'next/navigation';
import { toast } from '@kit/ui/sonner';
import { Plus } from 'lucide-react';
import { useAction } from 'next-safe-action/hooks';
import { createDepartment } from '@kit/member-management/actions/member-actions';
import { Button } from '@kit/ui/button';
import { Input } from '@kit/ui/input';
import { Label } from '@kit/ui/label';
import {
Dialog,
DialogContent,
@@ -16,15 +18,17 @@ import {
DialogTitle,
DialogTrigger,
} from '@kit/ui/dialog';
import { Plus } from 'lucide-react';
import { createDepartment } from '@kit/member-management/actions/member-actions';
import { Input } from '@kit/ui/input';
import { Label } from '@kit/ui/label';
import { toast } from '@kit/ui/sonner';
interface CreateDepartmentDialogProps {
accountId: string;
}
export function CreateDepartmentDialog({ accountId }: CreateDepartmentDialogProps) {
export function CreateDepartmentDialog({
accountId,
}: CreateDepartmentDialogProps) {
const router = useRouter();
const [open, setOpen] = useState(false);
const [name, setName] = useState('');
@@ -49,7 +53,11 @@ export function CreateDepartmentDialog({ accountId }: CreateDepartmentDialogProp
(e: React.FormEvent) => {
e.preventDefault();
if (!name.trim()) return;
execute({ accountId, name: name.trim(), description: description.trim() || undefined });
execute({
accountId,
name: name.trim(),
description: description.trim() || undefined,
});
},
[execute, accountId, name, description],
);

View File

@@ -1,9 +1,11 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Users } from 'lucide-react';
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 { Users } from 'lucide-react';
import { AccountNotFound } from '~/components/account-not-found';
import { CreateDepartmentDialog } from './create-department-dialog';
@@ -14,14 +16,22 @@ interface Props {
export default async function DepartmentsPage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
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="Abteilungen" description="Sparten und Abteilungen verwalten">
<CmsPageShell
account={account}
title="Abteilungen"
description="Sparten und Abteilungen verwalten"
>
<div className="space-y-4">
<div className="flex items-center justify-end">
<CreateDepartmentDialog accountId={acct.id} />
@@ -37,16 +47,21 @@ export default async function DepartmentsPage({ params }: Props) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Name</th>
<th className="p-3 text-left font-medium">Beschreibung</th>
</tr>
</thead>
<tbody>
{departments.map((dept: Record<string, unknown>) => (
<tr key={String(dept.id)} className="border-b hover:bg-muted/30">
<tr
key={String(dept.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">{String(dept.name)}</td>
<td className="p-3 text-muted-foreground">{String(dept.description ?? '—')}</td>
<td className="text-muted-foreground p-3">
{String(dept.description ?? '—')}
</td>
</tr>
))}
</tbody>

View File

@@ -1,8 +1,9 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createMemberManagementApi } from '@kit/member-management/api';
import { DuesCategoryManager } from '@kit/member-management/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
@@ -11,14 +12,22 @@ interface Props {
export default async function DuesPage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
const api = createMemberManagementApi(client);
const categories = await api.listDuesCategories(acct.id);
return (
<CmsPageShell account={account} title="Beitragskategorien" description="Mitgliedsbeiträge verwalten">
<CmsPageShell
account={account}
title="Beitragskategorien"
description="Mitgliedsbeiträge verwalten"
>
<DuesCategoryManager categories={categories} accountId={acct.id} />
</CmsPageShell>
);

View File

@@ -1,7 +1,8 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { MemberImportWizard } from '@kit/member-management/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
@@ -10,11 +11,19 @@ interface Props {
export default async function MemberImportPage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
return (
<CmsPageShell account={account} title="Mitglieder importieren" description="CSV-Datei importieren">
<CmsPageShell
account={account}
title="Mitglieder importieren"
description="CSV-Datei importieren"
>
<MemberImportWizard accountId={acct.id} account={account} />
</CmsPageShell>
);

View File

@@ -1,28 +1,43 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createMemberManagementApi } from '@kit/member-management/api';
import { CreateMemberForm } from '@kit/member-management/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
interface Props { params: Promise<{ account: string }> }
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
}
export default async function NewMemberPage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
const api = createMemberManagementApi(client);
const duesCategories = await api.listDuesCategories(acct.id);
return (
<CmsPageShell account={account} title="Neues Mitglied" description="Mitglied manuell anlegen">
<CreateMemberForm
accountId={acct.id}
account={account}
duesCategories={(duesCategories ?? []).map((c: Record<string, unknown>) => ({
id: String(c.id), name: String(c.name), amount: Number(c.amount ?? 0)
}))}
<CmsPageShell
account={account}
title="Neues Mitglied"
description="Mitglied manuell anlegen"
>
<CreateMemberForm
accountId={acct.id}
account={account}
duesCategories={(duesCategories ?? []).map(
(c: Record<string, unknown>) => ({
id: String(c.id),
name: String(c.name),
amount: Number(c.amount ?? 0),
}),
)}
/>
</CmsPageShell>
);

View File

@@ -1,8 +1,9 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createMemberManagementApi } from '@kit/member-management/api';
import { MembersDataTable } from '@kit/member-management/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
const PAGE_SIZE = 25;
@@ -15,7 +16,11 @@ export default async function MembersPage({ params, searchParams }: Props) {
const { account } = await params;
const search = await searchParams;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
const api = createMemberManagementApi(client);
@@ -29,16 +34,23 @@ export default async function MembersPage({ params, searchParams }: Props) {
const duesCategories = await api.listDuesCategories(acct.id);
return (
<CmsPageShell account={account} title="Mitglieder" description={`${result.total} Mitglieder`}>
<CmsPageShell
account={account}
title="Mitglieder"
description={`${result.total} Mitglieder`}
>
<MembersDataTable
data={result.data}
total={result.total}
page={page}
pageSize={PAGE_SIZE}
account={account}
duesCategories={(duesCategories ?? []).map((c: Record<string, unknown>) => ({
id: String(c.id), name: String(c.name),
}))}
duesCategories={(duesCategories ?? []).map(
(c: Record<string, unknown>) => ({
id: String(c.id),
name: String(c.name),
}),
)}
/>
</CmsPageShell>
);

View File

@@ -1,14 +1,20 @@
import { Users, UserCheck, UserMinus, Clock, BarChart3, TrendingUp } from 'lucide-react';
import {
Users,
UserCheck,
UserMinus,
Clock,
BarChart3,
TrendingUp,
} from 'lucide-react';
import { createMemberManagementApi } from '@kit/member-management/api';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createMemberManagementApi } from '@kit/member-management/api';
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';
import { AccountNotFound } from '~/components/account-not-found';
interface PageProps {
params: Promise<{ account: string }>;
@@ -40,10 +46,26 @@ export default async function MemberStatisticsPage({ params }: PageProps) {
<CmsPageShell account={account} title="Mitglieder-Statistiken">
<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="Gesamt" value={stats.total ?? 0} icon={<Users className="h-5 w-5" />} />
<StatsCard title="Aktiv" value={stats.active ?? 0} icon={<UserCheck className="h-5 w-5" />} />
<StatsCard title="Inaktiv" value={stats.inactive ?? 0} icon={<UserMinus className="h-5 w-5" />} />
<StatsCard title="Ausstehend" value={stats.pending ?? 0} icon={<Clock className="h-5 w-5" />} />
<StatsCard
title="Gesamt"
value={stats.total ?? 0}
icon={<Users className="h-5 w-5" />}
/>
<StatsCard
title="Aktiv"
value={stats.active ?? 0}
icon={<UserCheck className="h-5 w-5" />}
/>
<StatsCard
title="Inaktiv"
value={stats.inactive ?? 0}
icon={<UserMinus className="h-5 w-5" />}
/>
<StatsCard
title="Ausstehend"
value={stats.pending ?? 0}
icon={<Clock className="h-5 w-5" />}
/>
</div>
<div className="grid grid-cols-1 gap-6 lg:grid-cols-2">

View File

@@ -1,6 +1,8 @@
import 'server-only';
import { SupabaseClient } from '@supabase/supabase-js';
import { getLogger } from '@kit/shared/logger';
import { loadTeamWorkspace } from '~/home/[account]/_lib/server/team-account-workspace.loader';
import { Database } from '~/lib/database.types';
@@ -49,7 +51,11 @@ async function loadAccountMembers(
});
if (error) {
console.error(error);
const logger = await getLogger();
logger.error(
{ error, context: 'load-account-members' },
'Failed to load account members',
);
throw error;
}
@@ -70,7 +76,11 @@ async function loadInvitations(
});
if (error) {
console.error(error);
const logger = await getLogger();
logger.error(
{ error, context: 'load-invitations' },
'Failed to load account invitations',
);
throw error;
}

View File

@@ -1,12 +1,14 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import Link from 'next/link';
import { Pencil, Trash2, Lock, Unlock } from 'lucide-react';
import { createModuleBuilderApi } from '@kit/module-builder/api';
import { ModuleForm } from '@kit/module-builder/components';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Pencil, Trash2, Lock, Unlock } from 'lucide-react';
import Link from 'next/link';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { CmsPageShell } from '~/components/cms-page-shell';
@@ -14,7 +16,9 @@ interface RecordDetailPageProps {
params: Promise<{ account: string; moduleId: string; recordId: string }>;
}
export default async function RecordDetailPage({ params }: RecordDetailPageProps) {
export default async function RecordDetailPage({
params,
}: RecordDetailPageProps) {
const { account, moduleId, recordId } = await params;
const client = getSupabaseServerClient();
const api = createModuleBuilderApi(client);
@@ -26,29 +30,49 @@ export default async function RecordDetailPage({ params }: RecordDetailPageProps
if (!moduleWithFields || !record) return <div>Nicht gefunden</div>;
const fields = (moduleWithFields as unknown as {
fields: Array<{
name: string; display_name: string; field_type: string;
is_required: boolean; placeholder: string | null;
help_text: string | null; is_readonly: boolean;
select_options: Array<{ label: string; value: string }> | null;
section: string; sort_order: number; show_in_form: boolean; width: string;
}>;
}).fields;
const fields = (
moduleWithFields as unknown as {
fields: Array<{
name: string;
display_name: string;
field_type: string;
is_required: boolean;
placeholder: string | null;
help_text: string | null;
is_readonly: boolean;
select_options: Array<{ label: string; value: string }> | null;
section: string;
sort_order: number;
show_in_form: boolean;
width: string;
}>;
}
).fields;
const data = (record.data ?? {}) as Record<string, unknown>;
const isLocked = record.status === 'locked';
return (
<CmsPageShell account={account} title={`${String(moduleWithFields.display_name)} — Datensatz`}>
<CmsPageShell
account={account}
title={`${String(moduleWithFields.display_name)} — Datensatz`}
>
<div className="space-y-6">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<Badge variant={isLocked ? 'destructive' : record.status === 'active' ? 'default' : 'secondary'}>
<Badge
variant={
isLocked
? 'destructive'
: record.status === 'active'
? 'default'
: 'secondary'
}
>
{String(record.status)}
</Badge>
<span className="text-sm text-muted-foreground">
Erstellt: {new Date(record.created_at).toLocaleDateString('de-DE')}
<span className="text-muted-foreground text-sm">
Erstellt: {formatDate(record.created_at)}
</span>
</div>
<div className="flex gap-2">

View File

@@ -1,9 +1,9 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Upload, ArrowRight, CheckCircle } from 'lucide-react';
import { createModuleBuilderApi } from '@kit/module-builder/api';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Button } from '@kit/ui/button';
import { Upload, ArrowRight, CheckCircle } from 'lucide-react';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { CmsPageShell } from '~/components/cms-page-shell';
@@ -19,22 +19,45 @@ export default async function ImportPage({ params }: ImportPageProps) {
const moduleWithFields = await api.modules.getModuleWithFields(moduleId);
if (!moduleWithFields) return <div>Modul nicht gefunden</div>;
const fields = (moduleWithFields as unknown as { fields: Array<{ name: string; display_name: string }> }).fields ?? [];
const fields =
(
moduleWithFields as unknown as {
fields: Array<{ name: string; display_name: string }>;
}
).fields ?? [];
return (
<CmsPageShell account={account} title={`${String(moduleWithFields.display_name)} — Import`}>
<CmsPageShell
account={account}
title={`${String(moduleWithFields.display_name)} — Import`}
>
<div className="space-y-6">
{/* Step indicator */}
<div className="flex items-center justify-center gap-2">
{['Datei hochladen', 'Spalten zuordnen', 'Vorschau', 'Importieren'].map((step, i) => (
{[
'Datei hochladen',
'Spalten zuordnen',
'Vorschau',
'Importieren',
].map((step, i) => (
<div key={step} className="flex items-center gap-2">
<div className={`flex h-8 w-8 items-center justify-center rounded-full text-xs font-bold ${
i === 0 ? 'bg-primary text-primary-foreground' : 'bg-muted text-muted-foreground'
}`}>
<div
className={`flex h-8 w-8 items-center justify-center rounded-full text-xs font-bold ${
i === 0
? 'bg-primary text-primary-foreground'
: 'bg-muted text-muted-foreground'
}`}
>
{i + 1}
</div>
<span className={`text-sm ${i === 0 ? 'font-semibold' : 'text-muted-foreground'}`}>{step}</span>
{i < 3 && <ArrowRight className="h-4 w-4 text-muted-foreground" />}
<span
className={`text-sm ${i === 0 ? 'font-semibold' : 'text-muted-foreground'}`}
>
{step}
</span>
{i < 3 && (
<ArrowRight className="text-muted-foreground h-4 w-4" />
)}
</div>
))}
</div>
@@ -49,21 +72,30 @@ export default async function ImportPage({ params }: ImportPageProps) {
</CardHeader>
<CardContent>
<div className="flex flex-col items-center justify-center rounded-lg border-2 border-dashed p-12 text-center">
<Upload className="mb-4 h-10 w-10 text-muted-foreground" />
<p className="text-lg font-semibold">CSV oder Excel-Datei hierher ziehen</p>
<p className="mt-1 text-sm text-muted-foreground">oder klicken zum Auswählen</p>
<Upload className="text-muted-foreground mb-4 h-10 w-10" />
<p className="text-lg font-semibold">
CSV oder Excel-Datei hierher ziehen
</p>
<p className="text-muted-foreground mt-1 text-sm">
oder klicken zum Auswählen
</p>
<input
type="file"
accept=".csv,.xlsx,.xls"
className="mt-4 block w-full max-w-xs text-sm text-muted-foreground file:mr-4 file:rounded-md file:border-0 file:bg-primary file:px-4 file:py-2 file:text-sm file:font-semibold file:text-primary-foreground hover:file:bg-primary/90"
className="text-muted-foreground file:bg-primary file:text-primary-foreground hover:file:bg-primary/90 mt-4 block w-full max-w-xs text-sm file:mr-4 file:rounded-md file:border-0 file:px-4 file:py-2 file:text-sm file:font-semibold"
/>
</div>
<div className="mt-6">
<h4 className="text-sm font-semibold mb-2">Verfügbare Zielfelder:</h4>
<h4 className="mb-2 text-sm font-semibold">
Verfügbare Zielfelder:
</h4>
<div className="flex flex-wrap gap-1">
{fields.map((field) => (
<span key={field.name} className="rounded-md bg-muted px-2 py-1 text-xs">
<span
key={field.name}
className="bg-muted rounded-md px-2 py-1 text-xs"
>
{field.display_name}
</span>
))}

View File

@@ -1,7 +1,7 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createModuleBuilderApi } from '@kit/module-builder/api';
import { ModuleForm } from '@kit/module-builder/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CmsPageShell } from '~/components/cms-page-shell';
interface NewRecordPageProps {
@@ -16,18 +16,30 @@ export default async function NewRecordPage({ params }: NewRecordPageProps) {
const moduleWithFields = await api.modules.getModuleWithFields(moduleId);
if (!moduleWithFields) return <div>Modul nicht gefunden</div>;
const fields = (moduleWithFields as unknown as {
fields: Array<{
name: string; display_name: string; field_type: string;
is_required: boolean; placeholder: string | null;
help_text: string | null; is_readonly: boolean;
select_options: Array<{ label: string; value: string }> | null;
section: string; sort_order: number; show_in_form: boolean; width: string;
}>;
}).fields;
const fields = (
moduleWithFields as unknown as {
fields: Array<{
name: string;
display_name: string;
field_type: string;
is_required: boolean;
placeholder: string | null;
help_text: string | null;
is_readonly: boolean;
select_options: Array<{ label: string; value: string }> | null;
section: string;
sort_order: number;
show_in_form: boolean;
width: string;
}>;
}
).fields;
return (
<CmsPageShell account={account} title={`${String(moduleWithFields.display_name)} — Neuer Datensatz`}>
<CmsPageShell
account={account}
title={`${String(moduleWithFields.display_name)} — Neuer Datensatz`}
>
<div className="mx-auto max-w-3xl">
<ModuleForm
fields={fields as Parameters<typeof ModuleForm>[0]['fields']}

View File

@@ -1,13 +1,15 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createModuleBuilderApi } from '@kit/module-builder/api';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
interface ModuleDetailPageProps {
params: Promise<{ account: string; moduleId: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}
export default async function ModuleDetailPage({ params, searchParams }: ModuleDetailPageProps) {
export default async function ModuleDetailPage({
params,
searchParams,
}: ModuleDetailPageProps) {
const { account, moduleId } = await params;
const search = await searchParams;
const client = getSupabaseServerClient();
@@ -20,14 +22,21 @@ export default async function ModuleDetailPage({ params, searchParams }: ModuleD
}
const page = Number(search.page) || 1;
const pageSize = Number(search.pageSize) || moduleWithFields.default_page_size || 25;
const pageSize =
Number(search.pageSize) || moduleWithFields.default_page_size || 25;
const result = await api.query.query({
moduleId,
page,
pageSize,
sortField: (search.sort as string) ?? moduleWithFields.default_sort_field ?? undefined,
sortDirection: (search.dir as 'asc' | 'desc') ?? (moduleWithFields.default_sort_direction as 'asc' | 'desc') ?? 'asc',
sortField:
(search.sort as string) ??
moduleWithFields.default_sort_field ??
undefined,
sortDirection:
(search.dir as 'asc' | 'desc') ??
(moduleWithFields.default_sort_direction as 'asc' | 'desc') ??
'asc',
search: (search.q as string) ?? undefined,
filters: [],
});
@@ -36,20 +45,25 @@ export default async function ModuleDetailPage({ params, searchParams }: ModuleD
<div className="flex flex-col gap-4">
<div className="flex items-center justify-between">
<div>
<h1 className="text-2xl font-bold">{moduleWithFields.display_name}</h1>
<h1 className="text-2xl font-bold">
{moduleWithFields.display_name}
</h1>
{moduleWithFields.description && (
<p className="text-muted-foreground">{moduleWithFields.description}</p>
<p className="text-muted-foreground">
{moduleWithFields.description}
</p>
)}
</div>
</div>
<div className="text-sm text-muted-foreground">
{result.pagination.total} Datensätze Seite {result.pagination.page} von {result.pagination.totalPages}
<div className="text-muted-foreground text-sm">
{result.pagination.total} Datensätze Seite {result.pagination.page}{' '}
von {result.pagination.totalPages}
</div>
{/* Phase 3 will replace this with module-table component */}
<div className="rounded-lg border">
<pre className="p-4 text-xs overflow-auto max-h-96">
<pre className="max-h-96 overflow-auto p-4 text-xs">
{JSON.stringify(result.data, null, 2)}
</pre>
</div>

View File

@@ -1,12 +1,12 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Settings2, List, Shield } from 'lucide-react';
import { createModuleBuilderApi } from '@kit/module-builder/api';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { Input } from '@kit/ui/input';
import { Label } from '@kit/ui/label';
import { Settings2, List, Shield } from 'lucide-react';
import { CmsPageShell } from '~/components/cms-page-shell';
@@ -14,7 +14,9 @@ interface ModuleSettingsPageProps {
params: Promise<{ account: string; moduleId: string }>;
}
export default async function ModuleSettingsPage({ params }: ModuleSettingsPageProps) {
export default async function ModuleSettingsPage({
params,
}: ModuleSettingsPageProps) {
const { account, moduleId } = await params;
const client = getSupabaseServerClient();
const api = createModuleBuilderApi(client);
@@ -23,10 +25,14 @@ export default async function ModuleSettingsPage({ params }: ModuleSettingsPageP
if (!moduleWithFields) return <div>Modul nicht gefunden</div>;
const mod = moduleWithFields;
const fields = (mod as unknown as { fields: Array<Record<string, unknown>> }).fields ?? [];
const fields =
(mod as unknown as { fields: Array<Record<string, unknown>> }).fields ?? [];
return (
<CmsPageShell account={account} title={`${String(mod.display_name)} — Einstellungen`}>
<CmsPageShell
account={account}
title={`${String(mod.display_name)} — Einstellungen`}
>
<div className="space-y-6">
{/* General Settings */}
<Card>
@@ -44,7 +50,11 @@ export default async function ModuleSettingsPage({ params }: ModuleSettingsPageP
</div>
<div className="space-y-2">
<Label>Systemname</Label>
<Input defaultValue={String(mod.name)} readOnly className="bg-muted" />
<Input
defaultValue={String(mod.name)}
readOnly
className="bg-muted"
/>
</div>
<div className="col-span-full space-y-2">
<Label>Beschreibung</Label>
@@ -56,7 +66,10 @@ export default async function ModuleSettingsPage({ params }: ModuleSettingsPageP
</div>
<div className="space-y-2">
<Label>Seitengröße</Label>
<Input type="number" defaultValue={String(mod.default_page_size ?? 25)} />
<Input
type="number"
defaultValue={String(mod.default_page_size ?? 25)}
/>
</div>
</div>
<div className="flex flex-wrap gap-2">
@@ -73,7 +86,11 @@ export default async function ModuleSettingsPage({ params }: ModuleSettingsPageP
].map(({ key, label }) => (
<Badge
key={key}
variant={(mod as Record<string, unknown>)[key] ? 'default' : 'secondary'}
variant={
(mod as Record<string, unknown>)[key]
? 'default'
: 'secondary'
}
>
{(mod as Record<string, unknown>)[key] ? '✓' : '✗'} {label}
</Badge>
@@ -96,7 +113,7 @@ export default async function ModuleSettingsPage({ params }: ModuleSettingsPageP
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left">Name</th>
<th className="p-3 text-left">Anzeigename</th>
<th className="p-3 text-left">Typ</th>
@@ -108,21 +125,35 @@ export default async function ModuleSettingsPage({ params }: ModuleSettingsPageP
<tbody>
{fields.length === 0 ? (
<tr>
<td colSpan={6} className="p-8 text-center text-muted-foreground">
<td
colSpan={6}
className="text-muted-foreground p-8 text-center"
>
Noch keine Felder definiert
</td>
</tr>
) : (
fields.map((field) => (
<tr key={String(field.id)} className="border-b hover:bg-muted/30">
<td className="p-3 font-mono text-xs">{String(field.name)}</td>
<tr
key={String(field.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-mono text-xs">
{String(field.name)}
</td>
<td className="p-3">{String(field.display_name)}</td>
<td className="p-3">
<Badge variant="secondary">{String(field.field_type)}</Badge>
<Badge variant="secondary">
{String(field.field_type)}
</Badge>
</td>
<td className="p-3">{field.is_required ? '✓' : '—'}</td>
<td className="p-3">{field.show_in_table ? '✓' : '—'}</td>
<td className="p-3">{field.show_in_form ? '✓' : '—'}</td>
<td className="p-3">
{field.show_in_table ? '✓' : '—'}
</td>
<td className="p-3">
{field.show_in_form ? '✓' : '—'}
</td>
</tr>
))
)}
@@ -141,8 +172,9 @@ export default async function ModuleSettingsPage({ params }: ModuleSettingsPageP
</CardTitle>
</CardHeader>
<CardContent>
<p className="text-sm text-muted-foreground">
Modulspezifische Berechtigungen pro Rolle können hier konfiguriert werden.
<p className="text-muted-foreground text-sm">
Modulspezifische Berechtigungen pro Rolle können hier konfiguriert
werden.
</p>
</CardContent>
</Card>

View File

@@ -1,11 +1,12 @@
'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 { useRouter } from 'next/navigation';
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';
@@ -55,9 +56,7 @@ export function ModuleToggles({ accountId, features }: ModuleTogglesProps) {
const result = await toggleModuleAction(accountId, moduleKey, enabled);
if (result.success) {
toast.success(
enabled ? 'Modul aktiviert' : 'Modul deaktiviert',
);
toast.success(enabled ? 'Modul aktiviert' : 'Modul deaktiviert');
router.refresh();
} else {

View File

@@ -18,8 +18,7 @@ export async function toggleModuleAction(
.eq('account_id', accountId)
.maybeSingle();
const currentFeatures =
(settings?.features as Record<string, boolean>) ?? {};
const currentFeatures = (settings?.features as Record<string, boolean>) ?? {};
const newFeatures = { ...currentFeatures, [moduleKey]: enabled };
// Upsert

View File

@@ -1,11 +1,10 @@
import Link from 'next/link';
import { createModuleBuilderApi } from '@kit/module-builder/api';
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 { CmsPageShell } from '~/components/cms-page-shell';
import { ModuleToggles } from './_components/module-toggles';
@@ -61,17 +60,15 @@ export default async function ModulesPage({ params }: ModulesPageProps) {
<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"
className="hover:bg-accent/50 block rounded-lg border p-4 transition-colors"
>
<h3 className="font-semibold">
{String(module.display_name)}
</h3>
<h3 className="font-semibold">{String(module.display_name)}</h3>
{module.description ? (
<p className="text-sm text-muted-foreground mt-1">
<p className="text-muted-foreground mt-1 text-sm">
{String(module.description)}
</p>
) : null}
<div className="mt-2 text-xs text-muted-foreground">
<div className="text-muted-foreground mt-2 text-xs">
Status: {String(module.status)}
</div>
</Link>

View File

@@ -2,16 +2,15 @@ import Link from 'next/link';
import { ArrowLeft, Send, Users } from 'lucide-react';
import { createNewsletterApi } from '@kit/newsletter/api';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createNewsletterApi } from '@kit/newsletter/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { StatsCard } from '~/components/stats-card';
import { AccountNotFound } from '~/components/account-not-found';
import {
NEWSLETTER_STATUS_VARIANT,
NEWSLETTER_STATUS_LABEL,
@@ -115,7 +114,7 @@ export default async function NewsletterDetailPage({ params }: PageProps) {
</CardHeader>
<CardContent>
{recipients.length === 0 ? (
<p className="py-8 text-center text-sm text-muted-foreground">
<p className="text-muted-foreground py-8 text-center text-sm">
Keine Empfänger hinzugefügt. Fügen Sie Empfänger aus Ihrer
Mitgliederliste hinzu.
</p>
@@ -123,7 +122,7 @@ export default async function NewsletterDetailPage({ params }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Name</th>
<th className="p-3 text-left font-medium">E-Mail</th>
<th className="p-3 text-left font-medium">Status</th>
@@ -135,7 +134,7 @@ export default async function NewsletterDetailPage({ params }: PageProps) {
return (
<tr
key={String(recipient.id)}
className="border-b hover:bg-muted/30"
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">
{String(recipient.name ?? '—')}
@@ -146,10 +145,12 @@ export default async function NewsletterDetailPage({ params }: PageProps) {
<td className="p-3">
<Badge
variant={
NEWSLETTER_RECIPIENT_STATUS_VARIANT[rStatus] ?? 'secondary'
NEWSLETTER_RECIPIENT_STATUS_VARIANT[rStatus] ??
'secondary'
}
>
{NEWSLETTER_RECIPIENT_STATUS_LABEL[rStatus] ?? rStatus}
{NEWSLETTER_RECIPIENT_STATUS_LABEL[rStatus] ??
rStatus}
</Badge>
</td>
</tr>

View File

@@ -1,18 +1,29 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CreateNewsletterForm } from '@kit/newsletter/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
interface Props { params: Promise<{ account: string }> }
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
}
export default async function NewNewsletterPage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
return (
<CmsPageShell account={account} title="Neuer Newsletter" description="Newsletter-Kampagne erstellen">
<CmsPageShell
account={account}
title="Neuer Newsletter"
description="Newsletter-Kampagne erstellen"
>
<CreateNewsletterForm accountId={acct.id} account={account} />
</CmsPageShell>
);

View File

@@ -1,18 +1,25 @@
import Link from 'next/link';
import { ChevronLeft, ChevronRight, Mail, Plus, Send, Users } from 'lucide-react';
import {
ChevronLeft,
ChevronRight,
Mail,
Plus,
Send,
Users,
} from 'lucide-react';
import { createNewsletterApi } from '@kit/newsletter/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createNewsletterApi } from '@kit/newsletter/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { StatsCard } from '~/components/stats-card';
import { AccountNotFound } from '~/components/account-not-found';
import {
NEWSLETTER_STATUS_VARIANT,
NEWSLETTER_STATUS_LABEL,
@@ -25,7 +32,10 @@ interface PageProps {
searchParams: Promise<Record<string, string | string[] | undefined>>;
}
export default async function NewsletterPage({ params, searchParams }: PageProps) {
export default async function NewsletterPage({
params,
searchParams,
}: PageProps) {
const { account } = await params;
const search = await searchParams;
const client = getSupabaseServerClient();
@@ -116,7 +126,7 @@ export default async function NewsletterPage({ params, searchParams }: PageProps
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Betreff</th>
<th className="p-3 text-left font-medium">Status</th>
<th className="p-3 text-right font-medium">Empfänger</th>
@@ -128,7 +138,7 @@ export default async function NewsletterPage({ params, searchParams }: PageProps
{newsletters.map((nl: Record<string, unknown>) => (
<tr
key={String(nl.id)}
className="border-b hover:bg-muted/30"
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">
<Link
@@ -141,10 +151,12 @@ export default async function NewsletterPage({ params, searchParams }: PageProps
<td className="p-3">
<Badge
variant={
NEWSLETTER_STATUS_VARIANT[String(nl.status)] ?? 'secondary'
NEWSLETTER_STATUS_VARIANT[String(nl.status)] ??
'secondary'
}
>
{NEWSLETTER_STATUS_LABEL[String(nl.status)] ?? String(nl.status)}
{NEWSLETTER_STATUS_LABEL[String(nl.status)] ??
String(nl.status)}
</Badge>
</td>
<td className="p-3 text-right">
@@ -152,16 +164,8 @@ export default async function NewsletterPage({ params, searchParams }: PageProps
? String(nl.total_recipients)
: '—'}
</td>
<td className="p-3">
{nl.created_at
? new Date(String(nl.created_at)).toLocaleDateString('de-DE')
: '—'}
</td>
<td className="p-3">
{nl.sent_at
? new Date(String(nl.sent_at)).toLocaleDateString('de-DE')
: '—'}
</td>
<td className="p-3">{formatDate(nl.created_at)}</td>
<td className="p-3">{formatDate(nl.sent_at)}</td>
</tr>
))}
</tbody>
@@ -171,12 +175,15 @@ export default async function NewsletterPage({ params, searchParams }: PageProps
{/* Pagination */}
{totalPages > 1 && (
<div className="flex items-center justify-between pt-4">
<p className="text-sm text-muted-foreground">
{startIdx + 1}{Math.min(startIdx + PAGE_SIZE, totalItems)} von {totalItems}
<p className="text-muted-foreground text-sm">
{startIdx + 1}{Math.min(startIdx + PAGE_SIZE, totalItems)}{' '}
von {totalItems}
</p>
<div className="flex items-center gap-1">
{safePage > 1 ? (
<Link href={`/home/${account}/newsletter?page=${safePage - 1}`}>
<Link
href={`/home/${account}/newsletter?page=${safePage - 1}`}
>
<Button variant="outline" size="sm">
<ChevronLeft className="h-4 w-4" />
</Button>
@@ -192,7 +199,9 @@ export default async function NewsletterPage({ params, searchParams }: PageProps
</span>
{safePage < totalPages ? (
<Link href={`/home/${account}/newsletter?page=${safePage + 1}`}>
<Link
href={`/home/${account}/newsletter?page=${safePage + 1}`}
>
<Button variant="outline" size="sm">
<ChevronRight className="h-4 w-4" />
</Button>

View File

@@ -2,16 +2,15 @@ import Link from 'next/link';
import { FileText, Plus } from 'lucide-react';
import { createNewsletterApi } from '@kit/newsletter/api';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { createNewsletterApi } from '@kit/newsletter/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { AccountNotFound } from '~/components/account-not-found';
interface PageProps {
params: Promise<{ account: string }>;
@@ -67,7 +66,7 @@ export default async function NewsletterTemplatesPage({ params }: PageProps) {
<div className="rounded-md border">
<table className="w-full text-sm">
<thead>
<tr className="border-b bg-muted/50">
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Name</th>
<th className="p-3 text-left font-medium">Betreff</th>
<th className="p-3 text-left font-medium">Variablen</th>
@@ -81,7 +80,7 @@ export default async function NewsletterTemplatesPage({ params }: PageProps) {
return (
<tr
key={String(template.id)}
className="border-b hover:bg-muted/30"
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">
{String(template.name ?? '—')}
@@ -91,17 +90,19 @@ export default async function NewsletterTemplatesPage({ params }: PageProps) {
</td>
<td className="p-3">
<div className="flex flex-wrap gap-1">
{variables.length > 0
? variables.map((v) => (
<Badge
key={v}
variant="secondary"
className="text-xs"
>
{`{{${v}}}`}
</Badge>
))
: <span className="text-muted-foreground"></span>}
{variables.length > 0 ? (
variables.map((v) => (
<Badge
key={v}
variant="secondary"
className="text-xs"
>
{`{{${v}}}`}
</Badge>
))
) : (
<span className="text-muted-foreground"></span>
)}
</div>
</td>
</tr>

View File

@@ -13,9 +13,15 @@ import {
BedDouble,
} from 'lucide-react';
import { createBookingManagementApi } from '@kit/booking-management/api';
import { createCourseManagementApi } from '@kit/course-management/api';
import { createEventManagementApi } from '@kit/event-management/api';
import { createFinanceApi } from '@kit/finance/api';
import { createMemberManagementApi } from '@kit/member-management/api';
import { createNewsletterApi } from '@kit/newsletter/api';
import { formatDate } from '@kit/shared/dates';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import {
Card,
CardContent,
@@ -24,17 +30,10 @@ import {
CardTitle,
} from '@kit/ui/card';
import { createMemberManagementApi } from '@kit/member-management/api';
import { createCourseManagementApi } from '@kit/course-management/api';
import { createFinanceApi } from '@kit/finance/api';
import { createNewsletterApi } from '@kit/newsletter/api';
import { createBookingManagementApi } from '@kit/booking-management/api';
import { createEventManagementApi } from '@kit/event-management/api';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { StatsCard } from '~/components/stats-card';
import { AccountNotFound } from '~/components/account-not-found';
interface TeamAccountHomePageProps {
params: Promise<{ account: string }>;
@@ -79,7 +78,12 @@ export default async function TeamAccountHomePage({
const courseStats =
courseStatsResult.status === 'fulfilled'
? courseStatsResult.value
: { totalCourses: 0, openCourses: 0, completedCourses: 0, totalParticipants: 0 };
: {
totalCourses: 0,
openCourses: 0,
completedCourses: 0,
totalParticipants: 0,
};
const openInvoices =
invoicesResult.status === 'fulfilled' ? invoicesResult.value : [];
@@ -145,82 +149,68 @@ export default async function TeamAccountHomePage({
<CardContent>
<div className="space-y-4">
{/* Recent bookings */}
{bookings.data.slice(0, 3).map((booking: Record<string, unknown>) => (
<div
key={String(booking.id)}
className="flex items-center justify-between rounded-md border p-3"
>
<div className="flex items-center gap-3">
<div className="rounded-full bg-blue-500/10 p-2 text-blue-600">
<BedDouble className="h-4 w-4" />
</div>
<div>
<Link
href={`/home/${account}/bookings/${String(booking.id)}`}
className="text-sm font-medium hover:underline"
>
Buchung{' '}
{booking.check_in
? new Date(
String(booking.check_in),
).toLocaleDateString('de-DE', {
day: '2-digit',
month: 'short',
})
: ''}
</Link>
<p className="text-xs text-muted-foreground">
{booking.check_in
? new Date(
String(booking.check_in),
).toLocaleDateString('de-DE')
: '—'}{' '}
{' '}
{booking.check_out
? new Date(
String(booking.check_out),
).toLocaleDateString('de-DE')
: '—'}
</p>
{bookings.data
.slice(0, 3)
.map((booking: Record<string, unknown>) => (
<div
key={String(booking.id)}
className="flex items-center justify-between rounded-md border p-3"
>
<div className="flex items-center gap-3">
<div className="rounded-full bg-blue-500/10 p-2 text-blue-600">
<BedDouble className="h-4 w-4" />
</div>
<div>
<Link
href={`/home/${account}/bookings/${String(booking.id)}`}
className="text-sm font-medium hover:underline"
>
Buchung{' '}
{booking.check_in
? formatDate(booking.check_in as string)
: '—'}
</Link>
<p className="text-muted-foreground text-xs">
{formatDate(booking.check_in as string)} {' '}
{formatDate(booking.check_out as string)}
</p>
</div>
</div>
<Badge variant="outline">
{String(booking.status ?? '—')}
</Badge>
</div>
<Badge variant="outline">
{String(booking.status ?? '—')}
</Badge>
</div>
))}
))}
{/* Recent events */}
{events.data.slice(0, 3).map((event: Record<string, unknown>) => (
<div
key={String(event.id)}
className="flex items-center justify-between rounded-md border p-3"
>
<div className="flex items-center gap-3">
<div className="rounded-full bg-amber-500/10 p-2 text-amber-600">
<CalendarDays className="h-4 w-4" />
</div>
<div>
<Link
href={`/home/${account}/events/${String(event.id)}`}
className="text-sm font-medium hover:underline"
>
{String(event.name)}
</Link>
<p className="text-xs text-muted-foreground">
{event.event_date
? new Date(
String(event.event_date),
).toLocaleDateString('de-DE')
: 'Kein Datum'}
</p>
{events.data
.slice(0, 3)
.map((event: Record<string, unknown>) => (
<div
key={String(event.id)}
className="flex items-center justify-between rounded-md border p-3"
>
<div className="flex items-center gap-3">
<div className="rounded-full bg-amber-500/10 p-2 text-amber-600">
<CalendarDays className="h-4 w-4" />
</div>
<div>
<Link
href={`/home/${account}/events/${String(event.id)}`}
className="text-sm font-medium hover:underline"
>
{String(event.name)}
</Link>
<p className="text-muted-foreground text-xs">
{formatDate(event.event_date as string)}
</p>
</div>
</div>
<Badge variant="outline">
{String(event.status ?? '—')}
</Badge>
</div>
<Badge variant="outline">
{String(event.status ?? '—')}
</Badge>
</div>
))}
))}
{bookings.data.length === 0 && events.data.length === 0 && (
<EmptyState
@@ -242,7 +232,7 @@ export default async function TeamAccountHomePage({
<CardContent className="flex flex-col gap-2">
<Link
href={`/home/${account}/members-cms/new`}
className="inline-flex w-full items-center justify-between gap-2 rounded-lg border border-border bg-background px-4 py-2 text-sm font-medium hover:bg-muted hover:text-foreground transition-all"
className="border-border bg-background hover:bg-muted hover:text-foreground inline-flex w-full items-center justify-between gap-2 rounded-lg border px-4 py-2 text-sm font-medium transition-all"
>
<span className="flex items-center gap-2">
<UserPlus className="h-4 w-4" />
@@ -253,7 +243,7 @@ export default async function TeamAccountHomePage({
<Link
href={`/home/${account}/courses/new`}
className="inline-flex w-full items-center justify-between gap-2 rounded-lg border border-border bg-background px-4 py-2 text-sm font-medium hover:bg-muted hover:text-foreground transition-all"
className="border-border bg-background hover:bg-muted hover:text-foreground inline-flex w-full items-center justify-between gap-2 rounded-lg border px-4 py-2 text-sm font-medium transition-all"
>
<span className="flex items-center gap-2">
<GraduationCap className="h-4 w-4" />
@@ -264,7 +254,7 @@ export default async function TeamAccountHomePage({
<Link
href={`/home/${account}/newsletter/new`}
className="inline-flex w-full items-center justify-between gap-2 rounded-lg border border-border bg-background px-4 py-2 text-sm font-medium hover:bg-muted hover:text-foreground transition-all"
className="border-border bg-background hover:bg-muted hover:text-foreground inline-flex w-full items-center justify-between gap-2 rounded-lg border px-4 py-2 text-sm font-medium transition-all"
>
<span className="flex items-center gap-2">
<Mail className="h-4 w-4" />
@@ -275,7 +265,7 @@ export default async function TeamAccountHomePage({
<Link
href={`/home/${account}/bookings/new`}
className="inline-flex w-full items-center justify-between gap-2 rounded-lg border border-border bg-background px-4 py-2 text-sm font-medium hover:bg-muted hover:text-foreground transition-all"
className="border-border bg-background hover:bg-muted hover:text-foreground inline-flex w-full items-center justify-between gap-2 rounded-lg border px-4 py-2 text-sm font-medium transition-all"
>
<span className="flex items-center gap-2">
<BedDouble className="h-4 w-4" />
@@ -286,7 +276,7 @@ export default async function TeamAccountHomePage({
<Link
href={`/home/${account}/events/new`}
className="inline-flex w-full items-center justify-between gap-2 rounded-lg border border-border bg-background px-4 py-2 text-sm font-medium hover:bg-muted hover:text-foreground transition-all"
className="border-border bg-background hover:bg-muted hover:text-foreground inline-flex w-full items-center justify-between gap-2 rounded-lg border px-4 py-2 text-sm font-medium transition-all"
>
<span className="flex items-center gap-2">
<Plus className="h-4 w-4" />
@@ -304,21 +294,23 @@ export default async function TeamAccountHomePage({
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm font-medium text-muted-foreground">
<p className="text-muted-foreground text-sm font-medium">
Buchungen
</p>
<p className="text-2xl font-bold">{bookings.total}</p>
<p className="text-xs text-muted-foreground">
{bookings.data.filter(
(b: Record<string, unknown>) =>
b.status === 'confirmed' || b.status === 'checked_in',
).length}{' '}
<p className="text-muted-foreground text-xs">
{
bookings.data.filter(
(b: Record<string, unknown>) =>
b.status === 'confirmed' || b.status === 'checked_in',
).length
}{' '}
aktiv
</p>
</div>
<Link
href={`/home/${account}/bookings`}
className="inline-flex h-9 w-9 items-center justify-center rounded-lg text-sm font-medium hover:bg-muted hover:text-foreground transition-all"
className="hover:bg-muted hover:text-foreground inline-flex h-9 w-9 items-center justify-center rounded-lg text-sm font-medium transition-all"
>
<ArrowRight className="h-4 w-4" />
</Link>
@@ -330,22 +322,24 @@ export default async function TeamAccountHomePage({
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm font-medium text-muted-foreground">
<p className="text-muted-foreground text-sm font-medium">
Veranstaltungen
</p>
<p className="text-2xl font-bold">{events.total}</p>
<p className="text-xs text-muted-foreground">
{events.data.filter(
(e: Record<string, unknown>) =>
e.status === 'published' ||
e.status === 'registration_open',
).length}{' '}
<p className="text-muted-foreground text-xs">
{
events.data.filter(
(e: Record<string, unknown>) =>
e.status === 'published' ||
e.status === 'registration_open',
).length
}{' '}
aktiv
</p>
</div>
<Link
href={`/home/${account}/events`}
className="inline-flex h-9 w-9 items-center justify-center rounded-lg text-sm font-medium hover:bg-muted hover:text-foreground transition-all"
className="hover:bg-muted hover:text-foreground inline-flex h-9 w-9 items-center justify-center rounded-lg text-sm font-medium transition-all"
>
<ArrowRight className="h-4 w-4" />
</Link>
@@ -357,19 +351,19 @@ export default async function TeamAccountHomePage({
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm font-medium text-muted-foreground">
<p className="text-muted-foreground text-sm font-medium">
Kurse abgeschlossen
</p>
<p className="text-2xl font-bold">
{courseStats.completedCourses}
</p>
<p className="text-xs text-muted-foreground">
<p className="text-muted-foreground text-xs">
von {courseStats.totalCourses} insgesamt
</p>
</div>
<Link
href={`/home/${account}/courses`}
className="inline-flex h-9 w-9 items-center justify-center rounded-lg text-sm font-medium hover:bg-muted hover:text-foreground transition-all"
className="hover:bg-muted hover:text-foreground inline-flex h-9 w-9 items-center justify-center rounded-lg text-sm font-medium transition-all"
>
<ArrowRight className="h-4 w-4" />
</Link>

View File

@@ -1,19 +1,32 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createSiteBuilderApi } from '@kit/site-builder/api';
import { SiteEditor } from '@kit/site-builder/components';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { AccountNotFound } from '~/components/account-not-found';
interface Props { params: Promise<{ account: string; pageId: string }> }
interface Props {
params: Promise<{ account: string; pageId: string }>;
}
export default async function EditPageRoute({ params }: Props) {
const { account, pageId } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
const api = createSiteBuilderApi(client);
const page = await api.getPage(pageId);
if (!page) return <div>Seite nicht gefunden</div>;
return <SiteEditor pageId={pageId} accountId={acct.id} initialData={(page.puck_data ?? {}) as Record<string, unknown>} />;
return (
<SiteEditor
pageId={pageId}
accountId={acct.id}
initialData={(page.puck_data ?? {}) as Record<string, unknown>}
/>
);
}

View File

@@ -1,7 +1,8 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CreatePageForm } from '@kit/site-builder/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
@@ -10,11 +11,19 @@ interface Props {
export default async function NewSitePage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
return (
<CmsPageShell account={account} title="Neue Seite" description="Seite für Ihre Vereinswebsite erstellen">
<CmsPageShell
account={account}
title="Neue Seite"
description="Seite für Ihre Vereinswebsite erstellen"
>
<CreatePageForm accountId={acct.id} account={account} />
</CmsPageShell>
);

View File

@@ -1,21 +1,31 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import Link from 'next/link';
import { Plus, Globe, FileText, Settings, ExternalLink } from 'lucide-react';
import { formatDate } from '@kit/shared/dates';
import { createSiteBuilderApi } from '@kit/site-builder/api';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { cn } from '@kit/ui/utils';
import { Plus, Globe, FileText, Settings, ExternalLink } from 'lucide-react';
import Link from 'next/link';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { AccountNotFound } from '~/components/account-not-found';
interface Props { params: Promise<{ account: string }> }
interface Props {
params: Promise<{ account: string }>;
}
export default async function SiteBuilderDashboard({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
const api = createSiteBuilderApi(client);
@@ -24,39 +34,72 @@ export default async function SiteBuilderDashboard({ params }: Props) {
const posts = await api.listPosts(acct.id);
const isOnline = Boolean(settings?.is_public);
const publishedCount = pages.filter((p: Record<string, unknown>) => p.is_published).length;
const publishedCount = pages.filter(
(p: Record<string, unknown>) => p.is_published,
).length;
return (
<CmsPageShell account={account} title="Website-Baukasten" description="Ihre Vereinswebseite verwalten">
<CmsPageShell
account={account}
title="Website-Baukasten"
description="Ihre Vereinswebseite verwalten"
>
<div className="space-y-6">
<div className="flex items-center justify-between">
<div className="flex gap-2">
<Link href={`/home/${account}/site-builder/settings`}>
<Button variant="outline" size="sm"><Settings className="mr-2 h-4 w-4" />Einstellungen</Button>
<Button variant="outline" size="sm">
<Settings className="mr-2 h-4 w-4" />
Einstellungen
</Button>
</Link>
<Link href={`/home/${account}/site-builder/posts`}>
<Button variant="outline" size="sm"><FileText className="mr-2 h-4 w-4" />Beiträge ({posts.length})</Button>
<Button variant="outline" size="sm">
<FileText className="mr-2 h-4 w-4" />
Beiträge ({posts.length})
</Button>
</Link>
{isOnline && (
<a href={`/club/${account}`} target="_blank" rel="noopener">
<Button variant="outline" size="sm"><ExternalLink className="mr-2 h-4 w-4" />Website ansehen</Button>
<Button variant="outline" size="sm">
<ExternalLink className="mr-2 h-4 w-4" />
Website ansehen
</Button>
</a>
)}
</div>
<Link href={`/home/${account}/site-builder/new`}>
<Button><Plus className="mr-2 h-4 w-4" />Neue Seite</Button>
<Button>
<Plus className="mr-2 h-4 w-4" />
Neue Seite
</Button>
</Link>
</div>
<div className="grid grid-cols-1 gap-4 sm:grid-cols-3">
<Card><CardContent className="p-6"><p className="text-sm text-muted-foreground">Seiten</p><p className="text-2xl font-bold">{pages.length}</p></CardContent></Card>
<Card><CardContent className="p-6"><p className="text-sm text-muted-foreground">Veröffentlicht</p><p className="text-2xl font-bold">{publishedCount}</p></CardContent></Card>
<Card>
<CardContent className="p-6">
<p className="text-sm text-muted-foreground">Status</p>
<p className="text-muted-foreground text-sm">Seiten</p>
<p className="text-2xl font-bold">{pages.length}</p>
</CardContent>
</Card>
<Card>
<CardContent className="p-6">
<p className="text-muted-foreground text-sm">Veröffentlicht</p>
<p className="text-2xl font-bold">{publishedCount}</p>
</CardContent>
</Card>
<Card>
<CardContent className="p-6">
<p className="text-muted-foreground text-sm">Status</p>
<p className="text-2xl font-bold">
<span className="flex items-center gap-1.5">
<span className={cn('inline-block h-2 w-2 rounded-full', isOnline ? 'bg-green-500' : 'bg-red-500')} />
<span
className={cn(
'inline-block h-2 w-2 rounded-full',
isOnline ? 'bg-green-500' : 'bg-red-500',
)}
/>
<span>{isOnline ? 'Online' : 'Offline'}</span>
</span>
</p>
@@ -75,25 +118,44 @@ export default async function SiteBuilderDashboard({ params }: Props) {
) : (
<div className="rounded-md border">
<table className="w-full text-sm">
<thead><tr className="border-b bg-muted/50">
<th className="p-3 text-left font-medium">Titel</th>
<th className="p-3 text-left font-medium">URL</th>
<th className="p-3 text-left font-medium">Status</th>
<th className="p-3 text-left font-medium">Startseite</th>
<th className="p-3 text-left font-medium">Aktualisiert</th>
<th className="p-3 text-left font-medium">Aktionen</th>
</tr></thead>
<thead>
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left font-medium">Titel</th>
<th className="p-3 text-left font-medium">URL</th>
<th className="p-3 text-left font-medium">Status</th>
<th className="p-3 text-left font-medium">Startseite</th>
<th className="p-3 text-left font-medium">Aktualisiert</th>
<th className="p-3 text-left font-medium">Aktionen</th>
</tr>
</thead>
<tbody>
{pages.map((page: Record<string, unknown>) => (
<tr key={String(page.id)} className="border-b hover:bg-muted/30">
<tr
key={String(page.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">{String(page.title)}</td>
<td className="p-3 text-muted-foreground font-mono text-xs">/{String(page.slug)}</td>
<td className="p-3"><Badge variant={page.is_published ? 'default' : 'secondary'}>{page.is_published ? 'Veröffentlicht' : 'Entwurf'}</Badge></td>
<td className="p-3">{page.is_homepage ? '⭐' : '—'}</td>
<td className="p-3 text-xs text-muted-foreground">{page.updated_at ? new Date(String(page.updated_at)).toLocaleDateString('de-DE') : '—'}</td>
<td className="text-muted-foreground p-3 font-mono text-xs">
/{String(page.slug)}
</td>
<td className="p-3">
<Link href={`/home/${account}/site-builder/${String(page.id)}/edit`}>
<Button size="sm" variant="outline">Bearbeiten</Button>
<Badge
variant={page.is_published ? 'default' : 'secondary'}
>
{page.is_published ? 'Veröffentlicht' : 'Entwurf'}
</Badge>
</td>
<td className="p-3">{page.is_homepage ? '⭐' : '—'}</td>
<td className="text-muted-foreground p-3 text-xs">
{formatDate(page.updated_at)}
</td>
<td className="p-3">
<Link
href={`/home/${account}/site-builder/${String(page.id)}/edit`}
>
<Button size="sm" variant="outline">
Bearbeiten
</Button>
</Link>
</td>
</tr>

View File

@@ -1,18 +1,29 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { CreatePostForm } from '@kit/site-builder/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
interface Props { params: Promise<{ account: string }> }
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
}
export default async function NewPostPage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
return (
<CmsPageShell account={account} title="Neuer Beitrag" description="Beitrag erstellen">
<CmsPageShell
account={account}
title="Neuer Beitrag"
description="Beitrag erstellen"
>
<CreatePostForm accountId={acct.id} account={account} />
</CmsPageShell>
);

View File

@@ -1,47 +1,83 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import Link from 'next/link';
import { Plus } from 'lucide-react';
import { formatDate } from '@kit/shared/dates';
import { createSiteBuilderApi } from '@kit/site-builder/api';
import { Card, CardContent } from '@kit/ui/card';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import { Plus } from 'lucide-react';
import Link from 'next/link';
import { Card, CardContent } from '@kit/ui/card';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import { EmptyState } from '~/components/empty-state';
import { AccountNotFound } from '~/components/account-not-found';
interface Props { params: Promise<{ account: string }> }
interface Props {
params: Promise<{ account: string }>;
}
export default async function PostsManagerPage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
const api = createSiteBuilderApi(client);
const posts = await api.listPosts(acct.id);
return (
<CmsPageShell account={account} title="Beiträge" description="Neuigkeiten und Artikel verwalten">
<CmsPageShell
account={account}
title="Beiträge"
description="Neuigkeiten und Artikel verwalten"
>
<div className="space-y-6">
<div className="flex justify-end">
<Button><Plus className="mr-2 h-4 w-4" />Neuer Beitrag</Button>
<Button>
<Plus className="mr-2 h-4 w-4" />
Neuer Beitrag
</Button>
</div>
{posts.length === 0 ? (
<EmptyState title="Keine Beiträge" description="Erstellen Sie Ihren ersten Beitrag." actionLabel="Beitrag erstellen" />
<EmptyState
title="Keine Beiträge"
description="Erstellen Sie Ihren ersten Beitrag."
actionLabel="Beitrag erstellen"
/>
) : (
<div className="rounded-md border">
<table className="w-full text-sm">
<thead><tr className="border-b bg-muted/50">
<th className="p-3 text-left">Titel</th>
<th className="p-3 text-left">Status</th>
<th className="p-3 text-left">Erstellt</th>
</tr></thead>
<thead>
<tr className="bg-muted/50 border-b">
<th className="p-3 text-left">Titel</th>
<th className="p-3 text-left">Status</th>
<th className="p-3 text-left">Erstellt</th>
</tr>
</thead>
<tbody>
{posts.map((post: Record<string, unknown>) => (
<tr key={String(post.id)} className="border-b hover:bg-muted/30">
<tr
key={String(post.id)}
className="hover:bg-muted/30 border-b"
>
<td className="p-3 font-medium">{String(post.title)}</td>
<td className="p-3"><Badge variant={post.status === 'published' ? 'default' : 'secondary'}>{String(post.status)}</Badge></td>
<td className="p-3 text-xs text-muted-foreground">{post.created_at ? new Date(String(post.created_at)).toLocaleDateString('de-DE') : '—'}</td>
<td className="p-3">
<Badge
variant={
post.status === 'published' ? 'default' : 'secondary'
}
>
{String(post.status)}
</Badge>
</td>
<td className="text-muted-foreground p-3 text-xs">
{formatDate(post.created_at)}
</td>
</tr>
))}
</tbody>

View File

@@ -1,23 +1,38 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createSiteBuilderApi } from '@kit/site-builder/api';
import { SiteSettingsForm } from '@kit/site-builder/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
interface Props { params: Promise<{ account: string }> }
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;
}
export default async function SiteSettingsPage({ params }: Props) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client.from('accounts').select('id').eq('slug', account).single();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
const api = createSiteBuilderApi(client);
const settings = await api.getSiteSettings(acct.id);
return (
<CmsPageShell account={account} title="Website-Einstellungen" description="Design und Kontaktdaten">
<SiteSettingsForm accountId={acct.id} account={account} settings={settings} />
<CmsPageShell
account={account}
title="Website-Einstellungen"
description="Design und Kontaktdaten"
>
<SiteSettingsForm
accountId={acct.id}
account={account}
settings={settings}
/>
</CmsPageShell>
);
}

View File

@@ -7,8 +7,8 @@ import {
ClubNotesList,
} from '@kit/verbandsverwaltung/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string; clubId: string }>;
@@ -41,9 +41,11 @@ export default async function ClubDetailPage({ params }: Props) {
{detail.club.short_name && (
<p className="text-muted-foreground">{detail.club.short_name}</p>
)}
<div className="mt-2 flex flex-wrap gap-4 text-sm text-muted-foreground">
<div className="text-muted-foreground mt-2 flex flex-wrap gap-4 text-sm">
{detail.club.city && (
<span>{detail.club.zip} {detail.club.city}</span>
<span>
{detail.club.zip} {detail.club.city}
</span>
)}
{detail.club.member_count != null && (
<span>{detail.club.member_count} Mitglieder</span>

View File

@@ -1,9 +1,12 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createVerbandApi } from '@kit/verbandsverwaltung/api';
import { VerbandTabNavigation, CreateClubForm } from '@kit/verbandsverwaltung/components';
import {
VerbandTabNavigation,
CreateClubForm,
} from '@kit/verbandsverwaltung/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;

View File

@@ -1,9 +1,12 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createVerbandApi } from '@kit/verbandsverwaltung/api';
import { VerbandTabNavigation, ClubsDataTable } from '@kit/verbandsverwaltung/components';
import {
VerbandTabNavigation,
ClubsDataTable,
} from '@kit/verbandsverwaltung/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface Props {
params: Promise<{ account: string }>;

View File

@@ -0,0 +1,48 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createVerbandApi } from '@kit/verbandsverwaltung/api';
import {
VerbandTabNavigation,
HierarchyTree,
} from '@kit/verbandsverwaltung/components';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
params: Promise<{ account: string }>;
}
export default async function HierarchyPage({ params }: PageProps) {
const { account } = await params;
const client = getSupabaseServerClient();
const { data: acct } = await client
.from('accounts')
.select('id')
.eq('slug', account)
.single();
if (!acct) return <AccountNotFound />;
const api = createVerbandApi(client);
const [tree, availableAccounts] = await Promise.all([
api.getHierarchyTree(acct.id),
api.searchAvailableAccounts(acct.id),
]);
return (
<CmsPageShell
account={account}
title="Verbandsverwaltung - Hierarchie"
description="Verwalten Sie die Organisationsstruktur Ihres Verbands"
>
<VerbandTabNavigation account={account} activeTab="hierarchy" />
<HierarchyTree
accountId={acct.id}
tree={tree}
availableAccounts={availableAccounts}
/>
</CmsPageShell>
);
}

View File

@@ -1,9 +1,12 @@
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createVerbandApi } from '@kit/verbandsverwaltung/api';
import { VerbandTabNavigation, VerbandDashboard } from '@kit/verbandsverwaltung/components';
import {
VerbandTabNavigation,
VerbandDashboard,
} from '@kit/verbandsverwaltung/components';
import { CmsPageShell } from '~/components/cms-page-shell';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
interface PageProps {
params: Promise<{ account: string }>;

View File

@@ -1,15 +1,14 @@
'use client';
import { useState } from 'react';
import { useAction } from 'next-safe-action/hooks';
import { Plus, Pencil, Trash2, Settings } from 'lucide-react';
import { useAction } from 'next-safe-action/hooks';
import { Button } from '@kit/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { Input } from '@kit/ui/input';
import { toast } from '@kit/ui/sonner';
import {
createRole,
updateRole,
@@ -93,18 +92,27 @@ function SettingsSection({
>
Erstellen
</Button>
<Button size="sm" variant="outline" onClick={() => setShowAdd(false)}>
<Button
size="sm"
variant="outline"
onClick={() => setShowAdd(false)}
>
Abbrechen
</Button>
</div>
)}
{items.length === 0 ? (
<p className="text-sm text-muted-foreground">Keine Einträge vorhanden.</p>
<p className="text-muted-foreground text-sm">
Keine Einträge vorhanden.
</p>
) : (
<div className="space-y-2">
{items.map((item) => (
<div key={String(item.id)} className="flex items-center justify-between rounded-lg border p-3">
<div
key={String(item.id)}
className="flex items-center justify-between rounded-lg border p-3"
>
{editingId === String(item.id) ? (
<div className="flex flex-1 gap-2">
<Input
@@ -122,7 +130,11 @@ function SettingsSection({
>
Speichern
</Button>
<Button size="sm" variant="outline" onClick={() => setEditingId(null)}>
<Button
size="sm"
variant="outline"
onClick={() => setEditingId(null)}
>
Abbrechen
</Button>
</div>
@@ -131,7 +143,9 @@ function SettingsSection({
<div>
<span className="font-medium">{String(item.name)}</span>
{item.description && (
<p className="text-xs text-muted-foreground">{String(item.description)}</p>
<p className="text-muted-foreground text-xs">
{String(item.description)}
</p>
)}
</div>
<div className="flex gap-1">
@@ -150,7 +164,7 @@ function SettingsSection({
size="sm"
onClick={() => onDelete(String(item.id))}
>
<Trash2 className="h-4 w-4 text-destructive" />
<Trash2 className="text-destructive h-4 w-4" />
</Button>
</div>
</>
@@ -171,42 +185,60 @@ export default function SettingsContent({
feeTypes,
}: SettingsContentProps) {
// Roles
const { execute: execCreateRole, isPending: isCreatingRole } = useAction(createRole, {
onSuccess: () => toast.success('Funktion erstellt'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
});
const { execute: execUpdateRole, isPending: isUpdatingRole } = useAction(updateRole, {
onSuccess: () => toast.success('Funktion aktualisiert'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
});
const { execute: execCreateRole, isPending: isCreatingRole } = useAction(
createRole,
{
onSuccess: () => toast.success('Funktion erstellt'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
},
);
const { execute: execUpdateRole, isPending: isUpdatingRole } = useAction(
updateRole,
{
onSuccess: () => toast.success('Funktion aktualisiert'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
},
);
const { execute: execDeleteRole } = useAction(deleteRole, {
onSuccess: () => toast.success('Funktion gelöscht'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
});
// Types
const { execute: execCreateType, isPending: isCreatingType } = useAction(createAssociationType, {
onSuccess: () => toast.success('Vereinstyp erstellt'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
});
const { execute: execUpdateType, isPending: isUpdatingType } = useAction(updateAssociationType, {
onSuccess: () => toast.success('Vereinstyp aktualisiert'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
});
const { execute: execCreateType, isPending: isCreatingType } = useAction(
createAssociationType,
{
onSuccess: () => toast.success('Vereinstyp erstellt'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
},
);
const { execute: execUpdateType, isPending: isUpdatingType } = useAction(
updateAssociationType,
{
onSuccess: () => toast.success('Vereinstyp aktualisiert'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
},
);
const { execute: execDeleteType } = useAction(deleteAssociationType, {
onSuccess: () => toast.success('Vereinstyp gelöscht'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
});
// Fee Types
const { execute: execCreateFeeType, isPending: isCreatingFee } = useAction(createFeeType, {
onSuccess: () => toast.success('Beitragsart erstellt'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
});
const { execute: execUpdateFeeType, isPending: isUpdatingFee } = useAction(updateFeeType, {
onSuccess: () => toast.success('Beitragsart aktualisiert'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
});
const { execute: execCreateFeeType, isPending: isCreatingFee } = useAction(
createFeeType,
{
onSuccess: () => toast.success('Beitragsart erstellt'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
},
);
const { execute: execUpdateFeeType, isPending: isUpdatingFee } = useAction(
updateFeeType,
{
onSuccess: () => toast.success('Beitragsart aktualisiert'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
},
);
const { execute: execDeleteFeeType } = useAction(deleteFeeType, {
onSuccess: () => toast.success('Beitragsart gelöscht'),
onError: ({ error }) => toast.error(error.serverError ?? 'Fehler'),
@@ -224,7 +256,9 @@ export default function SettingsContent({
<SettingsSection
title="Funktionen (Rollen)"
items={roles}
onAdd={(name, description) => execCreateRole({ accountId, name, description, sortOrder: 0 })}
onAdd={(name, description) =>
execCreateRole({ accountId, name, description, sortOrder: 0 })
}
onUpdate={(id, name) => execUpdateRole({ roleId: id, name })}
onDelete={(id) => execDeleteRole({ roleId: id })}
isAdding={isCreatingRole}
@@ -234,7 +268,9 @@ export default function SettingsContent({
<SettingsSection
title="Vereinstypen"
items={types}
onAdd={(name, description) => execCreateType({ accountId, name, description, sortOrder: 0 })}
onAdd={(name, description) =>
execCreateType({ accountId, name, description, sortOrder: 0 })
}
onUpdate={(id, name) => execUpdateType({ typeId: id, name })}
onDelete={(id) => execDeleteType({ typeId: id })}
isAdding={isCreatingType}
@@ -244,7 +280,9 @@ export default function SettingsContent({
<SettingsSection
title="Beitragsarten"
items={feeTypes}
onAdd={(name, description) => execCreateFeeType({ accountId, name, description, isActive: true })}
onAdd={(name, description) =>
execCreateFeeType({ accountId, name, description, isActive: true })
}
onUpdate={(id, name) => execUpdateFeeType({ feeTypeId: id, name })}
onDelete={(id) => execDeleteFeeType({ feeTypeId: id })}
isAdding={isCreatingFee}

View File

@@ -2,10 +2,10 @@ import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createVerbandApi } from '@kit/verbandsverwaltung/api';
import { VerbandTabNavigation } from '@kit/verbandsverwaltung/components';
import { AccountNotFound } from '~/components/account-not-found';
import { CmsPageShell } from '~/components/cms-page-shell';
import SettingsContent from './_components/settings-content';
import { AccountNotFound } from '~/components/account-not-found';
interface Props {
params: Promise<{ account: string }>;

View File

@@ -1,6 +1,5 @@
'use client';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
import { BarChart3 } from 'lucide-react';
import {
AreaChart,
@@ -12,6 +11,8 @@ import {
ResponsiveContainer,
} from 'recharts';
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
const PLACEHOLDER_DATA = [
{ year: '2020', vereine: 12, mitglieder: 850 },
{ year: '2021', vereine: 14, mitglieder: 920 },
@@ -89,9 +90,10 @@ export default function StatisticsContent() {
<Card>
<CardContent className="p-6">
<p className="text-sm text-muted-foreground">
Die Statistiken werden automatisch aus den Vereinsdaten und der Verbandshistorie berechnet.
Pflegen Sie die Mitgliederzahlen in den einzelnen Vereinsdetails, um aktuelle Auswertungen zu erhalten.
<p className="text-muted-foreground text-sm">
Die Statistiken werden automatisch aus den Vereinsdaten und der
Verbandshistorie berechnet. Pflegen Sie die Mitgliederzahlen in den
einzelnen Vereinsdetails, um aktuelle Auswertungen zu erhalten.
</p>
</CardContent>
</Card>