From 644fe59e7742c81b2e90155f69275b97896cc553 Mon Sep 17 00:00:00 2001 From: Francisco Pessano Date: Sat, 25 Sep 2021 19:48:23 -0300 Subject: [PATCH] Logic for form added --- .../Identify Childrens/LoginForm.jsx | 21 ++++++-- .../Identify Childrens/RegisterForm.jsx | 37 ++++++++++--- src/components/Identify.jsx | 54 +++++++++++++++++-- 3 files changed, 98 insertions(+), 14 deletions(-) diff --git a/src/components/Identify Childrens/LoginForm.jsx b/src/components/Identify Childrens/LoginForm.jsx index 6710d65..0b5e61c 100644 --- a/src/components/Identify Childrens/LoginForm.jsx +++ b/src/components/Identify Childrens/LoginForm.jsx @@ -1,10 +1,23 @@ import React from 'react' -const LoginForm = () => { +const LoginForm = (props) => { return ( -
- - + + { + props.setEmail(e.target.value) + }} + /> + + { + props.setPassword(e.target.value) + }} + />
) diff --git a/src/components/Identify Childrens/RegisterForm.jsx b/src/components/Identify Childrens/RegisterForm.jsx index d523c1b..d89723c 100644 --- a/src/components/Identify Childrens/RegisterForm.jsx +++ b/src/components/Identify Childrens/RegisterForm.jsx @@ -1,12 +1,37 @@ import React from 'react' -const RegisterForm = () => { +const RegisterForm = (props) => { return ( -
- - - - + + { + props.setEmail(e.target.value) + }} + /> + + { + props.setPassword(e.target.value) + }} + + /> + + { + props.setConfirmPassword(e.target.value) + }} + /> + +
) } diff --git a/src/components/Identify.jsx b/src/components/Identify.jsx index a7c2009..a8e4fc9 100644 --- a/src/components/Identify.jsx +++ b/src/components/Identify.jsx @@ -4,7 +4,11 @@ import RegisterForm from './Identify Childrens/RegisterForm' const Identify = () => { - const [act, setAct] = useState('register') + const [act, setAct] = useState('') + + const [email, setEmail] = useState('') + const [password, setPassword] = useState('') + const [confirmPassword, setConfirmPassword] = useState('') const defineLogin = () => { if (act !== 'login') { @@ -17,6 +21,48 @@ const Identify = () => { setAct('register') } } + + const sendForm = (e) => { + e.preventDefault() + + if (!email.trim()) { + alert('EMAIL EMPTY') + return + } + + if (!password.trim()) { + alert('PASSWORD EMPTY') + return + } + + if (act === 'register') { + + if (!confirmPassword.trim()) { + alert('CONFIRM PASSWORD PLEASE') + return + } + + e.target.reset() + setEmail('') + setPassword('') + setConfirmPassword('') + + //SEND TO FIREBASE + return + } + + if (act === 'login') { + + e.target.reset() + setEmail('') + setPassword('') + + //SEND TO FIREBASE + return + } + + alert('ACTION NOT VALID') + } React.useEffect( () => { const urlInfo = new URLSearchParams(window.location.search) @@ -56,7 +102,7 @@ const Identify = () => { className={ act === 'register' ? 'option active-option': 'option' } - + onClick={() => { defineRegister() }} @@ -69,10 +115,10 @@ const Identify = () => {
{ - act === 'login' ? : null + act === 'login' ? : null } { - act === 'register' ? : null + act === 'register' ? : null }