'use client'; import { AusgabenEntry } from '@/types/ausgaben'; interface AusgabenListProps { entries: AusgabenEntry[]; onDelete: (id: number) => void; onEdit: (entry: AusgabenEntry) => void; } export default function AusgabenList({ entries, onDelete, onEdit }: AusgabenListProps) { const handleDelete = async (id: number) => { if (!confirm('Wirklich löschen?')) return; try { const response = await fetch(`/api/ausgaben/${id}`, { method: 'DELETE', }); if (response.ok) { onDelete(id); } else { alert('Fehler beim Löschen!'); } } catch (error) { console.error('Error:', error); alert('Fehler beim Löschen!'); } }; const formatDate = (dateStr: string) => { const date = new Date(dateStr); return date.toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit', year: 'numeric', }); }; const formatAmount = (amount: number) => { return new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR', }).format(amount); }; return (
{entries.length === 0 ? ( ) : ( entries.map((entry, index) => ( )) )}
Datum Tag Wo Was Betrag Wie Aktion
Keine Einträge vorhanden
{formatDate(entry.Datum)} {entry.WochTag.slice(0, 2)} {entry.Wo} {entry.Was} {formatAmount(entry.Wieviel)} {entry.Wie}
); }