"use client"; import { useState } from "react"; import Card from "@/shared/components/Card"; import ProviderIcon from "@/shared/components/ProviderIcon"; import Badge from "@/shared/components/Badge"; import QuotaProgressBar from "./QuotaProgressBar"; import { calculatePercentage } from "./utils"; const planVariants = { free: "default", pro: "primary", ultra: "success", enterprise: "info", }; export default function ProviderLimitCard({ provider, name, plan, quotas = [], message = null, loading = false, error = null, onRefresh, }) { const [refreshing, setRefreshing] = useState(false); const handleRefresh = async () => { if (!onRefresh || refreshing) return; setRefreshing(true); try { await onRefresh(); } finally { setRefreshing(false); } }; // Get provider info from config const getProviderColor = () => { const colors = { github: "#000000", antigravity: "#4285F4", codex: "#10A37F", kiro: "#FF9900", qoder: "#EC4899", claude: "#D97757", }; return colors[provider?.toLowerCase()] || "#6B7280"; }; const providerColor = getProviderColor(); const planVariant = planVariants[plan?.toLowerCase()] || "default"; return ( {/* Header */}
{/* Provider Logo */}

{name || provider}

{plan && ( {plan} )}
{/* Refresh Button */}
{/* Loading State */} {loading && (
)} {/* Error State */} {!loading && error && (
error

{error}

)} {/* Info Message (for providers without API) */} {!loading && !error && message && (
info

{message}

)} {/* Quota Progress Bars */} {!loading && !error && !message && quotas?.length > 0 && (
{quotas.map((quota, index) => { // For Antigravity, use remainingPercentage if available, otherwise calculate const percentage = quota.remainingPercentage !== undefined ? Math.round(((quota.total - quota.used) / quota.total) * 100) : calculatePercentage(quota.used, quota.total); const unlimited = quota.total === 0 || quota.total === null; return ( ); })}
)} {/* Empty State */} {!loading && !error && !message && quotas?.length === 0 && (
data_usage

No quota data available

)} ); }