peppa/apps/web/components/SubscriptionName.tsx
2026-11-15 19:11:04 +05:00

13 lines
675 B
TypeScript

import type { SessionView } from "@peppa/core";
import { subscriptionNamesVisible } from "@/lib/auth";
/**
* PEP-121: the name of the subscription an agent runs on — for a superadmin only (it carries
* the login of whoever connected it). Others get `fallback` (nothing by default).
*/
export async function SubscriptionName({ s, prefix = "", fallback = null }: { s: Pick<SessionView, "subscriptionName" | "subscriptionId">; prefix?: string; fallback?: string | null }) {
if (!(await subscriptionNamesVisible())) return fallback;
const name = s.subscriptionName ?? (s.subscriptionId ? `#${s.subscriptionId}` : null);
return name ? `${prefix}${name}` : fallback;
}