Skip to content

Commit

Permalink
Merge branch 'release-0.2.47'
Browse files Browse the repository at this point in the history
  • Loading branch information
entrotech committed Jun 17, 2023
2 parents c7d0fcb + b305fe8 commit 9797bdb
Show file tree
Hide file tree
Showing 48 changed files with 2,153 additions and 349 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ RUN mkdir /app
WORKDIR /app
COPY /client/package.json .
COPY /client/package-lock.json .
RUN npm ci --legacy-peer-deps && find node_modules ! -user root | xargs chown root:root
#RUN npm ci --legacy-peer-deps && find node_modules ! -user root | xargs chown root:root
RUN npm ci --legacy-peer-deps
COPY /client .

RUN npm run build
Expand All @@ -18,7 +19,8 @@ COPY --from=clientBuilder /app/build /client/build
COPY ./server/package.json ./
COPY ./server/package-lock.json ./

RUN npm ci && find node_modules ! -user root | xargs chown root:root
#RUN npm ci && find node_modules ! -user root | xargs chown root:root
RUN npm ci

COPY ./server/app ./app
COPY ./server/middleware ./middleware
Expand Down
1,201 changes: 1,017 additions & 184 deletions client/package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tdm-calculator-client",
"version": "0.2.46",
"version": "0.2.47",
"private": true,
"proxy": "http://localhost:5001",
"scripts": {
Expand Down Expand Up @@ -34,6 +34,7 @@
"@fortawesome/react-fontawesome": "^0.1.18",
"@microsoft/applicationinsights-react-js": "^3.0.5",
"@microsoft/applicationinsights-web": "^2.5.11",
"@react-pdf/renderer": "^3.1.9",
"axios": "^0.27.2",
"clsx": "^1.1.1",
"formik": "^2.2.9",
Expand All @@ -48,6 +49,7 @@
"react-router-dom": "^5.3.0",
"react-select": "^5.2.2",
"react-string-replace": "^1.1.0",
"react-to-print": "^2.14.12",
"react-tooltip": "^4.2.21",
"yup": "^0.32.11"
},
Expand Down
17 changes: 16 additions & 1 deletion client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext } from "react";
import React, { useContext, useState } from "react";
import UserContext from "./contexts/UserContext";
import PropTypes from "prop-types";

