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 (
setFirstname({ value: e.target.value, touched: firstname.touched })} onBlur={() => setFirstname({ value: firstname.value, touched: true })} error={firstname.touched && !firstname.value} helperText={firstname.touched && !firstname.value && 'First name is required'} - placeholder='John' + placeholder="John" style={styles.textInput} /> setLastname({ value: e.target.value, touched: lastname.touched })} onBlur={() => setLastname({ value: lastname.value, touched: true })} error={lastname.touched && !lastname.value} helperText={lastname.touched && !lastname.value && 'Last name is required'} - placeholder='Smith' + placeholder="Smith" style={styles.textInput} /> setEmail({ value: e.target.value, touched: email.touched })} onBlur={() => setEmail({ value: email.value, touched: true })} error={email.touched && !email.value} helperText={email.touched && !emailValid && 'Invalid email address'} - placeholder='hello@climatemind.org' - type='email' + placeholder="hello@climatemind.org" + type="email" style={styles.textInput} /> setPassword({ value: e.target.value, touched: password.touched })} onBlur={() => setPassword({ value: password.value, touched: true })} error={password.touched && !passwordValid} helperText={password.touched && !passwordValid && 'Invalid Password. Password must be at least 8 characters and contain one number or one special character'} - placeholder='Super Secret Password' - type='password' + placeholder="Super Secret Password" + type="password" style={styles.textInput} /> setConfirmPassword({ value: e.target.value, touched: confirmPassword.touched })} onBlur={() => setConfirmPassword({ value: confirmPassword.value, touched: true })} error={confirmPassword.touched && !passwordsMatch} helperText={confirmPassword.touched && !passwordsMatch && 'Passwords do not match'} - placeholder='Confirm Password' - type='password' + placeholder="Confirm Password" + type="password" style={styles.textInput} /> -
- {onCancel && } - +
+ {onCancel && } + +
);