import type { ReactNode } from "react"; import type { PoolOverview, PoolSubscriptionState } from "@peppa/core"; import { intlLocale, type Locale } from "@peppa/shared/i18n"; import { Badge } from "@/components/ui/badge"; import { getT } from "@/lib/i18n"; const hhmm = (d: Date, locale: Locale) => d.toLocaleTimeString(intlLocale(locale), { hour: "2-digit", minute: "2-digit", timeZone: process.env.PEPPA_TZ || undefined }); const KIND: Record = { claude: "Claude", codex: "ChatGPT", opencode: "OpenCode" }; function tone(s: PoolSubscriptionState): "ok" | "warn" | "danger" | "muted" | "primary" { if (s.status === "auth_error") return "danger"; if (s.status === "pending") return "muted"; if (s.limitedUntil) return "warn"; return s.activeSessions ? "primary" : "ok"; } /** * PEP-107: the subscriptions of a pool as people see them — which one is at work, which is * free, when a limit resets, how full the usage window is; `action` adds a button per row. */ export async function PoolSubscriptions({ o, action }: { o: PoolOverview; action?: (s: PoolSubscriptionState) => ReactNode }) { const t = await getT(); if (!o.subscriptions.length) return

{t("В пуле нет подписок.")}

; return ( ); } /** One line under the list: is there a spare, does anyone wait. */ export async function PoolSummary({ o }: { o: PoolOverview }) { const t = await getT(); const parts: string[] = []; if (o.usableCount === 0) parts.push(t("рабочих подписок нет — агенты ждут сброса")); else if (o.usableCount === 1) parts.push(t("запасной подписки нет: на лимите агенты встанут до сброса")); else parts.push(t("рабочих подписок: {n} — на лимите агент переедет на свободную", { n: o.usableCount })); if (o.waiting) parts.push(t("ждут сброса: {n}", { n: o.waiting })); return

{parts.join(" · ")}

; }