From 1c37ad5e91b6520a9224a8ed39b84bb7574f8c29 Mon Sep 17 00:00:00 2001 From: Phillip Cutter Date: Thu, 25 Jan 2024 14:58:17 -0800 Subject: [PATCH] Added first & last name with creation of volunteer record on sign-up --- src/pages/Login.jsx | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/pages/Login.jsx b/src/pages/Login.jsx index 02f18cb..64f1f28 100644 --- a/src/pages/Login.jsx +++ b/src/pages/Login.jsx @@ -3,6 +3,7 @@ import { FormControl, FormErrorMessage, FormLabel, + HStack, Input, Modal, ModalBody, @@ -24,6 +25,7 @@ import { logInWithEmailAndPassWord, sendResetPasswordPrompt, } from '../utils/firebaseAuthUtils'; +import Backend from '../utils/utils'; const Login = () => { return ( @@ -43,6 +45,8 @@ const signinSchema = yup.object({ }); const signupSchema = yup.object({ + firstName: yup.string().required("Please enter your first name"), + lastName: yup.string().required("Please enter your last name"), email: yup.string().email().required('Please enter your email address'), password: yup .string() @@ -146,10 +150,11 @@ const CreateAccount = () => { const navigate = useNavigate(); const onSubmit = async event => { - const { email, password } = event; + const { email, password, firstName, lastName } = event; try { await createUserInFirebase(email, password, '/successful-login', navigate); + await createVolunteerRow({id: email, email, firstName, lastName}); toast.closeAll(); @@ -188,6 +193,18 @@ const CreateAccount = () => {
+ + + First Name + + {errors.firstName && {errors.firstName?.message}} + + + Last Name + + {errors.lastName && {errors.lastName?.message}} + + Email address @@ -222,6 +239,16 @@ const CreateAccount = () => { ); }; +const createVolunteerRow = async ({ id, email, firstName, lastName }) => { + const response = await Backend.post("/profiles", { + id: id, + email: email, + first_name: firstName, + last_name: lastName, + }); + return response; +}; + const ForgotPasswordButton = () => { const { isOpen, onOpen, onClose } = useDisclosure(); const [email, setEmail] = useState('');