import { Input } from "@kandev/ui/input"; import { Label } from "@kandev/ui/label"; import { RadioGroup, RadioGroupItem } from "@kandev/ui/radio-group"; import { Textarea } from "@kandev/ui/textarea"; import type { GitHubAppOwnerType, GitHubAppVisibility } from "@/lib/types/github"; import type { AppSetupErrors } from "./github-app-onboarding-model"; import { useTranslation } from "react-i18next"; export type GitHubAppImportValues = { displayName: string; ownerLogin: string; ownerType: GitHubAppOwnerType; publicBaseUrl: string; visibility: GitHubAppVisibility; appId: string; clientId: string; clientSecret: string; privateKey: string; webhookSecret: string; slug: string; }; type Update = (name: keyof GitHubAppImportValues, value: string) => void; export function GitHubAppImportIdentityFields({ values, errors, update, }: { values: GitHubAppImportValues; errors: AppSetupErrors; update: Update; }) { const { t } = useTranslation(); return (
update("displayName", e.target.value)} /> update("slug", e.target.value)} /> update("ownerLogin", e.target.value)} />
update("ownerType", value)} className="flex min-h-11 flex-wrap items-center gap-5" >
); } export function GitHubAppImportSecretFields({ values, errors, update, }: { values: GitHubAppImportValues; errors: AppSetupErrors; update: Update; }) { const { t } = useTranslation(); // Keys are the value/error field names; only the labels are copy. Resolved // here rather than at module scope so they follow a locale switch. const labels = { appId: t("github:appId"), clientId: t("github:clientId"), clientSecret: t("github:clientSecret"), webhookSecret: t("github:webhookSecret"), } as const; return (
{(Object.keys(labels) as (keyof typeof labels)[]).map((name) => ( update(name, event.target.value)} /> ))}