import { IconBrandGithub, IconKey, IconTerminal2 } from "@tabler/icons-react"; import { Label } from "@kandev/ui/label"; import { RadioGroup, RadioGroupItem } from "@kandev/ui/radio-group"; import { cn } from "@/lib/utils"; import { useTranslation } from "react-i18next"; export type GitHubAutomationMethod = "pat" | "cli" | "app"; // `value` is the wire enum the connection form switches on — never translated. // The copy travels as catalog keys resolved at render: a `t()` call here would // be module scope and freeze at the boot locale (see docs/i18n.md). Every entry // carries both keys, so `t()` never receives `string | undefined`. type AuthMethodOption = { value: GitHubAutomationMethod; labelKey: string; descriptionKey: string; icon: typeof IconTerminal2; }; const methods: AuthMethodOption[] = [ { value: "cli", labelKey: "github:githubCliAccount", descriptionKey: "github:resolvedFromOneNamedHostAccount", icon: IconTerminal2, }, { value: "pat", labelKey: "github:personalAccessToken", descriptionKey: "github:storedEncryptedByKandevWorkspaceAutomation", icon: IconKey, }, { value: "app", labelKey: "github:githubApp", descriptionKey: "github:storedAppCredentialsMintShortLived", icon: IconBrandGithub, }, ]; export function GitHubAuthMethodList({ value, onChange, }: { value: GitHubAutomationMethod; onChange: (value: GitHubAutomationMethod) => void; }) { const { t } = useTranslation(); return ( onChange(next as GitHubAutomationMethod)} className="grid gap-2 sm:grid-cols-3" aria-label={t("github:connectionMethod")} > {methods.map((method) => { const Icon = method.icon; return ( ); })} ); }