"use client" import { useState } from "react" import Link from "next/link" import { useRouter } from "next/navigation" import { createSupabaseBrowserClient } from "@/lib/supabase/client" export default function ResetPasswordPage() { const [newPassword, setNewPassword] = useState("") const [confirmPassword, setConfirmPassword] = useState("") const [errorMessage, setErrorMessage] = useState(null) const [isSubmitting, setIsSubmitting] = useState(false) const [isPasswordUpdated, setIsPasswordUpdated] = useState(false) const router = useRouter() async function handlePasswordUpdate(event: React.FormEvent) { event.preventDefault() setErrorMessage(null) if (newPassword !== confirmPassword) { setErrorMessage("passwords do not match") return } setIsSubmitting(true) const supabaseClient = createSupabaseBrowserClient() const { error } = await supabaseClient.auth.updateUser({ password: newPassword, }) if (error) { setErrorMessage(error.message) setIsSubmitting(false) return } setIsPasswordUpdated(true) } if (isPasswordUpdated) { return ( <>

password updated

your password has been changed successfully

go to reader ) } return ( <>

reset password

enter your new password

setNewPassword(event.target.value)} required minLength={8} className="w-full border border-border bg-background-secondary px-3 py-2 text-text-primary outline-none placeholder:text-text-dim focus:border-text-dim" />
setConfirmPassword(event.target.value)} required minLength={8} className="w-full border border-border bg-background-secondary px-3 py-2 text-text-primary outline-none placeholder:text-text-dim focus:border-text-dim" />
{errorMessage && (

{errorMessage}

)}
back to sign in ) }