import type { ProviderQuotaResult } from "@paperclipai/shared"; import { formatDateTime } from "../lib/utils"; import { QuotaBar } from "./QuotaBar"; import { quotaUnavailableMessage } from "../lib/quota-refresh"; export function AccountQuotaPanels({ accounts, failed, }: { accounts: ProviderQuotaResult[]; failed?: boolean; }) { return (
{accounts.map((account) => (

{account.accountLabel ?? "Subscription account"}

{(failed || !account.ok) && (

{account.errorFamily === "credentials_unavailable" ? "Connect or reconnect a subscription in AI connections to view its quota." : quotaUnavailableMessage(account.windows.length > 0)}

)} {account.windows.map((window, index) => window.usedPercent == null ? (
{window.label} {window.valueLabel ?? "Usage not reported"}
{window.resetsAt &&

Resets {formatDateTime(window.resetsAt)}

}
) : ( ))} {account.capturedAt && (

Last checked {formatDateTime(account.capturedAt)}

)}
))}
); }