import { useState } from "react"; import { FiEye, FiEyeOff } from "react-icons/fi"; import { Link } from "react-router-dom"; import toast, { Toaster } from "react-hot-toast"; // const API_BASE_URL = process.env.REACT_APP_API_URL; const API_BASE_URL = import.meta.env.VITE_API_URL; const SignUp = () => { const [formData, setFormData] = useState({ firstname: "", lastname: "", email: "", password: "", confirmPassword: "", }); const [showPassword, setShowPassword] = useState(false); const [showConfirmPassword, setShowConfirmPassword] = useState(false); const [loading, setLoading] = useState(false); const handleChange = (e) => { setFormData((prev) => ({ ...prev, [e.target.name]: e.target.value, })); }; const handleSubmit = async (e) => { e.preventDefault(); if (formData.password !== formData.confirmPassword) { toast.error("Passwords do not match."); return; } try { setLoading(true); const toastId = toast.loading("Registering..."); const response = await fetch(`${API_BASE_URL}/api/signup`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ firstname: formData.firstname, lastname: formData.lastname, email: formData.email, password: formData.password, }), }); const data = await response.json(); if (response.ok) { toast.success("Successfully registered!", { id: toastId }); // Optionally redirect to login } else { toast.error(data.message || "Signup failed.", { id: toastId }); } } catch (error) { toast.error("An error occurred. Please try again.", error); } finally { setLoading(false); } }; return (

Sign Up

{/* Password Field */}
{/* Confirm Password Field */}
{/* Sign Up Button */}
{/* Redirect to Login */}

Already have an account?{" "} Login

); }; export default SignUp; // // eslint-disable-next-line no-unused-vars // import React, { useState } from "react"; // import { FiEye, FiEyeOff } from "react-icons/fi"; // import { Link } from "react-router-dom"; // const SignUp = () => { // const [showPassword, setShowPassword] = useState(false); // const [showConfirmPassword, setShowConfirmPassword] = useState(false); // return ( //
//
//

Sign Up

// {/* Form Fields */} //
// // // // {/* Password Field */} //
// // //
// {/* Confirm Password Field */} //
// // //
//
// {/* Sign Up Button */} // // {/* Redirect to Login */} //

// Already have an account?{" "} // // Login // //

//
//
// ); // }; // export default SignUp;