import { useNavigate } from "@tanstack/react-router"; import { renameAccount } from "~/fns/profile"; import { useAction } from "~/hooks/use-action"; import { Button } from "~/ui/Button"; import { TextField } from "~/ui/Field"; import { ErrorBanner } from "~/ui/Callout"; import { Panel } from "~/ui/Panel"; export function RenamePanel({ account, hasPassword }: { account: string; hasPassword: boolean }) { const rename = useAction(renameAccount, { invalidate: false }); const navigate = useNavigate(); return (
{ event.preventDefault(); const form = new FormData(event.currentTarget); const result = await rename.run({ data: { account, newName: String(form.get("newName") ?? ""), password: String(form.get("password") ?? "") }, }); if (result) await navigate({ to: "/$owner", params: { owner: result.name }, reloadDocument: true }); }} >

Links and git remotes using {account} keep redirecting until someone else claims the name.

{hasPassword && ( )}
); }