Expand All @@ -15,6 +15,7 @@ import TermsAndConditionsModal from "./components/TermsAndConditions/TermsAndCon
import ChecklistModal from "./components/Checklist/ChecklistModal";
import PrivacyPolicy from "./components/PrivacyPolicy";
import Register from "./components/Authorization/Register";
import UpdateAccount from "./components/Authorization/UpdateAccount";
import ConfirmEmail from "./components/Authorization/ConfirmEmail";
import ProtectedRoute from "./components/Authorization/ProtectedRoute";
import Login from "./components/Authorization/Login";
Expand Down Expand Up @@ -49,6 +50,8 @@ const App = ({
const classes = useStyles();
const userContext = useContext(UserContext);
const account = userContext.account;
const [rules, setRules] = useState([]);
const [dateModified, setDateModified] = useState(null);

// console.error("account: " + JSON.stringify(account, null, 2));

Expand All @@ -70,6 +73,10 @@ const App = ({
<ProjectsPage
account={account}
contentContainerRef={contentContainerRef}
rules={rules}
setRules={setRules}
dateModified={dateModified}
setDateModified={setDateModified}
/>
</ProtectedRoute>

Expand All @@ -81,6 +88,10 @@ const App = ({
contentContainerRef={contentContainerRef}
checklistModalOpen={checklistModalOpen}
toggleChecklistModal={toggleChecklistModal}
rules={rules}
setRules={setRules}
dateModified={dateModified}
setDateModified={setDateModified}
/>
</Route>

Expand Down Expand Up @@ -124,6 +135,10 @@ const App = ({
<Register />
</Route>

<Route path="/updateaccount/:email?">
<UpdateAccount />
</Route>

<Route path="/confirm/:token?">
<ConfirmEmail />
</Route>
Expand Down
12 changes: 8 additions & 4 deletions client/src/components/Authorization/SendEmailForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export const useStyles = createUseStyles({
marginBottom: "16px"
},
subTitle: {
marginBottom: "32px"
marginBottom: "32px",
textAlign: "center"
},
fieldGroup: {
width: "100%",
Expand Down Expand Up @@ -59,8 +60,11 @@ const SendEmailForm = ({ label, submitted, handleSubmit }) => {
<>
<h1 className={classes.pageTitle}>Send {label} Email</h1>
<div className={classes.subTitle}>
<h3>Please enter the email registered with your account.</h3>
<h3>An email will be sent with further instructions.</h3>
<h3>
Please enter the email registered with your account, or if you have
recently updated your email, provide the new one below.
</h3>
<h3>An email containing further instructions will be sent to you.</h3>
</div>
<Formik
initialValues={{ email: "" }}
Expand All @@ -79,7 +83,7 @@ const SendEmailForm = ({ label, submitted, handleSubmit }) => {
innerRef={focusRef}
value={values.email}
name="email"
placeholder="Registered Email Address"
placeholder="Registered/Updated Email"
className={clsx(
classes.inputField,
touched.email && errors.email ? classes.error : null
Expand Down
178 changes: 178 additions & 0 deletions client/src/components/Authorization/UpdateAccount.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
import React, { useState, useRef, useContext } from "react";
import UserContext from "../../contexts/UserContext";
import PropTypes from "prop-types";
import * as accountService from "../../services/account.service";
import { createUseStyles } from "react-jss";
import { Formik, Form, Field, ErrorMessage } from "formik";
import { withRouter } from "react-router-dom";
import * as Yup from "yup";
import Button from "../Button/Button";
import ContentContainer from "../Layout/ContentContainer";

const useStyles = createUseStyles({
submitButton: {
float: "right"
},
authText: {
color: "#979797"
}
});

const UpdateAccount = props => {
const userContext = useContext(UserContext);
const account = userContext.account;
const focusRef = useRef(null);
const classes = useStyles();
const { match } = props;
const initialValues = {
id: account.id || "",
firstName: account.firstName || "",
lastName: account.lastName || "",
email: match.params.email || ""
};

const [errorMsg, setErrorMsg] = useState("");
const [submitted, setSubmitted] = useState(false);

const updateAccountSchema = Yup.object().shape({
firstName: Yup.string().required("First Name is required"),
lastName: Yup.string().required("Last Name is required"),
email: Yup.string()
.email("Invalid email address format")
.required("Email is required")
});

const handleSubmit = async (
{ id, firstName, lastName, email },
{ setSubmitting }
) => {
try {
const response = await accountService.updateAccount(
id,
firstName,
lastName,
email
);
if (response.isSuccess) {
setSubmitted(true);
userContext.updateAccount({});
} else if (response.code === "REG_DUPLICATE_EMAIL") {
setErrorMsg(`The email ${email} is already registered. Please
login or use the Forgot Password feature if you have
forgotten your password.`);
} else {
setErrorMsg(`An error occurred in updating the account
for ${email}.`);
}
} catch (err) {
setErrorMsg(err.message);
setSubmitting(false);
}
};

return (
<ContentContainer componentToTrack="UpdateAccount">
{!submitted ? (
<>
<h1>Update Your Account</h1>
<br />
<div className="auth-form">
<Formik
initialValues={initialValues}
validationSchema={updateAccountSchema}
onSubmit={(values, actions) =>
handleSubmit(values, actions, props)
}
>
{({ touched, errors, isSubmitting }) => (
<Form>
<div className="form-group">
<Field
type="text"
innerRef={focusRef}
name="firstName"
placeholder="First Name"
className={`form-control ${
touched.firstName && errors.firstName
? "is-invalid"
: ""
}`}
/>
<ErrorMessage
name="firstName"
component="div"
className="invalid-feedback"
/>
</div>
<div className="form-group">
<Field
type="text"
name="lastName"
placeholder="Last Name"
className={`form-control ${
touched.lastName && errors.lastName ? "is-invalid" : ""
}`}
/>
<ErrorMessage
name="lastName"
component="div"
className="invalid-feedback"
/>
</div>
<div className="form-group">
<Field
type="email"
name="email"
placeholder="Email"
className={`form-control ${
touched.email && errors.email ? "is-invalid" : ""
}`}
/>
<ErrorMessage
name="email"
component="div"
className="invalid-feedback"
/>
</div>

<Button
type="submit"
disabled={isSubmitting}
color="colorPrimary"
className={classes.submitButton}
>
{isSubmitting ? "Please wait..." : "Update Account"}
</Button>
<div className="warning">
<br />
{errorMsg}
</div>
</Form>
)}
</Formik>
</div>
</>
) : (
<>
<h1>
Instructions have been sent to the email you provided in order to
confirm account updates.
</h1>
<h2>
Please allow a few minutes for the email to arrive in your inbox.
</h2>
</>
)}
<br />
</ContentContainer>
);
};
UpdateAccount.propTypes = {
match: PropTypes.shape({
params: PropTypes.shape({
email: PropTypes.string
})
})
};

export default withRouter(UpdateAccount);
8 changes: 7 additions & 1 deletion client/src/components/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const useStyles = createUseStyles({
borderColor: "rgba(0, 0, 0, .05)", //lightest grey
boxShadow: "rgba(0, 46, 109, 0.3) 1px 2px 3px"
},
download: {
backgroundColor: ({ theme, color }) => theme[color],
borderColor: "rgb(167, 197, 57)", //site standard green
boxShadow: "rgb(167, 197, 57) 1px 2px 3px",
marginLeft: "auto"
},
outlined: {
backgroundColor: ({ theme }) => theme.colorWhite,
borderColor: "rgba(0, 46, 109, .2)", //medium grey
Expand Down Expand Up @@ -64,7 +70,7 @@ const Button = ({

Button.propTypes = {
onClick: PropTypes.func,
children: PropTypes.string,
children: PropTypes.any,
size: PropTypes.string,
variant: PropTypes.string,
isDisplayed: PropTypes.bool,
Expand Down
32 changes: 32 additions & 0 deletions client/src/components/Button/DownloadButton 2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from "react";
import PropTypes from "prop-types";
import Button from "../Button/Button";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faFileDownload } from "@fortawesome/free-solid-svg-icons";

const DownloadButton = ({ id, onClick, isDisplayed }) => {
return (
<Button
type="input"
color={"colorDisabled"}
variant="download"
id={id}
onClick={onClick}
data-testid={id}
isDisplayed={isDisplayed}
>
<FontAwesomeIcon icon={faFileDownload} style={{ marginRight: "0.5em" }} />
Download Summary
</Button>
);
};

DownloadButton.propTypes = {
children: PropTypes.object,
onClick: PropTypes.func,
ref: PropTypes.string,
id: PropTypes.string.isRequired,
isDisplayed: PropTypes.bool.isRequired
};

export default DownloadButton;
Loading

0 comments on commit 9797bdb

Please sign in to comment.