import { useNavigate } from "@tanstack/react-router"; import { useState } from "react"; import { transferRepo } from "~/fns/profile"; import { transferableOwners } from "~/fns/repos"; import { useAction } from "~/hooks/use-action"; import { Button } from "~/ui/Button"; import { SelectField, TextField } from "~/ui/Field"; import { ErrorBanner } from "~/ui/Callout"; import { Panel } from "~/ui/Panel"; export function TransferRepoPanel({ owner, repo }: { owner: string; repo: string }) { const navigate = useNavigate(); const transfer = useAction(transferRepo, { invalidate: false }); const [targets, setTargets] = useState(null); return (

Move this repository to another account you can create repositories in. Old URLs and git remotes redirect.

{targets === null ? ( ) : targets.length === 0 ? (

There are no other accounts you can transfer to.

) : (
{ event.preventDefault(); const form = new FormData(event.currentTarget); const result = await transfer.run({ data: { owner, repo, newOwner: String(form.get("newOwner") ?? ""), confirm: String(form.get("confirm") ?? ""), }, }); if (result) { await navigate({ to: "/$owner/$repo", params: { owner: result.owner, repo: result.name } }); } }} > ({ value: name, label: name }))} /> )}
); }