Merge pull request #607 from bluewave-labs/feat/set-password-page

Set password page
This commit is contained in:
Alexander Holliday authored and GitHub committed 2024-08-12 13:46:13 -07:00
commit d9654aa8b5
2 files changed
+132 -137

No files matched your search

+130 -93
View File
@@ -1,20 +1,19 @@
import "./index.css"; import { useDispatch, useSelector } from "react-redux";
import background from "../../assets/Images/background_pattern_decorative.png"; import { setNewPassword } from "../../Features/Auth/authSlice";
import LockIcon from "../../assets/icons/lock-button-icon.svg?react"; import { createToast } from "../../Utils/toastUtils";
import Check from "../../Components/Check/Check"; import { Box, Stack, Typography } from "@mui/material";
import ButtonSpinner from "../../Components/ButtonSpinner"; import { useTheme } from "@emotion/react";
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { useState } from "react"; import { useState } from "react";
import { credentials } from "../../Validation/validation"; import { credentials } from "../../Validation/validation";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import Check from "../../Components/Check/Check";
import ButtonSpinner from "../../Components/ButtonSpinner";
import Field from "../../Components/Inputs/Field"; import Field from "../../Components/Inputs/Field";
import { useDispatch, useSelector } from "react-redux"; import LockIcon from "../../assets/icons/lock-button-icon.svg?react";
import { setNewPassword } from "../../Features/Auth/authSlice"; import background from "../../assets/Images/background_pattern_decorative.png";
import { createToast } from "../../Utils/toastUtils"; import Logo from "../../assets/icons/bwu-icon.svg?react";
import { Stack, Typography } from "@mui/material"; import "./index.css";
import { useTheme } from "@emotion/react";
import Button from "../../Components/Button";
const SetNewPassword = () => { const SetNewPassword = () => {
const navigate = useNavigate(); const navigate = useNavigate();
@@ -105,100 +104,138 @@ const SetNewPassword = () => {
}; };
return ( return (
<div className="set-new-password-page"> <Stack className="set-new-password-page auth" overflow="hidden">
<img <img
className="background-pattern-svg" className="background-pattern-svg"
src={background} src={background}
alt="background pattern" alt="background pattern"
/> />
<form className="set-new-password-form" onSubmit={handleSubmit}> <Stack
<Stack direction="column" alignItems="center" gap={theme.gap.small}> direction="row"
<LockIcon alt="lock icon" style={{ fill: "white" }} /> alignItems="center"
<Typography component="h1" sx={{ mt: theme.gap.ml }}> px={theme.gap.large}
Set new password gap={theme.gap.small}
</Typography> >
<Typography sx={{ textAlign: "center" }}> <Logo style={{ borderRadius: theme.shape.borderRadius }} />
Your new password must be different to previously used passwords. <Typography sx={{ userSelect: "none" }}>BlueWave Uptime</Typography>
</Typography> </Stack>
</Stack> <Stack
<Stack gap={theme.gap.large} sx={{ mt: `calc(${theme.gap.ml}*2)` }}> width="100%"
<Field maxWidth={600}
type="password" flex={1}
id="register-password-input" justifyContent="center"
label="Password" p={theme.gap.xl}
isRequired={true} pb={theme.gap.triplexl}
placeholder="••••••••" mx="auto"
value={form.password} sx={{
onChange={handleChange} "& > .MuiStack-root": {
error={errors.password} border: 1,
/> borderRadius: theme.shape.borderRadius,
<Field borderColor: theme.palette.otherColors.graishWhite,
type="password" backgroundColor: theme.palette.otherColors.white,
id="confirm-password-input" padding: {
label="Confirm password" xs: theme.gap.large,
isRequired={true} sm: theme.gap.xl,
placeholder="••••••••" },
value={form.confirm} },
onChange={handleChange} }}
error={errors.confirm} >
/> <Stack gap={theme.gap.large} textAlign="center">
<Stack gap={theme.gap.small}> <Box>
<Check <LockIcon alt="lock icon" />
text="Must be at least 8 characters long" <Typography component="h1">Set new password</Typography>
variant={ <Typography>
errors?.password === "Password is required" Your new password must be different to previously used passwords.
? "error" </Typography>
: form.password === "" </Box>
? "info" <Box width="100%" textAlign="left">
: form.password.length < 8 <form noValidate spellCheck={false} onSubmit={handleSubmit}>
? "error" <Field
: "success" type="password"
} id="register-password-input"
/> label="Password"
<Check isRequired={true}
text="Must contain one special character and a number" placeholder="••••••••"
variant={ value={form.password}
errors?.password === "Password is required" onChange={handleChange}
? "error" error={errors.password}
: form.password === "" />
? "info" </form>
: !/^(?=.*[!@#$%^&*(),.?":{}|])(?=.*\d).+$/.test( <form noValidate spellCheck={false} onSubmit={handleSubmit}>
form.password <Field
) type="password"
? "error" id="confirm-password-input"
: "success" label="Confirm password"
} isRequired={true}
/> placeholder="••••••••"
<Check value={form.confirm}
text="Must contain at least one upper and lower character" onChange={handleChange}
variant={ error={errors.confirm}
errors?.password === "Password is required" />
? "error" </form>
: form.password === "" <Stack gap={theme.gap.small} mb={theme.gap.large}>
? "info" <Check
: !/^(?=.*[A-Z])(?=.*[a-z]).+$/.test(form.password) text="Must be at least 8 characters long"
? "error" variant={
: "success" errors?.password === "Password is required"
} ? "error"
/> : form.password === ""
</Stack> ? "info"
: form.password.length < 8
? "error"
: "success"
}
/>
<Check
text="Must contain one special character and a number"
variant={
errors?.password === "Password is required"
? "error"
: form.password === ""
? "info"
: !/^(?=.*[!@#$%^&*(),.?":{}|])(?=.*\d).+$/.test(
form.password
)
? "error"
: "success"
}
/>
<Check
text="Must contain at least one upper and lower character"
variant={
errors?.password === "Password is required"
? "error"
: form.password === ""
? "info"
: !/^(?=.*[A-Z])(?=.*[a-z]).+$/.test(form.password)
? "error"
: "success"
}
/>
</Stack>
</Box>
<ButtonSpinner <ButtonSpinner
disabled={Object.keys(errors).length !== 0} disabled={Object.keys(errors).length !== 0}
isLoading={isLoading} isLoading={isLoading}
onClick={handleSubmit} onClick={handleSubmit}
level="primary" level="primary"
label="Reset password" label="Reset password"
/> sx={{ width: "100%" }}
<Button
level="tertiary"
label="Back to log in"
img={<ArrowBackRoundedIcon />}
sx={{ alignSelf: "center", width: "fit-content" }}
onClick={() => navigate("/login")}
/> />
</Stack> </Stack>
</form> </Stack>
</div> <Box textAlign="center" p={theme.gap.large}>
<Typography display="inline-block">Go back to —</Typography>
<Typography
component="span"
ml={theme.gap.xs}
onClick={() => navigate("/login")}
sx={{ userSelect: "none" }}
>
Log In
</Typography>
</Box>
</Stack>
); );
}; };
+2 -44
View File
@@ -1,46 +1,3 @@
/* ////// */
/* SHARED */
/* ////// */
.set-new-password-page {
display: flex;
justify-content: center;
height: var(--env-var-height-1);
}
.set-new-password-page h1.MuiTypography-root {
font-size: var(--env-var-font-size-large);
color: var(--env-var-color-1);
font-weight: 600;
}
.set-new-password-page p.MuiTypography-root,
.set-new-password-page button {
font-size: var(--env-var-font-size-medium);
}
.set-new-password-page button:not(.MuiIconButton-root) {
height: 34px;
border-radius: var(--env-var-radius-2);
line-height: 0;
}
.set-new-password-form,
.password-confirmed-form {
margin-top: 65px;
width: var(--env-var-width-2);
}
.set-new-password-page p.MuiTypography-root {
color: var(--env-var-color-2);
}
.set-new-password-page button:not(.MuiIconButton-root) svg {
margin-right: 5px;
}
.set-new-password-page
.MuiFormControl-root:has(#register-password-input)
+ span.MuiTypography-root {
display: none;
visibility: hidden;
}
/* AUTH */ /* AUTH */
.auth { .auth {
height: 100vh; height: 100vh;
@@ -120,6 +77,7 @@
.forgot-password-page h1, .forgot-password-page h1,
.check-email-page h1, .check-email-page h1,
.password-confirmed-page h1 { .password-confirmed-page h1,
.set-new-password-page h1 {
font-size: var(--env-var-font-size-large-plus); font-size: var(--env-var-font-size-large-plus);
} }