import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { DollarSign, TrendingUp, Database, AlertTriangle, RefreshCw, Activity } from 'lucide-react'; import { useServiceStats } from '@/hooks/useServices'; import { formatCurrency } from '@/lib/currency'; export function DashboardStats() { const { data: stats, isLoading } = useServiceStats(); if (isLoading) { return (
{[...Array(8)].map((_, i) => (
))}
); } return (
Monthly Spend
{stats?.totalMonthlySpend?.byCurrency?.map((curr, index) => (
{formatCurrency(curr.amount, curr.currency as 'INR' | 'USD' | 'EUR')} {index < (stats.totalMonthlySpend?.byCurrency?.length || 0) - 1 && + }
)) || formatCurrency(0, 'INR')}

Current month active subscriptions

Projected Yearly
{stats?.projectedYearlySpend?.byCurrency?.map((curr, index) => (
{formatCurrency(curr.amount, curr.currency as 'INR' | 'USD' | 'EUR')} {index < (stats.projectedYearlySpend?.byCurrency?.length || 0) - 1 && + }
)) || formatCurrency(0, 'INR')}

Based on current subscriptions

Total Spent
{stats?.totalSpent?.byCurrency?.map((curr, index) => (
{formatCurrency(curr.amount, curr.currency as 'INR' | 'USD' | 'EUR')} {index < (stats.totalSpent?.byCurrency?.length || 0) - 1 && + }
)) || formatCurrency(0, 'INR')}

All time actual payments

This Year Spent
{stats?.yearlySpent?.byCurrency?.map((curr, index) => (
{formatCurrency(curr.amount, curr.currency as 'INR' | 'USD' | 'EUR')} {index < (stats.yearlySpent?.byCurrency?.length || 0) - 1 && + }
)) || formatCurrency(0, 'INR')}

{new Date().getFullYear()} actual payments

Active Services
{stats?.activeServices || 0}

of {stats?.totalServices || 0} total services

Expired Services
{stats?.expiredServices || 0}

Need immediate attention

Auto Renewal
{stats?.autoRenewServices || 0}

Services with auto-renewal enabled

Health Score
{stats?.totalServices ? Math.round((stats.activeServices / stats.totalServices) * 100) : 0}%
0.8 ? "default" : stats?.totalServices && (stats.activeServices / stats.totalServices) > 0.6 ? "secondary" : "destructive" }> {stats?.totalServices && (stats.activeServices / stats.totalServices) > 0.8 ? "Excellent" : stats?.totalServices && (stats.activeServices / stats.totalServices) > 0.6 ? "Good" : "Needs Attention"}

Active vs total services ratio

); }