"use client"; import * as React from "react"; import { cn } from "./lib/utils"; export interface UsageMeterProps extends React.HTMLAttributes { label: string; used: number; limit: number; unit?: string; } /** Usage meter gauge: filled bar + percentage + threshold alert. */ export function UsageMeter({ label, used, limit, unit = "", className, ...props }: UsageMeterProps) { const pct = Math.min(100, Math.round((used / Math.max(1, limit)) * 100)); const tone = pct >= 100 ? "bg-destructive" : pct >= 80 ? "bg-warning" : "bg-accent"; const over = used > limit; return (
{label} {used.toLocaleString("tr-TR")} / {limit.toLocaleString("tr-TR")} {unit}
%{pct} {over && ( Quota exceeded )} {!over && pct >= 80 && Approaching quota limit}
); }