From d1055d8b80b29b46bf4e21ee07edb448ed0d1215 Mon Sep 17 00:00:00 2001 From: Kirstie <39728053+epixieme@users.noreply.github.com> Date: Thu, 11 Jul 2024 15:30:17 +0100 Subject: [PATCH] pushing sign up code to production --- src/features/auth/components/SignUpForm.tsx | 75 +++++++++++++++------ 1 file changed, 53 insertions(+), 22 deletions(-) diff --git a/src/features/auth/components/SignUpForm.tsx b/src/features/auth/components/SignUpForm.tsx index 422eda12..be09f74f 100644 --- a/src/features/auth/components/SignUpForm.tsx +++ b/src/features/auth/components/SignUpForm.tsx @@ -1,5 +1,6 @@ import { useState } from 'react'; import { CmButton, CmTextInput } from 'shared/components'; +import { useAppSelector } from 'store/hooks'; interface Props { isLoading: boolean; @@ -13,7 +14,7 @@ function SignUpForm({ isLoading, onCancel, onSignUp }: Props) { const [email, setEmail] = useState({ value: '', touched: false }); const [password, setPassword] = useState({ value: '', touched: false }); const [confirmPassword, setConfirmPassword] = useState({ value: '', touched: false }); - + const { quizId } = useAppSelector((state) => state.auth.userA); function handleSubmit(e?: React.FormEvent) { e?.preventDefault(); if (!formIsValid) return; @@ -21,6 +22,12 @@ function SignUpForm({ isLoading, onCancel, onSignUp }: Props) { onSignUp(firstname.value, lastname.value, email.value, password.value); } + function handleGoogleAuth() { + //need to set isloggedin to true so that the user is redirected to the climate feed page + + window.location.href = `${process.env.REACT_APP_API_URL}/register/google?quizId=${quizId}`; + } + const emailValid = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(email.value); const passwordValid = /^(?=.*[a-zA-Z])(?=.*[\d!"#$£%&'()*+,-.:;<=>?@[\]^_`{|}~]).{8,128}$/.test(password.value); const passwordsMatch = password.value === confirmPassword.value; @@ -29,71 +36,95 @@ function SignUpForm({ isLoading, onCancel, onSignUp }: Props) { return (