import React, {useState} from "react"; import FlexibleForm from "../components/FlexibleForm"; import benefitTwoImg from "../assets/img/benefit-two.png"; const Login = () => { const [formData, setFormData] = useState({ email: "", password: "", }); const handleChange = (e) => { const { name, value } = e.target; setFormData((prevData) => ({ ...prevData, [name]: value, })); }; const handleSubmit = async (event) => { event.preventDefault(); const { email, password } = formData; const basicAuth = btoa(`${email}:${password}`) console.log(basicAuth) try { const response = await fetch(process.env.REACT_APP_LOGIN_ROUTE, { method: "POST", headers: { 'Content-Type': 'application/json', 'Authorization': `Basic ${basicAuth}`, }, }); if (response.ok) { const data = await response console.log("Login successful", data) } else { console.error("Login failed") } } catch (error) { console.error('Error submitting form:', error); } } return ( <> ); }; export default Login;