'use client' import { cn, formatCurrency } from '@/lib/utils' interface BudgetRingProps { spent: number total: number label: string } export function BudgetRing({ spent, total, label }: BudgetRingProps) { const percentage = total > 0 ? Math.min((spent / total) * 100, 100) : 0 const remaining = Math.max(total - spent, 0) const getColor = () => { if (percentage < 70) return { stroke: '#10b981', bg: 'text-emerald-400' } if (percentage < 90) return { stroke: '#f59e0b', bg: 'text-amber-400' } return { stroke: '#ef4444', bg: 'text-red-400' } } const colors = getColor() const radius = 80 const strokeWidth = 12 const normalizedRadius = radius - strokeWidth / 2 const circumference = normalizedRadius * 2 * Math.PI const strokeDashoffset = circumference - (percentage / 100) * circumference return (
{/* Background circle */} {/* Progress circle */} {/* Center content */}
{percentage.toFixed(0)}% usado
{/* Stats below */}

{label}

{formatCurrency(spent)} / {formatCurrency(total)}

{formatCurrency(remaining)} disponible

) }