"use client"; import { useEffect, useState } from 'react'; interface ActivityItem { type: 'fillup' | 'mileage'; id: string; car: { name: string; make: string; model: string }; mileage: number; liters?: number; cost?: number; currency?: string; date: string; fuelType?: string; // Add fuelType for fill-ups } export default function RecentActivity() { const [activity, setActivity] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { fetch('/api/activity') .then((res) => res.json()) .then((data) => { setActivity(data); setLoading(false); }) .catch(() => setLoading(false)); }, []); if (loading) return
Loading activity...
; if (!activity.length) return (
No recent activity yet.
Start by logging a fill-up or mileage entry!
); return ( ); }