import { createFileRoute } from "@tanstack/react-router"; import { redirectSignedIn } from "~/lib/route-guards"; import { useState } from "react"; import { requestPasswordResetEmail } from "~/fns/login"; import { useAction } from "~/hooks/use-action"; import { AuthCard } from "~/components/AuthCard"; import { Button } from "~/ui/Button"; import { TextField } from "~/ui/Field"; import { ErrorBanner } from "~/ui/Callout"; import { TextLink } from "~/ui/TextLink"; export const Route = createFileRoute("/forgot-password")({ beforeLoad: redirectSignedIn, head: () => ({ meta: [{ title: "Reset your password ยท gitfor" }] }), component: ForgotPasswordPage, }); function ForgotPasswordPage() { const action = useAction(requestPasswordResetEmail, { invalidate: false }); const [sent, setSent] = useState(false); return ( {sent ? (

If an account uses that address, a reset link is on its way. It expires in one hour.

) : (
{ event.preventDefault(); const email = String(new FormData(event.currentTarget).get("email") ?? ""); if (await action.run({ data: { email } })) setSent(true); }} > )}

Back to sign in

); }