Resolved conflicts

This commit is contained in:
Daniel Cojocea committed 2024-08-12 14:58:49 -04:00
commit e74e41cde0
6 files changed
+189 -130

No files matched your search

+100 -69
View File
@@ -1,18 +1,17 @@
import "./index.css"; import { Box, Stack, Typography } from "@mui/material";
import background from "../../assets/Images/background_pattern_decorative.png"; import { useTheme } from "@emotion/react";
import Logomark from "../../assets/icons/key.svg?react";
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
import { useState } from "react";
import { credentials } from "../../Validation/validation";
import { useNavigate } from "react-router-dom";
import Field from "../../Components/Inputs/Field";
import { createToast } from "../../Utils/toastUtils"; import { createToast } from "../../Utils/toastUtils";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { forgotPassword } from "../../Features/Auth/authSlice"; import { forgotPassword } from "../../Features/Auth/authSlice";
import { useEffect, useState } from "react";
import { credentials } from "../../Validation/validation";
import { useNavigate } from "react-router-dom";
import Field from "../../Components/Inputs/Field";
import ButtonSpinner from "../../Components/ButtonSpinner"; import ButtonSpinner from "../../Components/ButtonSpinner";
import { Stack, Typography } from "@mui/material"; import Logo from "../../assets/icons/bwu-icon.svg?react";
import { useTheme } from "@emotion/react"; import Key from "../../assets/icons/key.svg?react";
import Button from "../../Components/Button"; import background from "../../assets/Images/background_pattern_decorative.png";
import "./index.css";
const ForgotPassword = () => { const ForgotPassword = () => {
const navigate = useNavigate(); const navigate = useNavigate();
@@ -25,9 +24,10 @@ const ForgotPassword = () => {
email: "", email: "",
}); });
const idMap = { useEffect(() => {
"forgot-password-email-input": "email", const email = sessionStorage.getItem("email");
}; email && setForm({ email: sessionStorage.getItem("email") });
}, []);
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
event.preventDefault(); event.preventDefault();
@@ -40,11 +40,9 @@ const ForgotPassword = () => {
error.details && error.details.length > 0 error.details && error.details.length > 0
? error.details[0].message ? error.details[0].message
: "Error validating data."; : "Error validating data.";
setErrors(err); setErrors({ email: err });
createToast({ createToast({
variant: "info",
body: err, body: err,
hasIcon: false,
}); });
} else { } else {
const action = await dispatch(forgotPassword(form)); const action = await dispatch(forgotPassword(form));
@@ -71,72 +69,105 @@ const ForgotPassword = () => {
}; };
const handleChange = (event) => { const handleChange = (event) => {
const { value, id } = event.target; const { value } = event.target;
const name = idMap[id]; setForm({ email: value });
setForm((prev) => ({
...prev,
[name]: value,
}));
const { error } = credentials.validate( const { error } = credentials.validate(
{ [name]: value }, { email: value },
{ abortEarly: false } { abortEarly: false }
); );
setErrors((prev) => { if (error) setErrors({ email: error.details[0].message });
const prevErrors = { ...prev }; else delete errors.email;
if (error) prevErrors[name] = error.details[0].message;
else delete prevErrors[name];
return prevErrors;
});
}; };
return ( return (
<div className="forgot-password-page"> <Stack className="forgot-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="forgot-password-form" onSubmit={handleSubmit}> <Stack
<Stack direction="column" alignItems="center" gap={theme.gap.small}> direction="row"
<Logomark alt="Logomark" style={{ fill: "white" }} /> alignItems="center"
<Typography component="h1" sx={{ mt: theme.gap.ml }}> px={theme.gap.large}
Forgot password? gap={theme.gap.small}
</Typography> >
<Typography> <Logo style={{ borderRadius: theme.shape.borderRadius }} />
No worries, we'll send you reset instructions. <Typography sx={{ userSelect: "none" }}>BlueWave Uptime</Typography>
</Typography> </Stack>
<Stack
width="100%"
maxWidth={600}
flex={1}
justifyContent="center"
p={theme.gap.xl}
pb={theme.gap.triplexl}
mx="auto"
sx={{
"& > .MuiStack-root": {
border: 1,
borderRadius: theme.shape.borderRadius,
borderColor: theme.palette.otherColors.graishWhite,
backgroundColor: theme.palette.otherColors.white,
padding: {
xs: theme.gap.large,
sm: theme.gap.xl,
},
},
}}
>
<Stack gap={theme.gap.large} alignItems="center" textAlign="center">
<Box>
<Key />
<Typography component="h1">Forgot password?</Typography>
<Typography>
No worries, we'll send you reset instructions.
</Typography>
</Box>
<Box width="100%" maxWidth={400} textAlign="left">
<form noValidate spellCheck={false} onSubmit={handleSubmit}>
<Field
type="email"
id="forgot-password-email-input"
label="Email"
isRequired={true}
placeholder="Enter your email"
value={form.email}
onChange={handleChange}
error={errors.email}
/>
<ButtonSpinner
disabled={errors.email !== undefined}
onClick={handleSubmit}
isLoading={isLoading}
level="primary"
label="Send instructions"
sx={{
width: "100%",
fontWeight: 400,
mt: theme.gap.mlplus,
}}
/>
</form>
</Box>
</Stack> </Stack>
<Stack gap={theme.gap.ml} sx={{ mt: `calc(${theme.gap.ml}*2)` }}> </Stack>
<Field <Box textAlign="center" p={theme.gap.large}>
type="email" <Typography display="inline-block">Go back to —</Typography>
id="forgot-password-email-input" <Typography
label="Email" component="span"
isRequired={true} ml={theme.gap.xs}
placeholder="Enter your email" onClick={() => {
value={form.email} navigate("/login");
onChange={handleChange} }}
error={errors.email} sx={{ userSelect: "none" }}
/> >
<ButtonSpinner Log In
disabled={errors.email !== undefined} </Typography>
onClick={handleSubmit} </Box>
isLoading={isLoading} </Stack>
level="primary"
label="Reset password"
sx={{ mb: theme.gap.medium }}
/>
<Button
level="tertiary"
label="Back to log in"
img={<ArrowBackRoundedIcon />}
sx={{ alignSelf: "center", width: "fit-content" }}
onClick={() => navigate("/login")}
/>
</Stack>
</form>
</div>
); );
}; };
+8 -1
View File
@@ -154,6 +154,13 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
} }
}, []); }, []);
const handleNavigate = () => {
if (form.email !== "" && !errors.email) {
sessionStorage.setItem("email", form.email);
}
navigate("/forgot-password");
};
return ( return (
<> <>
<Stack gap={theme.gap.large} textAlign="center"> <Stack gap={theme.gap.large} textAlign="center">
@@ -209,7 +216,7 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
component="span" component="span"
ml={theme.gap.xs} ml={theme.gap.xs}
sx={{ userSelect: "none" }} sx={{ userSelect: "none" }}
onClick={() => navigate("/forgot-password")} onClick={handleNavigate}
> >
Reset password Reset password
</Typography> </Typography>
+22 -26
View File
@@ -107,18 +107,16 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
/> />
</form> </form>
<form noValidate spellCheck={false} onSubmit={onSubmit}> <form noValidate spellCheck={false} onSubmit={onSubmit}>
<Box my={theme.gap.ml}> <Field
<Field id="register-lastname-input"
id="register-lastname-input" label="Surname"
label="Surname" isRequired={true}
isRequired={true} placeholder="Ellis"
placeholder="Ellis" autoComplete="family-name"
autoComplete="family-name" value={form.lastName}
value={form.lastName} onChange={onChange}
onChange={onChange} error={errors.lastName}
error={errors.lastName} />
/>
</Box>
</form> </form>
</Box> </Box>
<Stack direction="row" justifyContent="space-between"> <Stack direction="row" justifyContent="space-between">
@@ -267,21 +265,19 @@ const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => {
/> />
</form> </form>
<form noValidate spellCheck={false} onSubmit={onSubmit}> <form noValidate spellCheck={false} onSubmit={onSubmit}>
<Box mt={theme.gap.ml}> <Field
<Field type="password"
type="password" id="register-confirm-input"
id="register-confirm-input" label="Confirm password"
label="Confirm password" isRequired={true}
isRequired={true} placeholder="Confirm your password"
placeholder="Confirm your password" autoComplete="current-password"
autoComplete="current-password" value={form.confirm}
value={form.confirm} onChange={onChange}
onChange={onChange} error={errors.confirm}
error={errors.confirm} />
/>
</Box>
</form> </form>
<Stack gap={theme.gap.small} my={theme.gap.large}> <Stack gap={theme.gap.small} mb={theme.gap.large}>
<Check <Check
text="Must be at least 8 characters long" text="Must be at least 8 characters long"
variant={ variant={
+3
View File
@@ -111,6 +111,9 @@
.auth .check span.MuiTypography-root { .auth .check span.MuiTypography-root {
font-size: var(--env-var-font-size-medium); font-size: var(--env-var-font-size-medium);
} }
.auth form + form {
margin: var(--env-var-spacing-1-plus) 0;
}
.auth .email-sent-to { .auth .email-sent-to {
font-weight: 600; font-weight: 600;
cursor: default; cursor: default;
@@ -9,6 +9,8 @@ import {
Pagination, Pagination,
PaginationItem, PaginationItem,
Paper, Paper,
Typography,
Box,
} from "@mui/material"; } from "@mui/material";
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded"; import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
@@ -105,41 +107,55 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
return ( return (
<> <>
<TableContainer component={Paper}> {checks?.length === 0 && selectedMonitor === "0" ? (
<Table> <Box>
<TableHead> <Typography textAlign="center">No incidents recorded yet.</Typography>
<TableRow> </Box>
<TableCell>Monitor Name</TableCell> ) : checks?.length === 0 ? (
<TableCell>Status</TableCell> <Box>
<TableCell>Date & Time</TableCell> <Typography textAlign="center">
<TableCell>Message</TableCell> The monitor you have selected has no recorded incidents yet.
</TableRow> </Typography>
</TableHead> </Box>
<TableBody> ) : (
{checks.map((check) => { <>
const status = check.status === true ? "up" : "down"; <TableContainer component={Paper}>
<Table>
return ( <TableHead>
<TableRow key={check._id}> <TableRow>
<TableCell>{monitors[check.monitorId]?.name}</TableCell> <TableCell>Monitor Name</TableCell>
<TableCell> <TableCell>Status</TableCell>
<StatusLabel <TableCell>Date & Time</TableCell>
status={status} <TableCell>Message</TableCell>
text={status}
customStyles={{ textTransform: "capitalize" }}
/>
</TableCell>
<TableCell>
{new Date(check.createdAt).toLocaleString()}
</TableCell>
<TableCell>{check.statusCode}</TableCell>
</TableRow> </TableRow>
); </TableHead>
})} <TableBody>
</TableBody> {checks.map((check) => {
</Table> const status = check.status === true ? "up" : "down";
</TableContainer>
{paginationComponent} return (
<TableRow key={check._id}>
<TableCell>{monitors[check.monitorId]?.name}</TableCell>
<TableCell>
<StatusLabel
status={status}
text={status}
customStyles={{ textTransform: "capitalize" }}
/>
</TableCell>
<TableCell>
{new Date(check.createdAt).toLocaleString()}
</TableCell>
<TableCell>{check.statusCode}</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
</TableContainer>
{paginationComponent}
</>
)}
</> </>
); );
}; };
+6
View File
@@ -17,6 +17,12 @@
.incidents .MuiPagination-root { .incidents .MuiPagination-root {
background-color: var(--env-var-color-8); background-color: var(--env-var-color-8);
} }
.incidents > .MuiBox-root {
background-color: var(--env-var-color-8);
border: solid 1px var(--env-var-color-6);
border-radius: var(--env-var-radius-1);
padding: 60px;
}
/* remove later */ /* remove later */
.incidents .MuiSelect-select { .incidents .MuiSelect-select {