From 2dc2bf3732f894fd2b86b6bc6372fc6799e5a336 Mon Sep 17 00:00:00 2001 From: Tara Epp <102187683+taraepp@users.noreply.github.com> Date: Fri, 18 Oct 2024 21:43:40 +0000 Subject: [PATCH 1/8] shush the key errors and sonarlint warnings --- .../dashboard/mine/projects/ProjectStagesTable.tsx | 9 ++++----- .../src/components/pages/Project/ProjectOverviewTab.tsx | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/services/minespace-web/src/components/dashboard/mine/projects/ProjectStagesTable.tsx b/services/minespace-web/src/components/dashboard/mine/projects/ProjectStagesTable.tsx index 842bd40a00..f79fbe19a5 100644 --- a/services/minespace-web/src/components/dashboard/mine/projects/ProjectStagesTable.tsx +++ b/services/minespace-web/src/components/dashboard/mine/projects/ProjectStagesTable.tsx @@ -13,9 +13,8 @@ interface ProjectStagesTableProps { export const ProjectStagesTable: FC = ({ projectStages }) => { const projectSummary = useSelector(getProjectSummary); - const transformRowData = (projectStages) => - projectStages && - projectStages.map((stage) => ({ + const transformRowData = (stages: IProjectStage[]) => + stages?.map((stage) => ({ key: stage.key, project_stage: stage.title, stage_status: stage.status === "ASG" ? "SUB" : stage.status, @@ -24,7 +23,7 @@ export const ProjectStagesTable: FC = ({ projectStages navigate_forward: stage.navigateForward, stage, })); - + console.log(transformRowData(projectStages)); const columns: ColumnsType = [ { title: "", @@ -134,7 +133,7 @@ export const ProjectStagesTable: FC = ({ projectStages showHeader={false} pagination={false} columns={columns} - rowKey="title" + rowKey="project_stage" dataSource={transformRowData(projectStages)} locale={{ emptyText: "This project has no stage data." }} /> diff --git a/services/minespace-web/src/components/pages/Project/ProjectOverviewTab.tsx b/services/minespace-web/src/components/pages/Project/ProjectOverviewTab.tsx index 84e7061a40..1f5ca395c6 100644 --- a/services/minespace-web/src/components/pages/Project/ProjectOverviewTab.tsx +++ b/services/minespace-web/src/components/pages/Project/ProjectOverviewTab.tsx @@ -164,7 +164,7 @@ export const ProjectOverviewTab: FC = ({ navigateForwar {EMLIcontactInfo.map((contact) => ( - + ))} From c050c6b5ca6f8c8e5a2c310d22940094b9955ebc Mon Sep 17 00:00:00 2001 From: Tara Epp <102187683+taraepp@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:29:14 +0000 Subject: [PATCH 2/8] fix routing on MS --- .../src/components/pages/Project/ProjectPage.tsx | 14 +++++++++++--- services/minespace-web/src/constants/routes.ts | 13 +++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/services/minespace-web/src/components/pages/Project/ProjectPage.tsx b/services/minespace-web/src/components/pages/Project/ProjectPage.tsx index f35d61519f..99ddbed78b 100644 --- a/services/minespace-web/src/components/pages/Project/ProjectPage.tsx +++ b/services/minespace-web/src/components/pages/Project/ProjectPage.tsx @@ -110,8 +110,13 @@ const ProjectPage: FC = () => { ), state: { current: 2, applicationSubmitted: true }, }); + } else { + const mmaTab = document.querySelector('[id*="major-mine-application"]') as HTMLElement; + if (!mmaTab) { + return null; + } + return mmaTab.click(); } - break; case "DFT": case "CHR": return history.push({ @@ -170,12 +175,15 @@ const ProjectPage: FC = () => { projectGuid, project?.information_requirements_table?.irt_guid ) - : `/projects/${projectGuid}/information-requirements-table/entry`; + : router.PROJECT_STAGE_ENTRY.dynamicRoute( + projectGuid, + "information-requirements-table" + ); const urlState = irtStatus == "APV" ? { state: { current: 2 } } : {}; return history.push({ pathname: url, ...urlState }); } case "major-mine-application": - url = `/projects/${projectGuid}/major-mine-application/entry`; + url = router.PROJECT_STAGE_ENTRY.dynamicRoute(projectGuid, newActiveTab); return history.push(url); default: diff --git a/services/minespace-web/src/constants/routes.ts b/services/minespace-web/src/constants/routes.ts index 173fc1a621..d6811e9d28 100755 --- a/services/minespace-web/src/constants/routes.ts +++ b/services/minespace-web/src/constants/routes.ts @@ -126,6 +126,13 @@ export const INFORMATION_REQUIREMENTS_TABLE_SUCCESS = { helpKey: "IRT-Submitted", }; +export const PROJECT_STAGE_ENTRY = { + route: "/projects/:projectGuid/:tab/entry", + dynamicRoute: (projectGuid: string, tab: string) => `/projects/${projectGuid}/${tab}/entry`, + component: ProjectPage, + helpKey: "Create-Project-Stage", +}; + export const EDIT_MAJOR_MINE_APPLICATION = { route: "/projects/:projectGuid/major-mine-application/:mmaGuid/edit", dynamicRoute: (projectGuid, mmaGuid) => @@ -218,8 +225,7 @@ export const EDIT_TAILINGS_STORAGE_FACILITY = { activeTab = "basic-information", isEditMode = false ) => - `/mines/${mineGuid}/tailings-storage-facility/${tailingsStorageFacilityGuid}/${activeTab}/${ - isEditMode ? "edit" : "view" + `/mines/${mineGuid}/tailings-storage-facility/${tailingsStorageFacilityGuid}/${activeTab}/${isEditMode ? "edit" : "view" }`, component: TailingsSummaryPageWrapper, helpKey: "Edit-Tailings-Storage-Facility", @@ -244,8 +250,7 @@ export const EDIT_DAM = { isEditMode = false, canEditDam = false ) => - `/mine/${mineGuid}/tailings-storage-facility/${tailingsStorageFacilityGuid}/${ - isEditMode ? "edit" : "view" + `/mine/${mineGuid}/tailings-storage-facility/${tailingsStorageFacilityGuid}/${isEditMode ? "edit" : "view" }/${canEditDam ? "editDam" : "viewDam"}/dam/${damGuid}`, component: DamsPage, helpKey: "Edit-Dam", From 3037071ef827bd9263eae5f5c575bd5637020254 Mon Sep 17 00:00:00 2001 From: Tara Epp <102187683+taraepp@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:31:11 +0000 Subject: [PATCH 3/8] remove console log --- .../components/dashboard/mine/projects/ProjectStagesTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/minespace-web/src/components/dashboard/mine/projects/ProjectStagesTable.tsx b/services/minespace-web/src/components/dashboard/mine/projects/ProjectStagesTable.tsx index f79fbe19a5..b0487790e6 100644 --- a/services/minespace-web/src/components/dashboard/mine/projects/ProjectStagesTable.tsx +++ b/services/minespace-web/src/components/dashboard/mine/projects/ProjectStagesTable.tsx @@ -23,7 +23,7 @@ export const ProjectStagesTable: FC = ({ projectStages navigate_forward: stage.navigateForward, stage, })); - console.log(transformRowData(projectStages)); + const columns: ColumnsType = [ { title: "", From fc02e9f6adef86f3d575be8ee90b5ec9760d626e Mon Sep 17 00:00:00 2001 From: Tara Epp <102187683+taraepp@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:33:32 +0000 Subject: [PATCH 4/8] refactored to TS --- ...tStagesTable.js => ProjectStagesTable.tsx} | 48 +++++++++---------- 1 file changed, 22 insertions(+), 26 deletions(-) rename services/core-web/src/components/mine/Projects/{ProjectStagesTable.js => ProjectStagesTable.tsx} (68%) diff --git a/services/core-web/src/components/mine/Projects/ProjectStagesTable.js b/services/core-web/src/components/mine/Projects/ProjectStagesTable.tsx similarity index 68% rename from services/core-web/src/components/mine/Projects/ProjectStagesTable.js rename to services/core-web/src/components/mine/Projects/ProjectStagesTable.tsx index 63eb7413eb..89cbcbc4de 100644 --- a/services/core-web/src/components/mine/Projects/ProjectStagesTable.js +++ b/services/core-web/src/components/mine/Projects/ProjectStagesTable.tsx @@ -1,15 +1,15 @@ -import React, { Component } from "react"; -import PropTypes from "prop-types"; +import React, { FC } from "react"; import { Table } from "antd"; +import { IProjectStage } from "@mds/common/interfaces/projects/projectStage.interface"; +import { ColumnsType } from "antd/es/table"; -const propTypes = { - projectStages: PropTypes.arrayOf(PropTypes.any).isRequired, -}; +interface ProjectStagesTableProps { + projectStages: IProjectStage[]; +} -export class ProjectStagesTable extends Component { - transformRowData = (projectStages) => - projectStages && - projectStages.map((stage) => ({ +export const ProjectStagesTable: FC = ({ projectStages }) => { + const transformRowData = (stages) => + stages?.map((stage) => ({ key: stage.key, project_stage: stage.title, stage_status: stage.status, @@ -17,8 +17,8 @@ export class ProjectStagesTable extends Component { link: stage.link, stage, })); - - columns = () => [ + console.log(transformRowData(projectStages)); + const columns: ColumnsType = [ { title: "", dataIndex: "project_stage", @@ -68,20 +68,16 @@ export class ProjectStagesTable extends Component { }, ]; - render() { - return ( - - ); - } -} - -ProjectStagesTable.propTypes = propTypes; + return ( +
+ ); +}; export default ProjectStagesTable; From b3bbecb7738a1394c1b68e6229cac19aaa2eff62 Mon Sep 17 00:00:00 2001 From: Tara Epp <102187683+taraepp@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:02:46 +0000 Subject: [PATCH 5/8] make things TS-y on CORE, shush a key warningabout the project contact, and remove some unused params --- .../mine/Projects/ProjectOverviewTab.js | 286 ------------------ .../mine/Projects/ProjectOverviewTab.tsx | 254 ++++++++++++++++ .../mine/Projects/ProjectStagesTable.tsx | 11 +- .../ProjectStagesTable.spec.js.snap | 2 +- .../ProjectOverviewTab.spec.tsx.snap | 3 + 5 files changed, 265 insertions(+), 291 deletions(-) delete mode 100644 services/core-web/src/components/mine/Projects/ProjectOverviewTab.js create mode 100644 services/core-web/src/components/mine/Projects/ProjectOverviewTab.tsx diff --git a/services/core-web/src/components/mine/Projects/ProjectOverviewTab.js b/services/core-web/src/components/mine/Projects/ProjectOverviewTab.js deleted file mode 100644 index 121ca70be4..0000000000 --- a/services/core-web/src/components/mine/Projects/ProjectOverviewTab.js +++ /dev/null @@ -1,286 +0,0 @@ -import React, { Component } from "react"; -import { connect } from "react-redux"; -import { Link } from "react-router-dom"; -import { Row, Col, Typography, Descriptions, Card, Button } from "antd"; -import PropTypes from "prop-types"; -import { - getProjectSummaryDocumentTypesHash, - getProjectSummaryStatusCodesHash, - getInformationRequirementsTableStatusCodesHash, - getMajorMinesApplicationStatusCodesHash, -} from "@mds/common/redux/selectors/staticContentSelectors"; -import { getProjectLeads } from "@mds/common/redux/selectors/partiesSelectors"; -import { formatDate } from "@common/utils/helpers"; -import * as Strings from "@mds/common/constants/strings"; -import { getProject } from "@mds/common/redux/selectors/projectSelectors"; -import * as routes from "@/constants/routes"; -import CustomPropTypes from "@/customPropTypes"; -import ProjectStagesTable from "./ProjectStagesTable"; -import withFeatureFlag from "@mds/common/providers/featureFlags/withFeatureFlag"; -import { Feature } from "@mds/common"; -import ProjectLinks from "@mds/common/components/projectSummary/ProjectLinks"; - -const propTypes = { - informationRequirementsTableStatusCodesHash: PropTypes.objectOf(PropTypes.string).isRequired, - projectSummaryStatusCodesHash: PropTypes.objectOf(PropTypes.string).isRequired, - majorMineApplicationStatusCodeHash: PropTypes.objectOf(PropTypes.string).isRequired, - project: CustomPropTypes.project.isRequired, - projectLeads: CustomPropTypes.projectContact.isRequired, - isFeatureEnabled: PropTypes.func.isRequired, -}; - -export class ProjectOverviewTab extends Component { - renderProjectContactsCard = (contacts = []) => { - return ( - - {contacts.map((c) => { - const isPrimary = c.is_primary; - const hasJobTitle = c.job_title; - const isProjectLeadContact = c.is_project_lead_contact; - const name = [c?.first_name, c?.last_name].join(" ").trim(); - let title; - if (isProjectLeadContact) { - title = "EMLI Project Lead"; - } else if (isPrimary) { - title = "Primary Contact"; - } else if (hasJobTitle) { - title = c.job_title; - } - return ( - - {title && ( - - {title} - - )} -
- {c.is_project_lead_contact && !c.first_name ? ( - Project Lead has not been assigned - ) : ( - <> - {name || Strings.EMPTY_FIELD} -
- {c.phone_no || c.phone_number} -
- {c.email && ( - - {c.email} - - )} - - )} -
- ); - })} -
- ); - }; - - render() { - const shouldDisplayLinkedProjects = this.props.isFeatureEnabled( - Feature.MAJOR_PROJECT_LINK_PROJECTS - ); - const { - project_summary_description, - expected_draft_irt_submission_date, - expected_permit_application_date, - expected_permit_receipt_date, - expected_project_start_date, - project_guid, - project_summary_id, - project_summary_guid, - status_code, - } = this.props.project.project_summary; - - const hasInformationRequirementsTable = Boolean( - this.props.project.information_requirements_table?.irt_guid - ); - - const project_lead_contact = - this.props.projectLeads?.filter((lead) => - lead.party_guid.includes(this.props.project.project_lead_party_guid) - ) ?? []; - if (project_lead_contact?.length > 0) { - project_lead_contact[0].is_project_lead_contact = true; - } else { - project_lead_contact.push({ is_project_lead_contact: true }); - } - - const contactsAndProjectLead = [...this.props.project.contacts]; - contactsAndProjectLead.push(project_lead_contact[0]); - - const requiredProjectStages = [ - { - title: "REQUIRED STAGES", - key: "req-stages-id", - status: "STATUS", - isTitle: true, - }, - ]; - - let optionalProjectStages = [ - { - title: "OPTIONAL STAGES", - key: "opt-stages-id", - status: "STATUS", - isOptional: true, - isTitle: true, - }, - ]; - - requiredProjectStages.push( - { - title: "Project description", - key: `ps-${project_summary_id}`, - status: status_code, - payload: this.props.project.project_summary, - statusHash: this.props.projectSummaryStatusCodesHash, - link: ( - - - - ), - }, - { - title: "Final Application", - key: `ps-${this.props.project.major_mine_application.major_mine_application_id}`, - status: this.props.project.major_mine_application.status_code, - payload: this.props.project.major_mine_application, - statusHash: this.props.majorMineApplicationStatusCodeHash, - link: ( - - - - ), - } - ); - - const irt = { - title: "Final IRT", - key: `irt-${this.props.project.information_requirements_table?.irt_id || 0}`, - status: this.props.project.information_requirements_table?.status_code, - payload: this.props.project.information_requirements_table, - statusHash: this.props.informationRequirementsTableStatusCodesHash, - link: ( - - - - ), - }; - - if (this.props.project.mrc_review_required) { - requiredProjectStages.push(irt); - } else { - optionalProjectStages.push({ ...irt, isOptional: true }); - } - - if (optionalProjectStages.length === 1) { - optionalProjectStages = []; - } - - return ( - - - Overview - PROJECT DESCRIPTION - {project_summary_description} - KEY DATES - - - - - {formatDate(expected_draft_irt_submission_date) || Strings.EMPTY_FIELD} - - - {formatDate(expected_permit_receipt_date) || Strings.EMPTY_FIELD} - - - - - - - {formatDate(expected_permit_application_date) || Strings.EMPTY_FIELD} - - - {formatDate(expected_project_start_date) || Strings.EMPTY_FIELD} - - - - - Project Stages - -
- {shouldDisplayLinkedProjects && ( - - routes.EDIT_PROJECT_SUMMARY.dynamicRoute(p.project_guid, p.project_summary_guid) - } - /> - )} - -
- - {this.renderProjectContactsCard(contactsAndProjectLead)} - - - - ); - } -} - -const mapStateToProps = (state) => ({ - project: getProject(state), - projectSummaryDocumentTypesHash: getProjectSummaryDocumentTypesHash(state), - projectSummaryStatusCodesHash: getProjectSummaryStatusCodesHash(state), - majorMineApplicationStatusCodeHash: getMajorMinesApplicationStatusCodesHash(state), - informationRequirementsTableStatusCodesHash: getInformationRequirementsTableStatusCodesHash( - state - ), - projectLeads: getProjectLeads(state), -}); - -ProjectOverviewTab.propTypes = propTypes; - -export default connect(mapStateToProps, null)(withFeatureFlag(ProjectOverviewTab)); diff --git a/services/core-web/src/components/mine/Projects/ProjectOverviewTab.tsx b/services/core-web/src/components/mine/Projects/ProjectOverviewTab.tsx new file mode 100644 index 0000000000..2248cc44d2 --- /dev/null +++ b/services/core-web/src/components/mine/Projects/ProjectOverviewTab.tsx @@ -0,0 +1,254 @@ +import React, { FC } from "react"; +import { useSelector } from "react-redux"; +import { Link } from "react-router-dom"; +import { Row, Col, Typography, Descriptions, Card, Button } from "antd"; +import { + getProjectSummaryStatusCodesHash, + getInformationRequirementsTableStatusCodesHash, + getMajorMinesApplicationStatusCodesHash, +} from "@mds/common/redux/selectors/staticContentSelectors"; +import { getProjectLeads } from "@mds/common/redux/selectors/partiesSelectors"; +import { formatDate } from "@common/utils/helpers"; +import * as Strings from "@mds/common/constants/strings"; +import { getProject } from "@mds/common/redux/selectors/projectSelectors"; +import * as routes from "@/constants/routes"; +import ProjectStagesTable from "./ProjectStagesTable"; +import { Feature } from "@mds/common"; +import ProjectLinks from "@mds/common/components/projectSummary/ProjectLinks"; +import { useFeatureFlag } from "@mds/common/providers/featureFlags/useFeatureFlag"; + +export const ProjectOverviewTab: FC = () => { + const project = useSelector(getProject); + const projectSummaryStatusCodesHash = useSelector(getProjectSummaryStatusCodesHash); + const majorMineApplicationStatusCodeHash = useSelector(getMajorMinesApplicationStatusCodesHash); + const informationRequirementsTableStatusCodesHash = useSelector( + getInformationRequirementsTableStatusCodesHash + ); + const projectLeads = useSelector(getProjectLeads); + + const { isFeatureEnabled } = useFeatureFlag(); + const shouldDisplayLinkedProjects = isFeatureEnabled(Feature.MAJOR_PROJECT_LINK_PROJECTS); + + const { + project_summary_description, + expected_draft_irt_submission_date, + expected_permit_application_date, + expected_permit_receipt_date, + expected_project_start_date, + project_guid, + project_summary_id, + project_summary_guid, + status_code, + } = project.project_summary; + + const hasInformationRequirementsTable = Boolean(project.information_requirements_table?.irt_guid); + + const project_lead_contact = + projectLeads?.filter((lead) => lead.party_guid.includes(project.project_lead_party_guid)) ?? []; + + if (project_lead_contact?.length > 0) { + project_lead_contact[0].is_project_lead_contact = true; + } else { + project_lead_contact.push({ is_project_lead_contact: true, project_contact_guid: "n/a" }); + } + + const contactsAndProjectLead = [...project.contacts]; + contactsAndProjectLead.push(project_lead_contact[0]); + + const requiredProjectStages: any[] = [ + { + title: "REQUIRED STAGES", + key: "req-stages-id", + status: "STATUS", + isTitle: true, + }, + ]; + + let optionalProjectStages: any[] = [ + { + title: "OPTIONAL STAGES", + key: "opt-stages-id", + status: "STATUS", + isOptional: true, + isTitle: true, + }, + ]; + + requiredProjectStages.push( + { + title: "Project description", + key: `ps-${project_summary_id}`, + status: status_code, + statusHash: projectSummaryStatusCodesHash, + link: ( + + + + ), + }, + { + title: "Final Application", + key: `ps-${project.major_mine_application.major_mine_application_id}`, + status: project.major_mine_application.status_code, + statusHash: majorMineApplicationStatusCodeHash, + link: ( + + + + ), + } + ); + + const irt = { + title: "Final IRT", + key: `irt-${project.information_requirements_table?.irt_id || 0}`, + status: project.information_requirements_table?.status_code, + statusHash: informationRequirementsTableStatusCodesHash, + link: ( + + + + ), + }; + + if (project.mrc_review_required) { + requiredProjectStages.push(irt); + } else { + optionalProjectStages.push({ ...irt, isOptional: true }); + } + + if (optionalProjectStages.length === 1) { + optionalProjectStages = []; + } + + const renderProjectContactsCard = (contacts = []) => { + return ( + + {contacts.map((c) => { + const isPrimary = c.is_primary; + const hasJobTitle = c.job_title; + const isProjectLeadContact = c.is_project_lead_contact; + const name = [c?.first_name, c?.last_name].join(" ").trim(); + let title; + + if (isProjectLeadContact) { + title = "EMLI Project Lead"; + } else if (isPrimary) { + title = "Primary Contact"; + } else if (hasJobTitle) { + title = c.job_title; + } + return ( + + {title && ( + + {title} + + )} +
+ {c.is_project_lead_contact && !c.first_name ? ( + Project Lead has not been assigned + ) : ( + <> + {name || Strings.EMPTY_FIELD} +
+ {c.phone_no || c.phone_number} +
+ {c.email && ( + + {c.email} + + )} + + )} +
+ ); + })} +
+ ); + }; + + return ( + + + Overview + PROJECT DESCRIPTION + {project_summary_description} + KEY DATES + + + + + {formatDate(expected_draft_irt_submission_date) || Strings.EMPTY_FIELD} + + + {formatDate(expected_permit_receipt_date) || Strings.EMPTY_FIELD} + + + + + + + {formatDate(expected_permit_application_date) || Strings.EMPTY_FIELD} + + + {formatDate(expected_project_start_date) || Strings.EMPTY_FIELD} + + + + + Project Stages + +
+ {shouldDisplayLinkedProjects && ( + + routes.EDIT_PROJECT_SUMMARY.dynamicRoute(p.project_guid, p.project_summary_guid) + } + /> + )} + +
+ + {renderProjectContactsCard(contactsAndProjectLead)} + + + + ); +}; + +export default ProjectOverviewTab; diff --git a/services/core-web/src/components/mine/Projects/ProjectStagesTable.tsx b/services/core-web/src/components/mine/Projects/ProjectStagesTable.tsx index 89cbcbc4de..774e49c436 100644 --- a/services/core-web/src/components/mine/Projects/ProjectStagesTable.tsx +++ b/services/core-web/src/components/mine/Projects/ProjectStagesTable.tsx @@ -3,8 +3,11 @@ import { Table } from "antd"; import { IProjectStage } from "@mds/common/interfaces/projects/projectStage.interface"; import { ColumnsType } from "antd/es/table"; +interface TableProjectStage extends IProjectStage { + link: string; +} interface ProjectStagesTableProps { - projectStages: IProjectStage[]; + projectStages: TableProjectStage[]; } export const ProjectStagesTable: FC = ({ projectStages }) => { @@ -17,7 +20,7 @@ export const ProjectStagesTable: FC = ({ projectStages link: stage.link, stage, })); - console.log(transformRowData(projectStages)); + const columns: ColumnsType = [ { title: "", @@ -62,9 +65,9 @@ export const ProjectStagesTable: FC = ({ projectStages }, { title: "", - dataIndex: "stage", + dataIndex: "link", align: "right", - render: (text, record) => record?.link, + render: (text) => text, }, ]; diff --git a/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectStagesTable.spec.js.snap b/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectStagesTable.spec.js.snap index 7c940b2e89..2c9f639b74 100644 --- a/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectStagesTable.spec.js.snap +++ b/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectStagesTable.spec.js.snap @@ -16,7 +16,7 @@ exports[`ProjectStagesTable renders properly 1`] = ` }, Object { "align": "right", - "dataIndex": "stage", + "dataIndex": "link", "render": [Function], "title": "", }, diff --git a/services/minespace-web/src/tests/components/project/projectOverviewTab/__snapshots__/ProjectOverviewTab.spec.tsx.snap b/services/minespace-web/src/tests/components/project/projectOverviewTab/__snapshots__/ProjectOverviewTab.spec.tsx.snap index 898a5e86ac..0e37d4b005 100644 --- a/services/minespace-web/src/tests/components/project/projectOverviewTab/__snapshots__/ProjectOverviewTab.spec.tsx.snap +++ b/services/minespace-web/src/tests/components/project/projectOverviewTab/__snapshots__/ProjectOverviewTab.spec.tsx.snap @@ -246,6 +246,7 @@ exports[`ProjectOverviewTab renders properly 1`] = ` > @@ -113,7 +115,7 @@ exports[`ProjectOverviewTab renders properly 1`] = ` - N/A + Nov 20 2020 @@ -165,7 +167,7 @@ exports[`ProjectOverviewTab renders properly 1`] = ` - N/A + Nov 12 2020 @@ -201,7 +203,7 @@ exports[`ProjectOverviewTab renders properly 1`] = ` - N/A + Nov 22 2020 @@ -279,7 +281,7 @@ exports[`ProjectOverviewTab renders properly 1`] = ` @@ -311,14 +313,14 @@ exports[`ProjectOverviewTab renders properly 1`] = ` > @@ -326,7 +328,7 @@ exports[`ProjectOverviewTab renders properly 1`] = ` @@ -358,7 +360,7 @@ exports[`ProjectOverviewTab renders properly 1`] = ` > @@ -442,11 +444,10 @@ exports[`ProjectOverviewTab renders properly 1`] = ` >
Date: Mon, 21 Oct 2024 19:33:57 +0000 Subject: [PATCH 6/8] testing & solarlint issues on CORE --- .../projects/projectStage.interface.ts | 9 +- .../mine/Projects/ProjectStagesTable.tsx | 12 +- .../mine/Projects/ProjectOverviewTab.spec.js | 32 - .../mine/Projects/ProjectOverviewTab.spec.tsx | 30 + .../mine/Projects/ProjectStagesTable.spec.js | 30 - .../mine/Projects/ProjectStagesTable.spec.tsx | 71 +++ .../ProjectOverviewTab.spec.js.snap | 99 --- .../ProjectOverviewTab.spec.tsx.snap | 599 ++++++++++++++++++ .../ProjectStagesTable.spec.js.snap | 87 --- .../ProjectStagesTable.spec.tsx.snap | 222 +++++++ 10 files changed, 933 insertions(+), 258 deletions(-) delete mode 100644 services/core-web/src/tests/components/mine/Projects/ProjectOverviewTab.spec.js create mode 100644 services/core-web/src/tests/components/mine/Projects/ProjectOverviewTab.spec.tsx delete mode 100644 services/core-web/src/tests/components/mine/Projects/ProjectStagesTable.spec.js create mode 100644 services/core-web/src/tests/components/mine/Projects/ProjectStagesTable.spec.tsx delete mode 100644 services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectOverviewTab.spec.js.snap create mode 100644 services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectOverviewTab.spec.tsx.snap delete mode 100644 services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectStagesTable.spec.js.snap create mode 100644 services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectStagesTable.spec.tsx.snap diff --git a/services/common/src/interfaces/projects/projectStage.interface.ts b/services/common/src/interfaces/projects/projectStage.interface.ts index 30c6b065d9..03c82c2639 100644 --- a/services/common/src/interfaces/projects/projectStage.interface.ts +++ b/services/common/src/interfaces/projects/projectStage.interface.ts @@ -4,8 +4,9 @@ export interface IProjectStage { title: string; key: string; status: string; - payload: IProjectSummary; - statusHash: any; - required: boolean; - navigateForward: (source: string, status: string) => void; + payload?: IProjectSummary; + statusHash?: any; + required?: boolean; + isOptional?: boolean; + navigateForward?: (source: string, status: string) => void; } diff --git a/services/core-web/src/components/mine/Projects/ProjectStagesTable.tsx b/services/core-web/src/components/mine/Projects/ProjectStagesTable.tsx index 774e49c436..dc0e4ac792 100644 --- a/services/core-web/src/components/mine/Projects/ProjectStagesTable.tsx +++ b/services/core-web/src/components/mine/Projects/ProjectStagesTable.tsx @@ -1,10 +1,10 @@ -import React, { FC } from "react"; +import React, { FC, ReactNode } from "react"; import { Table } from "antd"; import { IProjectStage } from "@mds/common/interfaces/projects/projectStage.interface"; import { ColumnsType } from "antd/es/table"; interface TableProjectStage extends IProjectStage { - link: string; + link?: Element | ReactNode; } interface ProjectStagesTableProps { projectStages: TableProjectStage[]; @@ -45,10 +45,10 @@ export const ProjectStagesTable: FC = ({ projectStages if (text === "STATUS") { label = text; } else { - label = - record.key && record.stage_status - ? `[${record.stage_status_hash[text]}]` || "N/A" - : "[Not submitted]"; + label = "[Not submitted]"; + if (record.key && record.stage_status) { + label = record.stage_status_hash[text] ? `[${record.stage_status_hash[text]}]` : "N/A"; + } } return (
diff --git a/services/core-web/src/tests/components/mine/Projects/ProjectOverviewTab.spec.js b/services/core-web/src/tests/components/mine/Projects/ProjectOverviewTab.spec.js deleted file mode 100644 index 5f1efb8ffa..0000000000 --- a/services/core-web/src/tests/components/mine/Projects/ProjectOverviewTab.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -import React from "react"; -import { shallow } from "enzyme"; -import { ProjectOverviewTab } from "@/components/mine/Projects/ProjectOverviewTab"; -import * as MOCK from "@/tests/mocks/dataMocks"; -import FeatureFlagContext from "@mds/common/providers/featureFlags/featureFlag.context"; - -const props = {}; - -const setupProps = () => { - props.projectSummaryDocumentTypesHash = MOCK.PROJECT_SUMMARY_DOCUMENT_TYPES_HASH; - props.projectSummaryStatusCodesHash = MOCK.PROJECT_SUMMARY_STATUS_ALIAS_CODES_HASH; - props.project = MOCK.PROJECT; -}; - -beforeEach(() => { - setupProps(); -}); - -describe("ProjectOverviewTab", () => { - it("renders properly", () => { - const component = shallow( - true, - }} - > - - - ); - expect(component).toMatchSnapshot(); - }); -}); diff --git a/services/core-web/src/tests/components/mine/Projects/ProjectOverviewTab.spec.tsx b/services/core-web/src/tests/components/mine/Projects/ProjectOverviewTab.spec.tsx new file mode 100644 index 0000000000..df2b0faf95 --- /dev/null +++ b/services/core-web/src/tests/components/mine/Projects/ProjectOverviewTab.spec.tsx @@ -0,0 +1,30 @@ +import React from "react"; +import { render } from "@testing-library/react"; +import { ProjectOverviewTab } from "@/components/mine/Projects/ProjectOverviewTab"; +import * as MOCK from "@/tests/mocks/dataMocks"; +import { PROJECTS, STATIC_CONTENT } from "@mds/common/constants/reducerTypes"; +import { BrowserRouter } from "react-router-dom"; +import { ReduxWrapper } from "@/tests/utils/ReduxWrapper"; + +const initialState = { + [PROJECTS]: { + projects: MOCK.PROJECTS.records, + project: MOCK.PROJECT, + projectSummary: MOCK.PROJECT_SUMMARY, + informationRequirementsTable: MOCK.INFORMATION_REQUIREMENTS_TABLE, + }, + [STATIC_CONTENT]: MOCK.BULK_STATIC_CONTENT_RESPONSE, +}; + +describe("ProjectOverviewTab", () => { + it("renders properly", () => { + const { container } = render( + + + + + + ); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/services/core-web/src/tests/components/mine/Projects/ProjectStagesTable.spec.js b/services/core-web/src/tests/components/mine/Projects/ProjectStagesTable.spec.js deleted file mode 100644 index 11a8658835..0000000000 --- a/services/core-web/src/tests/components/mine/Projects/ProjectStagesTable.spec.js +++ /dev/null @@ -1,30 +0,0 @@ -import React from "react"; -import { shallow } from "enzyme"; -import { ProjectStagesTable } from "@/components/mine/Projects/ProjectStagesTable"; -import * as MOCK from "@/tests/mocks/dataMocks"; - -const props = {}; - -const setupProps = () => { - props.projectStages = [ - { - title: "Project description", - key: 1, - status: "SUB", - payload: MOCK.PROJECT_SUMMARY, - statusHash: MOCK.PROJECT_SUMMARY_STATUS_CODES_HASH, - link: null, - }, - ]; -}; - -beforeEach(() => { - setupProps(); -}); - -describe("ProjectStagesTable", () => { - it("renders properly", () => { - const component = shallow(); - expect(component).toMatchSnapshot(); - }); -}); diff --git a/services/core-web/src/tests/components/mine/Projects/ProjectStagesTable.spec.tsx b/services/core-web/src/tests/components/mine/Projects/ProjectStagesTable.spec.tsx new file mode 100644 index 0000000000..502622b384 --- /dev/null +++ b/services/core-web/src/tests/components/mine/Projects/ProjectStagesTable.spec.tsx @@ -0,0 +1,71 @@ +import React from "react"; +import { render } from "@testing-library/react"; +import { ProjectStagesTable } from "@/components/mine/Projects/ProjectStagesTable"; +import * as MOCK from "@/tests/mocks/dataMocks"; +import { ReduxWrapper } from "@/tests/utils/ReduxWrapper"; + +const projectStages = [ + { + title: "REQUIRED STAGES", + key: "req-stages-id", + status: "STATUS", + isTitle: true, + }, + { + key: "ps-519", + link:
link 1
, + status: "DFT", + statusHash: { + WDN: "Withdrawn", + UNR: "Under review", + SUB: "Submitted", + OHD: "On Hold", + DFT: "Draft", + COM: "Complete", + CHR: "Change Requested", + ASG: "Assigned", + }, + title: "Project description", + }, + { + key: "ps-null", + link:
link 2
, + status: null, + statusHash: { + UNR: "Under review", + SUB: "Submitted", + DFT: "Draft", + CHR: "Change Requested", + APV: "Approved", + }, + title: "Final Application", + }, + { + title: "OPTIONAL STAGES", + key: "opt-stages-id", + status: "STATUS", + isOptional: true, + isTitle: true, + }, + { + isOptional: true, + key: "irt-0", + link:
link 3
, + status: null, + statusHash: { + UNR: "Under review", + SUB: "Submitted", + DFT: "Draft", + CHR: "Change Requested", + APV: "Approved", + }, + title: "Final IRT", + }, +]; + +describe("ProjectStagesTable", () => { + it("renders properly", () => { + const { container } = render(); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectOverviewTab.spec.js.snap b/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectOverviewTab.spec.js.snap deleted file mode 100644 index 8c40440cb9..0000000000 --- a/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectOverviewTab.spec.js.snap +++ /dev/null @@ -1,99 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ProjectOverviewTab renders properly 1`] = ` - -`; diff --git a/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectOverviewTab.spec.tsx.snap b/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectOverviewTab.spec.tsx.snap new file mode 100644 index 0000000000..8f856209cd --- /dev/null +++ b/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectOverviewTab.spec.tsx.snap @@ -0,0 +1,599 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ProjectOverviewTab renders properly 1`] = ` +
+
+
+

+ Overview +

+ + + PROJECT DESCRIPTION + + +
+ + + KEY DATES + + +
+
+
+
+ + + + + + + + + + + + + + + +
+
+ + Estimated IRT Submission + +
+
+
+ + N/A + +
+
+
+ + Desired date to receive permit/amendment(s) + +
+
+
+ + N/A + +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + +
+
+ + Estimated Permit Application Submission + +
+
+
+ + N/A + +
+
+
+ + Anticipated work start + +
+
+
+ + N/A + +
+
+
+
+
+
+

+ Project Stages +

+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ REQUIRED STAGES +
+
+
+
+
+ STATUS +
+
+
+
+
+ + Project description + +
+
+
+ + [Not submitted] + +
+
+ + + +
+
+ + Final Application + +
+
+
+ + [Not submitted] + +
+
+ + + +
+
+
+ OPTIONAL STAGES +
+
+
+
+
+ STATUS +
+
+
+
+
+
+ Final IRT +
+
+
+
+
+ [Not submitted] +
+
+
+ + + +
+
+
+
+
+
+
+
+

+ Related Project Applications +

+
+ Description of related major project applications for this mine are listed below. +
+
+
+
+
+
+
+ + + + + + + + + + + + +
+ Project Title + + Project # + + Status + + Contact + + Last Updated + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Project Contacts +
+
+
+
+
+ + + EMLI Project Lead + + +
+ + Project Lead has not been assigned + +
+
+
+
+
+
+
+
+`; diff --git a/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectStagesTable.spec.js.snap b/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectStagesTable.spec.js.snap deleted file mode 100644 index 2c9f639b74..0000000000 --- a/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectStagesTable.spec.js.snap +++ /dev/null @@ -1,87 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ProjectStagesTable renders properly 1`] = ` - -`; diff --git a/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectStagesTable.spec.tsx.snap b/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectStagesTable.spec.tsx.snap new file mode 100644 index 0000000000..5ad92c8f28 --- /dev/null +++ b/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectStagesTable.spec.tsx.snap @@ -0,0 +1,222 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ProjectStagesTable renders properly 1`] = ` +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ REQUIRED STAGES +
+
+
+
+
+ STATUS +
+
+
+
+
+ + Project description + +
+
+
+ + [Draft] + +
+
+
+ link 1 +
+
+
+ + Final Application + +
+
+
+ + [Not submitted] + +
+
+
+ link 2 +
+
+
+
+ OPTIONAL STAGES +
+
+
+
+
+ STATUS +
+
+
+
+
+
+ Final IRT +
+
+
+
+
+ [Not submitted] +
+
+
+
+ link 3 +
+
+
+
+
+
+
+
+
+`; From 956032b333b63ad9af4aad7ccaa8b60cc241f897 Mon Sep 17 00:00:00 2001 From: Tara Epp <102187683+taraepp@users.noreply.github.com> Date: Mon, 21 Oct 2024 19:55:24 +0000 Subject: [PATCH 7/8] flesh out data mocks a bit, use common one where we weren't already --- services/common/src/tests/mocks/dataMocks.tsx | 67 +++++++++ .../mine/Projects/ProjectOverviewTab.spec.tsx | 2 +- .../mine/Projects/ProjectStagesTable.spec.tsx | 2 - .../ProjectOverviewTab.spec.tsx.snap | 66 ++++++--- .../ProjectOverviewTab.spec.tsx | 5 +- .../ProjectOverviewTab.spec.tsx.snap | 133 +++++++++++++++++- .../project/projectPage/ProjectPage.spec.tsx | 3 +- 7 files changed, 256 insertions(+), 22 deletions(-) diff --git a/services/common/src/tests/mocks/dataMocks.tsx b/services/common/src/tests/mocks/dataMocks.tsx index b822c2eec9..106fbe01ff 100644 --- a/services/common/src/tests/mocks/dataMocks.tsx +++ b/services/common/src/tests/mocks/dataMocks.tsx @@ -7350,6 +7350,73 @@ export const EXPLOSIVES_PERMITS = { }, }; +export const EMLI_CONTACTS_BY_REGION = [ + { + contact_guid: "7f107cdd-974c-4505-b076-9a88438a2fce", + contact_id: 1, + emli_contact_type_code: "MMO", + mine_region_code: null, + is_major_mine: true, + is_general_contact: false, + email: "TestPermRecl@gov.bc.ca", + phone_number: null, + first_name: null, + last_name: null, + fax_number: null, + mailing_address_line_1: null, + mailing_address_line_2: null, + deleted_ind: false, + }, + { + contact_guid: "f9c42bc7-6d02-4830-b1e0-51a64e8b28cb", + contact_id: 2, + emli_contact_type_code: "CHI", + mine_region_code: null, + is_major_mine: true, + is_general_contact: true, + email: "anna.albright@gov.bc.ca", + phone_number: "123-234-3456", + first_name: "Anna", + last_name: "Albright", + fax_number: null, + mailing_address_line_1: null, + mailing_address_line_2: null, + deleted_ind: false, + }, + { + contact_guid: "eee5bb02-e92d-43b9-baf0-b7ee07dedbaf", + contact_id: 3, + emli_contact_type_code: "CHP", + mine_region_code: null, + is_major_mine: true, + is_general_contact: true, + email: "blaine.blainesworth@gov.bc.ca", + phone_number: "111-222-3333", + first_name: "Blaine", + last_name: "Blainesworth", + fax_number: null, + mailing_address_line_1: null, + mailing_address_line_2: null, + deleted_ind: false, + }, + { + contact_guid: "402fd5a0-de84-4ff4-adec-d69f73f6f106", + contact_id: 18, + emli_contact_type_code: "HSI", + mine_region_code: "SC", + is_major_mine: true, + is_general_contact: false, + email: "Carla.Carlsdottir@gov.bc.ca", + phone_number: "000-111-2222", + first_name: "Carla", + last_name: "Carlsdottir", + fax_number: null, + mailing_address_line_1: null, + mailing_address_line_2: null, + deleted_ind: false, + }, +]; + export const PROJECTS = { records: [ { diff --git a/services/core-web/src/tests/components/mine/Projects/ProjectOverviewTab.spec.tsx b/services/core-web/src/tests/components/mine/Projects/ProjectOverviewTab.spec.tsx index df2b0faf95..c8274f5435 100644 --- a/services/core-web/src/tests/components/mine/Projects/ProjectOverviewTab.spec.tsx +++ b/services/core-web/src/tests/components/mine/Projects/ProjectOverviewTab.spec.tsx @@ -1,7 +1,7 @@ import React from "react"; import { render } from "@testing-library/react"; import { ProjectOverviewTab } from "@/components/mine/Projects/ProjectOverviewTab"; -import * as MOCK from "@/tests/mocks/dataMocks"; +import * as MOCK from "@mds/common/tests/mocks/dataMocks"; import { PROJECTS, STATIC_CONTENT } from "@mds/common/constants/reducerTypes"; import { BrowserRouter } from "react-router-dom"; import { ReduxWrapper } from "@/tests/utils/ReduxWrapper"; diff --git a/services/core-web/src/tests/components/mine/Projects/ProjectStagesTable.spec.tsx b/services/core-web/src/tests/components/mine/Projects/ProjectStagesTable.spec.tsx index 502622b384..6926621732 100644 --- a/services/core-web/src/tests/components/mine/Projects/ProjectStagesTable.spec.tsx +++ b/services/core-web/src/tests/components/mine/Projects/ProjectStagesTable.spec.tsx @@ -1,8 +1,6 @@ import React from "react"; import { render } from "@testing-library/react"; import { ProjectStagesTable } from "@/components/mine/Projects/ProjectStagesTable"; -import * as MOCK from "@/tests/mocks/dataMocks"; -import { ReduxWrapper } from "@/tests/utils/ReduxWrapper"; const projectStages = [ { diff --git a/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectOverviewTab.spec.tsx.snap b/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectOverviewTab.spec.tsx.snap index 8f856209cd..dc0ce50aa1 100644 --- a/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectOverviewTab.spec.tsx.snap +++ b/services/core-web/src/tests/components/mine/Projects/__snapshots__/ProjectOverviewTab.spec.tsx.snap @@ -24,7 +24,9 @@ exports[`ProjectOverviewTab renders properly 1`] = `
+ > + Sample description +
@@ -77,7 +79,7 @@ exports[`ProjectOverviewTab renders properly 1`] = ` - N/A + Nov 10 2020
- [Not submitted] + N/A
- [Not submitted] + N/A
- [Not submitted] + N/A