SocialBuddyAdmin/components/auth/components-auth-forgot-form.tsx
2026-02-17 12:36:09 +05:30

88 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
import React, { useState } from "react";
import axios from "axios";
import { Mail } from "lucide-react";
export default function ForgotPasswordForm() {
const [email, setEmail] = useState("");
const [loading, setLoading] = useState(false);
const [message, setMessage] = useState("");
const handleForgot = async (e: React.FormEvent) => {
e.preventDefault();
setLoading(true);
setMessage("");
try {
await axios.post(
"https://api.socialbuddy.co/api/auth/forgot-password",
{ email }
);
setMessage("✅ Weve emailed you a reset code / link. Enter it below.");
} catch (err) {
console.error(err);
setMessage("❌ Something went wrong. Try again.");
} finally {
setLoading(false);
}
};
return (
<form onSubmit={handleForgot} className="space-y-5">
{/* Email */}
<div>
<label className="block text-sm font-medium text-white-dark mb-1">
Email
</label>
<div className="relative">
{/* Icon */}
<Mail
className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-400"
size={18}
/>
<input
type="email"
required
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="Enter your email"
className="
form-input w-full
ps-12
bg-[#0F172A] text-white
placeholder:text-gray-400
border border-white/10
rounded-xl
focus:border-cyan-400
focus:ring-1 focus:ring-cyan-400
"
/>
</div>
</div>
{/* Button */}
<button
type="submit"
disabled={loading}
className="
w-full py-3 rounded-xl text-lg font-semibold text-white
bg-gradient-to-r from-blue-600 to-pink-500
shadow-lg transition-all hover:opacity-90 hover:scale-[1.02]
disabled:opacity-60 mb-3
"
>
{loading ? "Sending..." : "Send Reset Link"}
</button>
{/* Message */}
{message && (
<p className="mt-2 text-center text-sm font-semibold text-primary">
{message}
</p>
)}
</form>
);
}