import React, { useState, useEffect } from 'react'; import StatCard from './Components/StatCard'; import ProfitTable from './Components/ProfitTable'; import { DollarSign, TrendingDown, TrendingUp, Calendar, ChevronDown } from 'lucide-react'; export default function Dashboard() { const [stats, setStats] = useState({ total_income: 0, total_expense: 0, net_profit: 0 }); const [loading, setLoading] = useState(true); useEffect(() => { fetch('/api/reports/profit') .then(res => res.json()) .then(data => { setStats({ total_income: data.total_income, total_expense: data.total_expense, net_profit: data.net_profit }); setLoading(false); }) .catch(err => { console.error("Error fetching dashboard stats:", err); setLoading(false); }); }, []); const formatCurrency = (val) => { if (val === undefined || val === null || isNaN(val)) return 'AED 0.00'; return new Intl.NumberFormat('en-AE', { style: 'currency', currency: 'AED' }).format(val); }; return ( <>
{/* Dashboard Title & Filters */}

Owner Dashboard

{/* Branch Selector */}
{/* Date Range */}
From 31 - 01 - 2026
To 02 - 03 - 2026
{/* Stat Cards Grid */}
{/* Main Content Area */}
); }