-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MDS-6225] - Project Summary status fix (#3330)
* 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
1 parent
9f34bef
commit 853836e
Showing
5 changed files
with
97 additions
and
57 deletions.
There are no files selected for viewing
143 changes: 90 additions & 53 deletions
143
services/common/src/components/projects/ProjectCallout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters