"use client"; import { useTranslations } from "next-intl"; import { useState, useEffect, useCallback } from "react"; import { Card } from "@/shared/components"; export default function RateLimitStatus() { const t = useTranslations("usage"); const tc = useTranslations("common"); const [data, setData] = useState({ lockouts: [], cacheStats: null }); const [loading, setLoading] = useState(true); const load = useCallback(async () => { try { const res = await fetch("/api/rate-limits"); if (res.ok) setData(await res.json()); } catch { } finally { setLoading(false); } }, []); useEffect(() => { load(); const interval = setInterval(load, 10000); return () => clearInterval(interval); }, [load]); const formatMs = (ms) => { if (ms < 1000) return t("durationMillisecondsShort", { value: ms }); if (ms < 60000) return t("durationSecondsShort", { value: Math.ceil(ms / 1000) }); return t("durationMinutesShort", { value: Math.ceil(ms / 60000) }); }; return (
{/* {t("modelLockouts")} */}

{t("modelLockouts")}

{t("lockoutsAutoRefreshHint")}

{data.lockouts.length > 0 && ( {t("lockedCount", { count: data.lockouts.length })} )}
{data.lockouts.length === 0 ? (

{t("noLockouts")}

) : (
{data.lockouts.map((lock, i) => (

{lock.model}

{t("account")}:{" "} {lock.accountId?.slice(0, 12) || tc("none")} {lock.reason && ( <> {t("reasonSeparator")} {lock.reason} )}

{t("timeLeft", { time: formatMs(lock.remainingMs) })}
))}
)}
); }