From 8c2b36e475a3d4fb273f96ed9dbdc2fcdf374949 Mon Sep 17 00:00:00 2001 From: Mikayla Dobson Date: Wed, 1 Jun 2022 11:14:31 -0500 Subject: [PATCH] expanding user data type to incorporate additional customer details --- client/src/components/User/Register.tsx | 46 +++++++++---------------- client/src/store/store_types.ts | 12 +++++++ client/src/types/main.d.ts | 10 +++--- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/client/src/components/User/Register.tsx b/client/src/components/User/Register.tsx index 32a32fc..200def2 100644 --- a/client/src/components/User/Register.tsx +++ b/client/src/components/User/Register.tsx @@ -1,4 +1,5 @@ import { useEffect, useState } from "react"; +import { emptySessionHeader } from "../../store/store_types"; import { userInfo } from '../../types/main'; import { registerNewUser } from "../../util/apiUtils"; import Page from "../../util/Page"; @@ -10,6 +11,12 @@ function Register() { const [verify, setVerify] = useState(''); const [warningText, setWarningText] = useState('initial'); + const [userInput, setUserInput] = useState({ + name: '', + email: '', + password: '', + }) + const [userData, setUserData] = useState(); // checks password complexity @@ -34,35 +41,13 @@ function Register() { } }, [password, verify]); - // checks that all conditions for registration have been met - // useEffect(() => { - // let evaluating = true; - - // if (!(conditions.includes('')) && warningText === '') { - // evaluating = false; - // } - - // if (!evaluating) { - // const userEntry: userInfo = { - // name: name, - // email: email, - // password: password - // } - - // console.log(userEntry); - // setUserData(userEntry); - - // setWarningText('Conditions met!'); - // } - // }, [conditions, warningText, userData, name, email]); - // updates user info object on each render useEffect(() => { let newInfo: userInfo = { name: name, email: email, password: password, - headers: {} + headers: emptySessionHeader } setUserData(newInfo); @@ -71,10 +56,6 @@ function Register() { // interrupts rendering loop by setting warning text on password data useEffect(() => { if (warningText === '') { - console.group('valid data'); - console.log(userData); - console.groupEnd(); - setWarningText('Conditions met!'); } }, [userData, warningText]); @@ -96,9 +77,16 @@ function Register() {
- - setName(e.target.value)}/> + + setName(e.target.value)}/>
+ +
+ + setName(e.target.value)}/> +
+ +
setEmail(e.target.value)}/> diff --git a/client/src/store/store_types.ts b/client/src/store/store_types.ts index 9e28d35..bbe4889 100644 --- a/client/src/store/store_types.ts +++ b/client/src/store/store_types.ts @@ -45,4 +45,16 @@ export const emptyCart: Cart = { userInfo: undefinedUser, checkedOut: false, contents: [] +} + +export const emptySessionHeader: SessionHeader = { + authenticated: false, + cookie: { + expires: "", + httpOnly: false, + originalMaxAge: 0, + path: "", + secure: false, + }, + user: undefinedUser } \ No newline at end of file diff --git a/client/src/types/main.d.ts b/client/src/types/main.d.ts index 40a49d7..b9237c1 100644 --- a/client/src/types/main.d.ts +++ b/client/src/types/main.d.ts @@ -2,10 +2,12 @@ import { SessionHeader } from "../store/store_types"; // user details and metadata export type userInfo = { - email: string; - id?: number; - name?: string; - password: string; + firstName?: string + lastName?: string + email: string + id?: number + name?: string + password: string headers?: SessionHeader }