"use client"; import { useState } from "react"; import { IconCheck, IconCopy, IconExternalLink } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard"; import type { PrepareGitHubAppImportResponse } from "@/lib/types/github"; import { GitHubAppPolicyDialog } from "./github-app-policy-dialog"; import { Trans, useTranslation } from "react-i18next"; import { formatDateTime } from "@/lib/i18n/formats"; // These are the verbatim field names on GitHub's own "Register a new GitHub App" // form, which is English-only. The numeric suffixes preserve the order GitHub // uses for OAuth during installation; they are references to another product's // UI, not our copy. const urlLabels: [keyof PrepareGitHubAppImportResponse, string][] = [ ["public_base_url", "Homepage URL"], ["install_callback_url", "User authorization callback URL 1"], ["personal_callback_url", "User authorization callback URL 2"], ["webhook_url", "Webhook URL"], ]; export function GitHubAppImportGuide({ preparation, settingsUrl, }: { preparation: PrepareGitHubAppImportResponse; settingsUrl?: string; }) { const { t } = useTranslation(); const { copy } = useCopyToClipboard(); const [copied, setCopied] = useState(""); async function copyValue(value: string) { await copy(value); setCopied(value); } return (

{t("github:configureTheExistingAppOnGithub")}

{t("github:setTheseExactUrlsCreateAClientSecret", { expiresAt: formatDateTime(preparation.expires_at), })}

{/* The content-type value is a literal the user selects on GitHub, so it is interpolated rather than written into the catalog. */} For webhooks, choose {"{{contentType}}"} as the content type and keep SSL verification enabled.

{urlLabels.map(([key, label]) => { const value = String(preparation[key]); return (
{label}
{value}
); })}
{settingsUrl ? ( ) : ( )}
); }