import { getProjects } from "@/data/projects" import { getDashboardStats, getProjectStats, StatsFilters } from "@/data/stats" import { formatCurrency } from "@/lib/utils" import { ArrowDown, ArrowUp, BicepsFlexed } from "lucide-react" import { Card, CardContent, CardHeader, CardTitle } from "../ui/card" import { FiltersWidget } from "./filters-widget" import { ProjectsWidget } from "./projects-widget" export async function StatsWidget({ filters }: { filters: StatsFilters }) { const projects = await getProjects() const stats = await getDashboardStats(filters) const statsPerProject = Object.fromEntries( await Promise.all( projects.map((project) => getProjectStats(project.code, filters).then((stats) => [project.code, stats])) ) ) return (

Overview

Total Income {Object.entries(stats.totalIncomePerCurrency).map(([currency, total]) => (
{formatCurrency(total, currency)}
))} {!Object.entries(stats.totalIncomePerCurrency).length &&
0.00
}
Total Expenses {Object.entries(stats.totalExpensesPerCurrency).map(([currency, total]) => (
{formatCurrency(total, currency)}
))} {!Object.entries(stats.totalExpensesPerCurrency).length &&
0.00
}
Net Profit {Object.entries(stats.profitPerCurrency).map(([currency, total]) => (
{formatCurrency(total, currency)}
))} {!Object.entries(stats.profitPerCurrency).length &&
0.00
}
Processed Transactions
{stats.invoicesProcessed}

Projects

) }