Skip to content

Commit

Permalink
[MDS-6225] - Project Summary status fix (#3330)
Browse files Browse the repository at this point in the history
* Refactor project callout logic and adjust status handling

Refactored ProjectCallout component to use a function for status text mapping to allow for differnces between core and minespace.  Updated status changes when saving project summary changes.

* Update snaps

* updated callout boolean use
  • Loading branch information
matbusby-fw authored Dec 5, 2024
1 parent 9f34bef commit 853836e
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 57 deletions.
143 changes: 90 additions & 53 deletions services/common/src/components/projects/ProjectCallout.tsx
Original file line number Diff line number Diff line change
@@ -1,67 +1,104 @@
import React, { FC, ReactElement } from "react";
import { CALLOUT_SEVERITY, MAJOR_MINE_APPLICATION_AND_IRT_STATUS_CODE_CODES, PROJECT_STATUS_CODES, PROJECT_SUMMARY_STATUS_CODES, SystemFlagEnum } from "@mds/common/constants";
import {
CALLOUT_SEVERITY,
MAJOR_MINE_APPLICATION_AND_IRT_STATUS_CODE_CODES,
PROJECT_STATUS_CODES,
PROJECT_SUMMARY_STATUS_CODES,
SystemFlagEnum,
} from "@mds/common/constants";
import Callout from "../common/Callout";
import { Alert, Col, Row } from "antd";
import { useSelector } from "react-redux";
import { getSystemFlag } from "@mds/common/redux/selectors/authenticationSelectors";

export const statusTextHash = {
"DFT": { severity: CALLOUT_SEVERITY.warning, message: "This project step has not been formally submitted by the proponent through MineSpace. MineSpace users can update text fields and add documents." },
"WDN": { severity: CALLOUT_SEVERITY.danger, message: "MineSpace users cannot update text fields or update documents. Contact the Ministry to change this status." },
"COM": { severity: CALLOUT_SEVERITY.success, message: "The review of this project is completed. MineSpace users cannot update text fields or update documents." },
"OHD": { severity: CALLOUT_SEVERITY.danger, message: "This project is on hold. MineSpace users cannot update text fields or update documents. Contact the Ministry to change this status." },
"SUB": { severity: CALLOUT_SEVERITY.success, message: "This project has been formally submitted by the proponent through MineSpace. MineSpace users can update documents only." },
"UNR": { severity: CALLOUT_SEVERITY.warning, message: "This project is being actively reviewed. MineSpace users cannot update text fields or update documents." },
"CHR": { severity: CALLOUT_SEVERITY.warning, message: "This project requires changes by the mine. MineSpace users can update text fields and update documents. Note: when the MineSpace user resubmits at this step the project status will be changed to under review." },
"ASG": { severity: CALLOUT_SEVERITY.success, message: "This project has been formally submitted by the proponent through MineSpace. MineSpace users can update documents only." }
}
export const statusTextHash = (status: string, isCore: boolean) => {
return (
{
DFT: {
severity: CALLOUT_SEVERITY.warning,
message:
"This project step has not been formally submitted by the proponent through MineSpace. MineSpace users can update text fields and add documents.",
},
WDN: {
severity: CALLOUT_SEVERITY.danger,
message:
"MineSpace users cannot update text fields or update documents. Contact the Ministry to change this status.",
},
COM: {
severity: CALLOUT_SEVERITY.success,
message:
"The review of this project is completed. MineSpace users cannot update text fields or update documents.",
},
OHD: {
severity: CALLOUT_SEVERITY.danger,
message:
"This project is on hold. MineSpace users cannot update text fields or update documents. Contact the Ministry to change this status.",
},
SUB: {
severity: CALLOUT_SEVERITY.success,
message:
"This project has been formally submitted by the proponent through MineSpace. MineSpace users can update documents only.",
},
UNR: {
severity: CALLOUT_SEVERITY.warning,
message:
"This project is being actively reviewed. MineSpace users cannot update text fields or update documents.",
},
CHR: {
severity: CALLOUT_SEVERITY.warning,
message: `This project requires changes by the mine. MineSpace users can update text fields and update documents.
Note: ${
isCore
? "when the MineSpace user resubmits at this step the project status will be changed to under review."
: "Navigate to the submit section of the form to resubmit your application after making any changes to have them resubmitted to the ministry."
}`,
},
ASG: {
severity: CALLOUT_SEVERITY.success,
message:
"This project has been formally submitted by the proponent through MineSpace. MineSpace users can update documents only.",
},
}[status] ?? {}
);
};

interface ProjectCalloutProps {
status_code: PROJECT_STATUS_CODES | MAJOR_MINE_APPLICATION_AND_IRT_STATUS_CODE_CODES;
formField?: ReactElement;
status_code: PROJECT_STATUS_CODES | MAJOR_MINE_APPLICATION_AND_IRT_STATUS_CODE_CODES;
formField?: ReactElement;
}

const ProjectCallout: FC<ProjectCalloutProps> = ({
status_code,
formField }) => {

const systemFlag = useSelector(getSystemFlag);
const isCore = systemFlag === SystemFlagEnum.core;
const calloutParams = statusTextHash[status_code ?? "DFT"];
let title = PROJECT_SUMMARY_STATUS_CODES[status_code ?? "DFT"];
const hasFormField = Boolean(formField);
const colProps = hasFormField ? { xs: 24, md: 18 } : { span: 24 };

if (status_code === PROJECT_STATUS_CODES.ASG && !isCore) {
title = PROJECT_SUMMARY_STATUS_CODES.SUB;
}
const ProjectCallout: FC<ProjectCalloutProps> = ({ status_code, formField }) => {
const systemFlag = useSelector(getSystemFlag);
const isCore = systemFlag === SystemFlagEnum.core;
const calloutParams = statusTextHash(status_code ?? "DFT", isCore);
let title = PROJECT_SUMMARY_STATUS_CODES[status_code ?? "DFT"];
const hasFormField = Boolean(formField);
const colProps = hasFormField ? { xs: 24, md: 18 } : { span: 24 };

return (
isCore ?
<Alert
message={title}
description={
<Row justify="space-between">
<Col {...colProps}>
{calloutParams.message}
</Col>
{hasFormField &&
<Col xs={24} md={6}>
{formField}
</Col>
}
</Row>
}
showIcon
type="warning"
className="margin-large--bottom"
/>
: <Callout
message={calloutParams.message}
title={title}
severity={calloutParams.severity}
if (status_code === PROJECT_STATUS_CODES.ASG && !isCore) {
title = PROJECT_SUMMARY_STATUS_CODES.SUB;
}

/>);
return isCore ? (
<Alert
message={title}
description={
<Row justify="space-between">
<Col {...colProps}>{calloutParams.message}</Col>
{hasFormField && (
<Col xs={24} md={6}>
{formField}
</Col>
)}
</Row>
}
showIcon
type="warning"
className="margin-large--bottom"
/>
) : (
<Callout message={calloutParams.message} title={title} severity={calloutParams.severity} />
);
};

export default ProjectCallout;
export default ProjectCallout;
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ def put(self, project_guid, project_summary_guid):
data.get('expected_draft_irt_submission_date'),
data.get('expected_permit_application_date'),
data.get('expected_permit_receipt_date'),
data.get('expected_project_start_date'), data.get('status_code'),
data.get('expected_project_start_date'),
data.get('status_code'),
data.get('project_lead_party_guid'),
documents, data.get('authorizations',[]),
ams_authorizations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export const ProjectSummaryPage = () => {
let status_code = projectSummary.status_code;
let is_historic = projectSummary.is_historic;

if (status_code === "CHR") {
if (status_code === "CHR" && formValues.confirmation_of_submission) {
status_code = "UNR";
} else if ((!status_code || !isEditMode) && status_code !== "UNR") {
status_code = "DFT";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2536,7 +2536,8 @@ exports[`MajorMineApplicationReviewSubmit renders properly as on ProjectPage 1`]
Change Requested
</p>
<p>
This project requires changes by the mine. MineSpace users can update text fields and update documents. Note: when the MineSpace user resubmits at this step the project status will be changed to under review.
This project requires changes by the mine. MineSpace users can update text fields and update documents.
Note: Navigate to the submit section of the form to resubmit your application after making any changes to have them resubmitted to the ministry.
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ exports[`MajorMinesApplicationPage renders properly 1`] = `
Change Requested
</p>
<p>
This project requires changes by the mine. MineSpace users can update text fields and update documents. Note: when the MineSpace user resubmits at this step the project status will be changed to under review.
This project requires changes by the mine. MineSpace users can update text fields and update documents.
Note: Navigate to the submit section of the form to resubmit your application after making any changes to have them resubmitted to the ministry.
</p>
</div>
<div>
Expand Down

0 comments on commit 853836e

Please sign in to comment.