import './Login.css' import React, { useState } from 'react' import 'bootstrap/dist/css/bootstrap.css'; export default function SignUp() { const [firstName, setFirstName] = useState(''); const [lastName, setLastName] = useState(''); const [name, setName] = useState(''); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [errorText, setErrorText] = useState(null); function handleSubmit(event) { event.preventDefault(); // Combine firstname and lastname into name field const name = `${firstName} ${lastName}`; setName(name); const formData = new FormData(); formData.append('name', name); formData.append('email', email); formData.append('password', password); // Send the form data via HTTP using Fetch API fetch(`https://api.bb.gabefarrell.com/auth/createaccount?name=${name}&email=${email}&password=${password}`, { method: 'POST', body: formData, }) .then((response) => response.json()) .then((data) => { if (data.status != 200) { console.log(data.error); setErrorText(data.error); } else { const session = data.session; document.cookie = `session=${session}; path=/;` window.location.href = '/dashboard'; } console.log(data); // Log the response from the server }) .catch((error) => { console.error(error); // Log any errors setErrorText(error); }); } (() => { // Fetch all the forms we want to apply custom Bootstrap validation styles to const forms = document.querySelectorAll('.needs-validation') // Loop over them and prevent submission Array.from(forms).forEach(form => { form.addEventListener('submit', event => { if (!form.checkValidity()) { event.preventDefault(); event.stopPropagation(); } form.classList.add('was-validated') }, false) }) })() return (