"use client"; import { KeyRound } from "lucide-react"; import React, { useState } from "react"; import { Button, Card, Field, Heading, Notice } from "@crosscode/ui"; import { PublicShell } from "@/components/PublicShell"; import { useBranding } from "@/components/BrandingProvider"; import { call, selfSignIn } from "@/lib/api"; export function Reset({ token }: { token: string | null }) { const branding = useBranding(); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); return ( } sub="At least 8 characters.">Choose a new password {error && {error}}
{ e.preventDefault(); setBusy(true); const r = await call<{ uid: string | null; returnUrl: string | null }>("POST", "/password/reset", { token, password: new FormData(e.currentTarget).get("password") }); setBusy(false); if (!r.ok) return setError(r.error.message); // Back to the sign-in it started from (and on to that site), to the product that made the // account (its sign-in brings them straight back here signed in), or to the account page. window.location.assign(r.data.uid ? `/signin?uid=${encodeURIComponent(r.data.uid)}` : r.data.returnUrl ?? selfSignIn("/account")); }}>
); }