"use client"; import Link from "next/link"; import useSWR from "swr"; import type { QuotaSummary } from "@/lib/subscription/service"; import { fetcher } from "@/lib/utils"; export function UsageBadge() { const { data } = useSWR( `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/usage`, fetcher, { refreshInterval: 15_000, revalidateOnFocus: true, } ); if (!data) { return null; } const isPro = data.tier === "pro"; const lowQuota = !isPro && (data.messages.remaining <= 2 || data.toolCalls.remaining <= 1); return ( {data.tier} {data.messages.used}/{data.messages.limit} msgs {isPro ? null : } ); }