"use client"; import Link from "next/link"; import { useState } from "react"; import { supabase } from "@/lib/supabase"; export default function ResetPasswordPage() { const [email, setEmail] = useState(""); const [message, setMessage] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const handleResetPassword = async (e: React.FormEvent) => { e.preventDefault(); setError(""); setMessage(""); setLoading(true); // Validação if (!email) { setError("Por favor, insira seu email"); setLoading(false); return; } const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; if (!emailRegex.test(email)) { setError("Email inválido"); setLoading(false); return; } try { const { error: resetError } = await supabase.auth.resetPasswordForEmail( email, { redirectTo: `${window.location.origin}/auth/callback`, }, ); if (resetError) throw resetError; setMessage("Email enviado! Verifique sua caixa de entrada."); setEmail(""); // Limpar campo } catch (err) { const error = err as Error; setError(error.message || "Erro ao enviar email. Tente novamente."); } finally { setLoading(false); } }; return (
{/* Logo */}

AutomatizaSE

Recuperar Senha

{/* Form */}
setEmail(e.target.value)} className="mt-1 block w-full px-3 py-2 bg-gray-800 border border-gray-700 rounded-md text-white focus:outline-none focus:ring-2 focus:ring-primary-500" placeholder="seu@email.com" />
{message && (
{message}
)} {error && (
{error}
)}
← Voltar para login
); }