Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

343 add validation to user signup form #363

Merged
merged 35 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
474de00
refactor: create StepOne component
marvinsjsu Jul 28, 2023
712baec
refactor: EmailInput and NameInput
marvinsjsu Jul 29, 2023
6d361ad
finish validation for step one form
marvinsjsu Jul 31, 2023
d43420a
refactor: add StepTwo component
marvinsjsu Jul 31, 2023
a9c5711
refactor: add StepThree, StepFour, and StepFive components
marvinsjsu Aug 1, 2023
4c823cd
set initData on form
marvinsjsu Aug 1, 2023
b690218
add style for selected chip
marvinsjsu Aug 1, 2023
24db3ed
add styling for buttons
marvinsjsu Aug 1, 2023
4c1d380
add passwordConfirm to type
marvinsjsu Aug 1, 2023
6030afd
add redux-thunk for user signup
marvinsjsu Aug 2, 2023
3fe366a
un-comment sendgrid send
marvinsjsu Aug 2, 2023
cffac22
add StyledLink import on StepOne
marvinsjsu Aug 2, 2023
d268616
fix bug for StepTwo next button disabled
marvinsjsu Aug 2, 2023
17b0141
Merge branch 'main' into 343-add-validation-to-user-signup-form
Aug 25, 2023
c467a66
bugfix: always apply password match validation
marvinsjsu Aug 31, 2023
3550260
refactor: simplify user actions
marvinsjsu Aug 31, 2023
78c348a
refactor: add utils for validation helpers
marvinsjsu Aug 31, 2023
816c42a
cleanup: remove console.logs
marvinsjsu Aug 31, 2023
d2ca68e
refactor: feature-based folder structure
marvinsjsu Sep 1, 2023
04607b8
removed Redux and use react-query for user registration
marvinsjsu Sep 6, 2023
458a633
display loading and error state placeholders
marvinsjsu Sep 6, 2023
df04b15
display the email, firstName, lastName or last_name of the user in th…
marvinsjsu Sep 6, 2023
cd2cdfb
cleanup: remove console.log
marvinsjsu Sep 6, 2023
e5fddb7
cleanup: remove unused folder/file backend.ts
marvinsjsu Sep 6, 2023
13d7021
cleanup: re-arrange props
marvinsjsu Sep 6, 2023
d694b4b
add validation for existing email
marvinsjsu Sep 7, 2023
16f976b
remove react-query package and use @tanstack/react-query, move @tanst…
marvinsjsu Sep 7, 2023
672cec4
remove @tanstack/react-query references
marvinsjsu Sep 7, 2023
e00261c
removed call to check email existence from StepOne
marvinsjsu Sep 9, 2023
3c7ed6c
removed endpoint for checking email existence
marvinsjsu Sep 9, 2023
3884285
bugfix: ensure bio is included in formData on form submission
marvinsjsu Sep 10, 2023
c29fa03
refactor: use type instead of interface for functional approach for p…
marvinsjsu Sep 10, 2023
f3335d1
refactor: use type instead of interface for prop types
marvinsjsu Sep 10, 2023
f4d02e6
fix linting issue
marvinsjsu Sep 10, 2023
8330910
un-comment sending email verification
marvinsjsu Sep 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"react-dom": "^18.2.0",
"react-hook-form": "^7.34.0",
"react-input-mask": "^3.0.0-alpha.2",
"react-query": "^3.35.0",
"react-query": "^3.39.3",
"react-router-dom": "^5.2.0",
"socket.io-client": "^4.5.1",
"tss-react": "^4.8.4",
Expand Down
25 changes: 22 additions & 3 deletions client/src/components/Users/Auth/EmailInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const useStyles = makeStyles()((theme: Theme) => {
textAlign: 'left',
marginTop: '20px',
},
error: {
marginBottom: 0,
border: '2px solid red',
},
};
});
interface Props {
Expand All @@ -35,19 +39,32 @@ interface Props {
placeholder: string;
showStartAdornment?: boolean;
error: string | null;
onBlur?: React.ChangeEventHandler<HTMLInputElement> | null;
}

function EmailInput({ onChange, value, placeholder, showStartAdornment = false, error }: Props) {
function EmailInput({
value,
error,
onChange,
placeholder,
onBlur = null,
showStartAdornment = false,
}: Props) {
const { classes } = useStyles();

let additionalProps: { [key: string]: any } = {};

if (onBlur) {
additionalProps['onBlur'] = onBlur;
}

return (
<FormControl fullWidth error={Boolean(error)}>
<label className={classes.label} htmlFor="email">
Email
</label>
{error && <FormHelperText error>{error}</FormHelperText>}
<Input
className={classes.input}
className={`${classes.input} ${Boolean(error) && classes.error}`}
type="email"
id="email"
name="email"
Expand All @@ -66,7 +83,9 @@ function EmailInput({ onChange, value, placeholder, showStartAdornment = false,
</InputAdornment>
)
}
{...additionalProps}
/>
{error && <FormHelperText error>{error}</FormHelperText>}
</FormControl>
);
}
Expand Down
101 changes: 101 additions & 0 deletions client/src/components/Users/Auth/NameInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import * as React from 'react';
import FormControl from '@mui/material/FormControl';
import Input from '@mui/material/Input';
import FormHelperText from '@mui/material/FormHelperText';
import type { Theme } from '@mui/material/styles';
import { makeStyles } from 'tss-react/mui';

const useStyles = makeStyles()((theme: Theme) => {
return {
input: {
height: 44,
border: '1px solid #C4C4C4',
borderRadius: 10,
boxSizing: 'border-box',
padding: theme.spacing(1),
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(2),
fontSize: 14,
marginBottom: 20,
},
label: {
color: '#000000',
fontWeight: 'bold',
textAlign: 'left',
},
sublabel: {
color: '#6E6E6E',
fontSize: 14,
fontWeight: 300,
marginLeft: 5,
},
error: {
border: '2px solid red',
marginBottom: 0,
},
};
});

type TNameInputProps = {
onChange: React.ChangeEventHandler<HTMLInputElement>;
value: string;
error?: string | null;
showStartAdornment?: boolean;
showForgot?: boolean;
placeholder?: string;
label?: string | null;
id?: string | null;
name?: string | null;
onBlur?: React.FocusEventHandler<HTMLInputElement> | null;
sublabel?: string | null;
};

export default function NameInput({
value,
error,
onBlur,
onChange,
id = null,
name = null,
placeholder,
label = null,
sublabel = null,
}: TNameInputProps) {
const { classes } = useStyles();

const getAdditionalProps = () => {
let additionalProps: { [key: string]: any } = {};

if (onBlur) {
additionalProps['onBlur'] = onBlur;
}

return additionalProps;
};

return (
<FormControl fullWidth error={Boolean(error)}>
<label className={classes.label} htmlFor={id || 'name'}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
{label || 'Name'}
{sublabel && <span className={classes.sublabel}>{sublabel}</span>}
</div>
</div>
</label>
<Input
className={`${classes.input} ${Boolean(error) && classes.error}`}
id={id || 'name'}
placeholder={placeholder || 'Jane'}
name={name || 'name'}
value={value}
onChange={onChange}
disableUnderline
error={Boolean(error)}
required
{...getAdditionalProps()}
/>
{error && <FormHelperText error>{error}</FormHelperText>}
</FormControl>
);
}
14 changes: 12 additions & 2 deletions client/src/components/Users/Auth/PasswordInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ const useStyles = makeStyles()((theme: Theme) => {
fontWeight: 300,
marginLeft: 5,
},
error: {
border: '2px solid red',
marginBottom: 0,
},
};
});

