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 { AccountNotFound } from '~/components/account-not-found'; import { CmsPageShell } from '~/components/cms-page-shell'; import { EmptyState } from '~/components/empty-state'; import { BATCH_STATUS_VARIANT, BATCH_STATUS_LABEL } from '~/lib/status-badges'; interface PageProps { params: Promise<{ account: string }>; } const formatCurrency = (amount: unknown) => new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format( Number(amount), ); export default async function SepaPage({ 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 ; const api = createFinanceApi(client); const batches = await api.listBatches(acct.id); return (
{/* Header */}

SEPA-Lastschriften

Lastschrifteinzüge verwalten

{/* Table or Empty State */} {batches.length === 0 ? ( } title="Keine SEPA-Einzüge" description="Erstellen Sie Ihren ersten SEPA-Einzug." actionLabel="Neuer Einzug" actionHref={`/home/${account}/finance/sepa/new`} /> ) : ( Alle Einzüge ({batches.length})
{batches.map((batch: Record) => ( ))}
Status Typ Beschreibung Betrag Anzahl Ausführungsdatum
{BATCH_STATUS_LABEL[String(batch.status)] ?? String(batch.status)} {batch.batch_type === 'direct_debit' ? 'Lastschrift' : 'Überweisung'} {String(batch.description ?? '—')} {batch.total_amount != null ? formatCurrency(batch.total_amount) : '—'} {String(batch.item_count ?? 0)} {formatDate(batch.execution_date)}
)}
); }