"use client"; import { useTranslations } from "next-intl"; import moment from "moment"; import { Button } from "@app/components/ui/button"; import CopyTextBox from "@app/components/CopyTextBox"; import CopyToClipboard from "@app/components/CopyToClipboard"; import { AiClientConfigSection } from "@app/components/ai-client-config/AiClientConfigSection"; import { SettingsContainer, SettingsFormCell, SettingsFormGrid, SettingsSection, SettingsSectionBody, SettingsSectionDescription, SettingsSectionHeader, SettingsSectionTitle as SectionTitle } from "@app/components/Settings"; import { useMyVirtualApiKeySecret } from "@app/hooks/useMyVirtualApiKeySecret"; import type { ListMyVirtualApiKeysResponse, VirtualApiKeyWithResources } from "@server/routers/virtualApiKey/types"; import { formatVirtualApiKeyPreview } from "@app/lib/virtualApiKeyFormat"; type UserVirtualApiKeysProps = { orgId: string; initialData: ListMyVirtualApiKeysResponse; /** The resource's niceId, when this page is scoped to a single resource. */ resourceNiceId?: string; /** The resource's real access URL, when known; falls back to a placeholder otherwise. */ endpoint?: string; }; function OwnedKeySecret({ orgId, virtualApiKeyId, lastChars }: { orgId: string; virtualApiKeyId: string; lastChars: string; }) { const t = useTranslations(); const preview = formatVirtualApiKeyPreview(virtualApiKeyId, lastChars); const { credential, revealed, loading, getCopyText, revealSecret } = useMyVirtualApiKeySecret(orgId, virtualApiKeyId); const displayValue = revealed && credential ? credential : preview; return (
{description}
{keyRow.name || t("myVirtualApiKeysUnnamed")}
{keyRow.description}
) : null}{t("created")} {moment(keyRow.createdAt).format("lll")}