'use client'; import { useState, useEffect } from 'react'; import AusgabenForm from '@/components/AusgabenForm'; import AusgabenList from '@/components/AusgabenList'; import { AusgabenEntry } from '@/types/ausgaben'; import packageJson from '@/package.json'; export default function Home() { const [entries, setEntries] = useState([]); const [isLoading, setIsLoading] = useState(true); const [selectedEntry, setSelectedEntry] = useState(null); const version = packageJson.version; useEffect(() => { fetchRecentEntries(); }, []); const fetchRecentEntries = async () => { setIsLoading(true); try { const response = await fetch('/api/ausgaben?limit=10', { cache: 'no-store', headers: { 'Cache-Control': 'no-cache', }, }); const data = await response.json(); if (data.success) { setEntries(data.data); } } catch (error) { console.error('Error fetching entries:', error); } finally { setIsLoading(false); } }; const handleSuccess = () => { setSelectedEntry(null); setTimeout(() => { fetchRecentEntries(); }, 100); }; const handleDelete = (id: number) => { setEntries(entries.filter(entry => entry.ID !== id)); }; const handleEdit = (entry: AusgabenEntry) => { setSelectedEntry(entry); window.scrollTo({ top: 0, behavior: 'smooth' }); }; return (

Ausgaben - Log

Eingabe

Letzte 10 Einträge

{isLoading ? (
Lade Daten...
) : ( )}
{/* Footer */}
); }