2026-04-15 17:02:00 -07:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import { OctagonAlert, Orbit } from "lucide-react";
|
|
|
|
|
import Link from "next/link";
|
2026-05-31 15:58:21 -07:00
|
|
|
import { Button } from "@/components/ui/button";
|
2026-04-15 17:02:00 -07:00
|
|
|
import { Progress } from "@/components/ui/progress";
|
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
|
|
|
|
|
interface QuotaBarProps {
|
|
|
|
|
used: number;
|
|
|
|
|
limit: number;
|
|
|
|
|
warningThreshold: number;
|
|
|
|
|
className?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function QuotaBar({ used, limit, warningThreshold, className }: QuotaBarProps) {
|
|
|
|
|
const percentage = Math.min((used / limit) * 100, 100);
|
|
|
|
|
const remaining = Math.max(limit - used, 0);
|
|
|
|
|
const isWarning = used >= warningThreshold;
|
|
|
|
|
const isExceeded = used >= limit;
|
|
|
|
|
|
|
|
|
|
return (
|
2026-05-31 15:58:21 -07:00
|
|
|
<div className={cn("flex flex-col gap-1.5", className)}>
|
|
|
|
|
<div className="flex items-center justify-between text-xs">
|
2026-04-15 17:02:00 -07:00
|
|
|
<span className="text-muted-foreground">
|
|
|
|
|
{used.toLocaleString()} / {limit.toLocaleString()} tokens
|
|
|
|
|
</span>
|
|
|
|
|
{isExceeded ? (
|
2026-05-31 15:58:21 -07:00
|
|
|
<span className="font-medium text-destructive">Limit reached</span>
|
2026-04-15 17:02:00 -07:00
|
|
|
) : isWarning ? (
|
2026-05-31 15:58:21 -07:00
|
|
|
<span className="flex items-center gap-1 font-medium text-highlight">
|
|
|
|
|
<OctagonAlert className="size-3" />
|
2026-04-15 17:02:00 -07:00
|
|
|
{remaining.toLocaleString()} remaining
|
|
|
|
|
</span>
|
|
|
|
|
) : (
|
|
|
|
|
<span className="font-medium">{percentage.toFixed(0)}%</span>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2026-05-31 15:58:21 -07:00
|
|
|
<Progress value={percentage} className="h-1.5" />
|
2026-04-15 17:02:00 -07:00
|
|
|
{isExceeded && (
|
2026-05-31 15:58:21 -07:00
|
|
|
<Button asChild size="sm" className="mt-0.5 w-full">
|
|
|
|
|
<Link href="/register">
|
|
|
|
|
<Orbit data-icon="inline-start" />
|
|
|
|
|
Create free account for 5M more tokens
|
|
|
|
|
</Link>
|
|
|
|
|
</Button>
|
2026-04-15 17:02:00 -07:00
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|