From 3f05cd8dfda73593361779c099051acad0c23c49 Mon Sep 17 00:00:00 2001 From: "Rayyan (Rayy)" Date: Mon, 18 Sep 2023 14:09:45 +0000 Subject: [PATCH] Various repairs to broken signup button not submitting data --- src/App.js | 8 ++++-- src/pages/Signup.js | 67 +++++++++++++++++++++++---------------------- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/App.js b/src/App.js index ab4ea1e..307c14a 100644 --- a/src/App.js +++ b/src/App.js @@ -14,7 +14,7 @@ import { Signup } from "./pages/Signup" function App() { const FBapp = initializeApp(FirebaseConfig) - const FBauth = getAuth(FBapp) + const FBauth = getAuth() // navigation array const navItems = [ { label: "Home", link: "/" }, @@ -42,11 +42,13 @@ function App() { // signing up a user const signUp = (email, password) => { createUserWithEmailAndPassword(FBauth, email, password) - .then((userCredential) => { + .then( (userCredential) => { // do something }) .catch((error) => console.log(error.message)) } + + return (
@@ -54,7 +56,7 @@ function App() { } /> } /> } /> - } /> + } />
); diff --git a/src/pages/Signup.js b/src/pages/Signup.js index e70b395..6c3d0cb 100644 --- a/src/pages/Signup.js +++ b/src/pages/Signup.js @@ -6,50 +6,51 @@ import Button from "react-bootstrap/Button" import {useState, useEffect} from 'react'; export function Signup ( props ) { - const[username,setUsername] = useState('') + const[username,setUsername] = useState('') const[validusername,setValidusername] = useState(false) - const[useremail,setUseremail] = useState('') - const[validemail,setValidemail] = useState(false) - const[password,setUserpassword] = useState('') + const[useremail,setUseremail] = useState('') + const[validemail,setValidemail] = useState(false) + const[userpassword,setUserpassword] = useState('') const[validpassword,setValidpassword] = useState(false) + const submitHandler = (evt) => { - evt.preventDefault() - props.handler(useremail, password) + evt.preventDefault() + props.handler( useremail, userpassword ) } - + useEffect( () => { - if(username.length >= 4) { - setValidusername(true) - } - else { - setValidusername(false) - } - }, [username] ) - - useEffect( () => { - if(useremail.indexOf('@') > 0 ) { - setValidemail(true) - } - else { - setValidemail(false) - } - }, [useremail] ) - - useEffect( () => { - if( password.length >= 8 ) { - setValidpassword(true) - } - else{ - setValidpassword(false) - } - }, [password] ) + if( username.length >= 4 ) { + setValidusername(true) + } + else { + setValidusername(false) + } + }, [username] ) + + useEffect( () => { + if( useremail.indexOf('@') > 0 ) { + setValidemail(true) + } + else { + setValidemail(false) + } + }, [useremail]) + + useEffect( () => { + if( userpassword.length >= 8 ) { + setValidpassword(true) + } + else{ + setValidpassword(false) + } + }, [userpassword]) return ( -
+ Username