Expand All @@ -53,6 +57,7 @@ interface Props {
name?: string | null;
onBlur?: React.FocusEventHandler<HTMLInputElement> | null;
sublabel?: string | null;
required?: boolean | null;
}

function PasswordInput({
Expand All @@ -67,6 +72,7 @@ function PasswordInput({
id = null,
name = null,
sublabel = null,
required = false,
}: Props) {
const { classes } = useStyles();

Expand All @@ -84,6 +90,10 @@ function PasswordInput({
additionalProps['onBlur'] = onBlur;
}

if (required) {
additionalProps['required'] = true;
}

return additionalProps;
};

Expand All @@ -99,9 +109,8 @@ function PasswordInput({
{showForgot && <StyledLink to={routes.ForgotPassword.path}>Forgot Password?</StyledLink>}
</div>
</label>
{error && <FormHelperText error>{error}</FormHelperText>}
<Input
className={classes.input}
className={`${classes.input} ${Boolean(error) && classes.error}`}
id={id || 'password'}
placeholder={placeholder || 'oooooo'}
name={name || 'password'}
Expand Down Expand Up @@ -133,6 +142,7 @@ function PasswordInput({
}
{...getAdditionalProps()}
/>
{error && <FormHelperText error>{error}</FormHelperText>}
</FormControl>
);
}
Expand Down
Loading
Loading