/opt/canhelp/apps/web/src/components
Edit: /opt/canhelp/apps/web/src/components/UsageMeter.tsx (1602B)
import type { DashboardData } from '@/lib/api'
interface UsageMeterProps {
current: number
limit: number | null
label: string
className?: string
}
export function UsageMeter({ current, limit, label, className = '' }: UsageMeterProps) {
if (limit === null) {
return (
)
}
const pct = limit > 0 ? Math.min(100, Math.round((current / limit) * 100)) : 100
const remaining = Math.max(0, limit - current)
const barColor =
pct >= 100
? 'bg-red-500'
: pct >= 80
? 'bg-amber-400'
: 'bg-green-500'
const textColor =
pct >= 100
? 'text-red-600'
: pct >= 80
? 'text-amber-600'
: 'text-gray-600'
return (
{label}
{remaining} / {limit}
)
}