"use client"; import { useActionState, useState } from "react"; import { Fieldset } from "@unlocalhosted/metalui"; import type { FormState } from "@/app/actions/types"; import { RepoChecklist, type RepoOption } from "@/components/repo-checklist"; import { ChoiceCards } from "@/components/settings-fields"; import { PlateBody, PlateFooter } from "@/components/settings-plate"; import { Alert, Button } from "@/components/ui"; export function AuthorizeForm({ action, requested, repos, destination, }: { action: (prev: FormState, formData: FormData) => Promise; /** What the application asked for; read-only requests can't be widened here. */ requested: "read" | "write"; repos: RepoOption[]; destination: string; }) { const [state, formAction, pending] = useActionState(action, undefined); const [permission, setPermission] = useState(requested); const [scope, setScope] = useState<"all" | "selected">("all"); return (
Permissions {requested === "write" ? ( ) : ( <>

Read-only: it can read code, issues and workflow runs, but change nothing.

)}
Repository access {scope === "selected" && }
{state?.error && {state.error}}

Authorizing sends you back to {destination}. You can disconnect it any time under Settings → Connected apps.

); }