From 2ed8d13ee1fa9ddcb360f280f4a0ee3a6c3a6870 Mon Sep 17 00:00:00 2001 From: Henry Oforeh Date: Fri, 13 Sep 2024 14:19:48 -0600 Subject: [PATCH] [MDS-6129] streamline status actions (#3245) * wip * implement disabled fields. * update disabled fields implementation. * update test snapshot. * update tests. * update logic. * update unit tests snapshot. * fix cypress test * add tests * update test. --- ...08.00__add_project_summary_status_code.sql | 20 + .../components/projectSummary/Agent.spec.tsx | 50 + .../src/components/projectSummary/Agent.tsx | 30 +- .../projectSummary/Applicant.spec.tsx | 42 + .../components/projectSummary/Applicant.tsx | 60 +- .../ApplicationSummary.spec.tsx | 40 + .../projectSummary/ApplicationSummary.tsx | 34 +- ...uthorizationSupportDocumentUpload.spec.tsx | 54 + .../AuthorizationSupportDocumentUpload.tsx | 223 +- .../projectSummary/AuthorizationsInvolved.tsx | 57 +- .../projectSummary/BasicInformation.tsx | 11 +- .../projectSummary/DocumentUpload.tsx | 62 +- .../projectSummary/FacilityOperator.spec.tsx | 33 + .../projectSummary/FacilityOperator.tsx | 25 +- .../LegalLandOwnerInformation.spec.tsx | 10 + .../LegalLandOwnerInformation.tsx | 19 +- .../projectSummary/PaymentContact.spec.tsx | 2 +- .../projectSummary/PaymentContact.tsx | 18 +- .../projectSummary/ProjectContacts.spec.tsx | 30 + .../projectSummary/ProjectContacts.tsx | 34 +- .../projectSummary/ProjectDates.tsx | 11 +- .../projectSummary/ProjectLinks.tsx | 20 +- .../__snapshots__/Agent.spec.tsx.snap | 158 + .../__snapshots__/Applicant.spec.tsx.snap | 2996 +++++++++++++++++ .../ApplicationSummary.spec.tsx.snap | 512 +++ ...izationSupportDocumentUpload.spec.tsx.snap | 280 ++ .../FacilityOperator.spec.tsx.snap | 1086 ++++++ .../ProjectContacts.spec.tsx.snap | 46 + services/common/src/constants/enums.ts | 1 + services/common/src/constants/utils.ts | 42 + .../resources/project_summary.py | 9 +- .../mine/Projects/ProjectSummary.tsx | 12 +- .../ProjectSummaryPage.spec.tsx.snap | 9 +- 33 files changed, 5856 insertions(+), 180 deletions(-) create mode 100644 migrations/sql/V2024.09.09.08.00__add_project_summary_status_code.sql create mode 100644 services/common/src/components/projectSummary/Agent.spec.tsx create mode 100644 services/common/src/components/projectSummary/Applicant.spec.tsx create mode 100644 services/common/src/components/projectSummary/ApplicationSummary.spec.tsx create mode 100644 services/common/src/components/projectSummary/AuthorizationSupportDocumentUpload.spec.tsx create mode 100644 services/common/src/components/projectSummary/FacilityOperator.spec.tsx create mode 100644 services/common/src/components/projectSummary/ProjectContacts.spec.tsx create mode 100644 services/common/src/components/projectSummary/__snapshots__/Agent.spec.tsx.snap create mode 100644 services/common/src/components/projectSummary/__snapshots__/Applicant.spec.tsx.snap create mode 100644 services/common/src/components/projectSummary/__snapshots__/ApplicationSummary.spec.tsx.snap create mode 100644 services/common/src/components/projectSummary/__snapshots__/AuthorizationSupportDocumentUpload.spec.tsx.snap create mode 100644 services/common/src/components/projectSummary/__snapshots__/FacilityOperator.spec.tsx.snap create mode 100644 services/common/src/components/projectSummary/__snapshots__/ProjectContacts.spec.tsx.snap diff --git a/migrations/sql/V2024.09.09.08.00__add_project_summary_status_code.sql b/migrations/sql/V2024.09.09.08.00__add_project_summary_status_code.sql new file mode 100644 index 0000000000..5dbf07a2b3 --- /dev/null +++ b/migrations/sql/V2024.09.09.08.00__add_project_summary_status_code.sql @@ -0,0 +1,20 @@ +INSERT INTO + project_summary_status_code ( + project_summary_status_code, + description, + alias_description, + display_order, + active_ind, + create_user, + update_user + ) +VALUES + ( + 'CHR', + 'Change Requested', + 'Change Requested', + 210, + true, + 'system-mds', + 'system-mds' + ); \ No newline at end of file diff --git a/services/common/src/components/projectSummary/Agent.spec.tsx b/services/common/src/components/projectSummary/Agent.spec.tsx new file mode 100644 index 0000000000..998ca116e7 --- /dev/null +++ b/services/common/src/components/projectSummary/Agent.spec.tsx @@ -0,0 +1,50 @@ +import React from "react"; +import { render } from "@testing-library/react"; +import { ReduxWrapper } from "@mds/common/tests/utils/ReduxWrapper"; +import { PROJECTS, STATIC_CONTENT, AUTHENTICATION } from "@mds/common/constants/reducerTypes"; +import { FORM } from "../.."; +import FormWrapper from "../forms/FormWrapper"; +import * as MOCK from "@mds/common/tests/mocks/dataMocks"; +import { Agent } from "./Agent"; + +const initialState = { + form: { + [FORM.ADD_EDIT_PROJECT_SUMMARY]: { + values: { + status_code: "DFT", + agent: { + credential_id: 1000, + party_type_code: null, + address: { address_type_code: "CAN", sub_division_code: "BC" }, + }, + is_agent: true, + }, + }, + }, + [PROJECTS]: { + projectSummary: MOCK.PROJECT_SUMMARY, + }, + [STATIC_CONTENT]: { + provinceOptions: MOCK.BULK_STATIC_CONTENT_RESPONSE.provinceOptions, + }, + [AUTHENTICATION]: { + systemFlag: "core", + }, +}; + +describe("Agent Component", () => { + it("should render the component with expected fields", () => { + const { container } = render( + + {}} + > + + + + ); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/services/common/src/components/projectSummary/Agent.tsx b/services/common/src/components/projectSummary/Agent.tsx index 1f77bbf6a7..2f06a752f7 100644 --- a/services/common/src/components/projectSummary/Agent.tsx +++ b/services/common/src/components/projectSummary/Agent.tsx @@ -2,7 +2,7 @@ import React, { FC, useEffect, useState } from "react"; import { useSelector, useDispatch } from "react-redux"; import { Field, change, getFormValues } from "redux-form"; import { Col, Row, Typography, Alert } from "antd"; -import { FORM } from "@mds/common/constants/forms"; +import { FORM, isFieldDisabled } from "@mds/common/constants"; import RenderField from "@mds/common/components/forms/RenderField"; import RenderRadioButtons from "@mds/common/components/forms/RenderRadioButtons"; import RenderSelect from "@mds/common/components/forms/RenderSelect"; @@ -26,6 +26,7 @@ import { getOrgBookCredential } from "@mds/common/redux/selectors/orgbookSelecto import { normalizePhone } from "@mds/common/redux/utils/helpers"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCircleCheck, faCircleX, faSpinner } from "@fortawesome/pro-light-svg-icons"; +import { getSystemFlag } from "@mds/common/redux/selectors/authenticationSelectors"; export const Agent: FC = () => { const dispatch = useDispatch(); @@ -42,6 +43,7 @@ export const Agent: FC = () => { const [verified, setVerified] = useState(false); const [checkingStatus, setCheckingStatus] = useState(false); const [verifiedCredential, setVerifiedCredential] = useState(null); + const systemFlag = useSelector(getSystemFlag); useEffect(() => { setCheckingStatus(true); @@ -178,6 +180,7 @@ export const Agent: FC = () => { validate={[requiredRadioButton]} label="Are you an agent applying on behalf of the applicant?" component={RenderRadioButtons} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> {is_agent && ( @@ -193,6 +196,7 @@ export const Agent: FC = () => { ]} optionType="button" onChange={handleResetParty} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> {party_type_code === "ORG" && (
@@ -232,6 +236,7 @@ export const Agent: FC = () => { required validate={[required]} component={RenderField} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -246,6 +251,7 @@ export const Agent: FC = () => { component={RenderField} required validate={[required, maxLength(100)]} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -255,6 +261,7 @@ export const Agent: FC = () => { component={RenderField} required validate={[required, maxLength(100)]} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -262,7 +269,12 @@ export const Agent: FC = () => { - + @@ -275,6 +287,7 @@ export const Agent: FC = () => { validate={isInternational ? [required] : [required, phoneNumber]} component={RenderField} normalize={normalizePhone} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -287,6 +300,7 @@ export const Agent: FC = () => { required validate={[required, email]} component={RenderField} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -300,10 +314,16 @@ export const Agent: FC = () => { required validate={[required]} component={RenderField} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> - + @@ -316,6 +336,7 @@ export const Agent: FC = () => { validate={[required]} data={CONTACTS_COUNTRY_OPTIONS} component={RenderSelect} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -327,6 +348,7 @@ export const Agent: FC = () => { data={provinceOptions.filter((p) => p.subType === address_type_code)} validate={!isInternational ? [required] : []} component={RenderSelect} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -339,6 +361,7 @@ export const Agent: FC = () => { required validate={[required]} component={RenderField} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -347,6 +370,7 @@ export const Agent: FC = () => { label="Postal Code" component={RenderField} validate={[postalCodeWithCountry(address_type_code), maxLength(10)]} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> diff --git a/services/common/src/components/projectSummary/Applicant.spec.tsx b/services/common/src/components/projectSummary/Applicant.spec.tsx new file mode 100644 index 0000000000..863f404cb3 --- /dev/null +++ b/services/common/src/components/projectSummary/Applicant.spec.tsx @@ -0,0 +1,42 @@ +import React from "react"; +import { render } from "@testing-library/react"; +import { ReduxWrapper } from "@mds/common/tests/utils/ReduxWrapper"; +import { PROJECTS, STATIC_CONTENT, AUTHENTICATION } from "@mds/common/constants/reducerTypes"; +import { FORM } from "../.."; +import FormWrapper from "../forms/FormWrapper"; +import * as MOCK from "@mds/common/tests/mocks/dataMocks"; +import Applicant from "./Applicant"; + +const initialState = { + form: { + [FORM.ADD_EDIT_PROJECT_SUMMARY]: { + values: {}, + }, + }, + [PROJECTS]: { + projectSummary: MOCK.PROJECT_SUMMARY, + }, + [STATIC_CONTENT]: { + provinceOptions: MOCK.BULK_STATIC_CONTENT_RESPONSE.provinceOptions, + }, + [AUTHENTICATION]: { + systemFlag: "ms", + }, +}; + +describe("Applicant Component", () => { + it("should render the component with expected fields", () => { + const { container } = render( + + {}} + > + + + + ); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/services/common/src/components/projectSummary/Applicant.tsx b/services/common/src/components/projectSummary/Applicant.tsx index b4bc6a209d..81b0e9a39a 100644 --- a/services/common/src/components/projectSummary/Applicant.tsx +++ b/services/common/src/components/projectSummary/Applicant.tsx @@ -11,7 +11,7 @@ import { requiredRadioButton, } from "@mds/common/redux/utils/Validate"; import RenderRadioButtons from "@mds/common/components/forms/RenderRadioButtons"; -import { FORM } from "@mds/common/constants/forms"; +import { FORM, isFieldDisabled } from "@mds/common/constants"; import { CONTACTS_COUNTRY_OPTIONS } from "@mds/common/constants/strings"; import { IOrgbookCredential } from "@mds/common/interfaces/party"; import RenderOrgBookSearch from "@mds/common/components/forms/RenderOrgBookSearch"; @@ -28,6 +28,7 @@ import RenderCheckbox from "@mds/common/components/forms/RenderCheckbox"; import { normalizePhone } from "@mds/common/redux/utils/helpers"; import { getOrgBookCredential } from "@mds/common/redux/selectors/orgbookSelectors"; import { PaymentContact } from "@mds/common/components/projectSummary/PaymentContact"; +import { getSystemFlag } from "@mds/common/redux/selectors/authenticationSelectors"; const { Title, Paragraph } = Typography; interface IVerifiedCredential { @@ -47,6 +48,7 @@ const Applicant = () => { const orgBookCredential = useSelector(getOrgBookCredential); const formValues = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY)); + const systemFlag = useSelector(getSystemFlag); const { applicant = {}, is_legal_address_same_as_mailing_address = false, @@ -282,6 +284,7 @@ const Applicant = () => { ]} optionType="button" onChange={handleResetParty} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> {party_type_code === "ORG" && (
@@ -295,6 +298,7 @@ const Applicant = () => { data={orgBookOptions} help={"as registered with the BC Registrar of Companies"} component={RenderOrgBookSearch} + isDisabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> {verifiedCredential && (
@@ -319,6 +323,7 @@ const Applicant = () => { name="company_alias" label="Doing Business As" component={RenderField} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -330,6 +335,7 @@ const Applicant = () => { required validate={[required]} component={RenderField} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -344,6 +350,7 @@ const Applicant = () => { required validate={[required]} component={RenderField} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -356,6 +363,7 @@ const Applicant = () => { required validate={[required]} component={RenderField} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -369,10 +377,16 @@ const Applicant = () => { component={RenderField} validate={[phoneNumber, maxLength(12), required]} normalize={normalizePhone} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> - + { required validate={[required, email]} component={RenderField} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -393,10 +408,16 @@ const Applicant = () => { required validate={[required]} component={RenderField} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> - + @@ -408,10 +429,12 @@ const Applicant = () => { validate={[required]} data={CONTACTS_COUNTRY_OPTIONS} component={RenderSelect} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> { { { }} type="checkbox" disabled={ + isFieldDisabled(systemFlag, formValues?.status_code) || !areAllAddressFieldsValid(isMailingInternational, applicantAddress.mailingAddress) } onChange={(e) => @@ -477,16 +503,23 @@ const Applicant = () => { required validate={[required]} component={RenderField} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> - + { { { { label: "Same as mailing address", }} disabled={ + isFieldDisabled(systemFlag, formValues?.status_code) || !areAllAddressFieldsValid(isMailingInternational, applicantAddress.mailingAddress) || is_billing_address_same_as_legal_address } @@ -570,6 +607,7 @@ const Applicant = () => { label: "Same as legal address", }} disabled={ + isFieldDisabled(systemFlag, formValues?.status_code) || is_billing_address_same_as_mailing_address || (!areAllAddressFieldsValid(isLegalInternational, applicantAddress.legalAddress) && !is_legal_address_same_as_mailing_address) @@ -587,6 +625,7 @@ const Applicant = () => { { /> - + { { { { )} - +
); }; diff --git a/services/common/src/components/projectSummary/ApplicationSummary.spec.tsx b/services/common/src/components/projectSummary/ApplicationSummary.spec.tsx new file mode 100644 index 0000000000..2a88ed4bc5 --- /dev/null +++ b/services/common/src/components/projectSummary/ApplicationSummary.spec.tsx @@ -0,0 +1,40 @@ +import React from "react"; +import { render } from "@testing-library/react"; +import { ReduxWrapper } from "@mds/common/tests/utils/ReduxWrapper"; +import { PERMITS, PROJECTS, STATIC_CONTENT } from "@mds/common/constants/reducerTypes"; +import { FORM } from "../.."; +import FormWrapper from "../forms/FormWrapper"; +import * as MOCK from "@mds/common/tests/mocks/dataMocks"; +import { ApplicationSummary } from "./ApplicationSummary"; + +const initialState = { + form: { + [FORM.ADD_EDIT_PROJECT_SUMMARY]: { + values: {}, + }, + }, + [PROJECTS]: { + projectSummary: MOCK.PROJECT_SUMMARY, + }, + [PERMITS]: { + permits: MOCK.PERMITS, + }, + [STATIC_CONTENT]: { + projectSummaryPermitTypes: MOCK.BULK_STATIC_CONTENT_RESPONSE.projectSummaryPermitTypes, + projectSummaryAuthorizationTypes: + MOCK.BULK_STATIC_CONTENT_RESPONSE.projectSummaryAuthorizationTypes, + }, +}; + +describe("ApplicationSummary Component", () => { + it("should render the component with expected fields", () => { + const { container } = render( + + {}}> + + + + ); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/services/common/src/components/projectSummary/ApplicationSummary.tsx b/services/common/src/components/projectSummary/ApplicationSummary.tsx index 6e40fa0d6d..bb26780aec 100644 --- a/services/common/src/components/projectSummary/ApplicationSummary.tsx +++ b/services/common/src/components/projectSummary/ApplicationSummary.tsx @@ -12,8 +12,9 @@ import { ColumnsType } from "antd/es/table"; import { Button, Alert, Typography, Col, Row } from "antd"; import { useHistory } from "react-router-dom"; import { getPermits } from "@mds/common/redux/selectors/permitSelectors"; -import { FORM } from "@mds/common/constants/forms"; +import { FORM, isFieldDisabled } from "@mds/common/constants"; import { IAuthorizationSummary } from "@mds/common/interfaces"; +import { getSystemFlag } from "@mds/common/redux/selectors/authenticationSelectors"; export const ApplicationSummary: FC = () => { const permits = useSelector(getPermits); @@ -33,6 +34,7 @@ export const ApplicationSummary: FC = () => { const processedEnvironmentActPermitResult: any[] = []; let processedOtherActPermitResult: any[] = []; + const systemFlag = useSelector(getSystemFlag); const minesActColumns: ColumnsType = [ renderTextColumn("project_type", "Type", false), @@ -245,7 +247,11 @@ export const ApplicationSummary: FC = () => { Mines Act - @@ -258,7 +264,11 @@ export const ApplicationSummary: FC = () => { Environmental Management Act - @@ -270,7 +280,11 @@ export const ApplicationSummary: FC = () => { Water Sustainability Act - @@ -282,7 +296,11 @@ export const ApplicationSummary: FC = () => { Forestry Act - @@ -294,7 +312,11 @@ export const ApplicationSummary: FC = () => { Other Legislation - diff --git a/services/common/src/components/projectSummary/AuthorizationSupportDocumentUpload.spec.tsx b/services/common/src/components/projectSummary/AuthorizationSupportDocumentUpload.spec.tsx new file mode 100644 index 0000000000..ebe3396f43 --- /dev/null +++ b/services/common/src/components/projectSummary/AuthorizationSupportDocumentUpload.spec.tsx @@ -0,0 +1,54 @@ +import React from "react"; +import { render } from "@testing-library/react"; +import { ReduxWrapper } from "@mds/common/tests/utils/ReduxWrapper"; +import { PROJECTS, STATIC_CONTENT, AUTHENTICATION } from "@mds/common/constants/reducerTypes"; +import { FORM } from "../.."; +import FormWrapper from "../forms/FormWrapper"; +import * as MOCK from "@mds/common/tests/mocks/dataMocks"; +import AuthorizationSupportDocumentUpload from "./AuthorizationSupportDocumentUpload"; + +const initialState = { + form: { + [FORM.ADD_EDIT_PROJECT_SUMMARY]: { + values: {}, + }, + }, + [PROJECTS]: { + projectSummary: MOCK.PROJECT_SUMMARY, + }, + [STATIC_CONTENT]: { + provinceOptions: MOCK.BULK_STATIC_CONTENT_RESPONSE.provinceOptions, + }, + [AUTHENTICATION]: { + systemFlag: "ms", + }, +}; + +describe("AuthorizationSupportDocumentUpload Component", () => { + it("should render the component with expected fields", () => { + const { container } = render( + + {}} + > + {}} + removeAmendmentDocument={() => {}} + projectGuid={"project_guid"} + projectSummaryGuid={"project_summary_guid"} + showExemptionSection={false} + isAmendment={false} + amendmentChanges={[]} + isDisabled={false} + /> + + + ); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/services/common/src/components/projectSummary/AuthorizationSupportDocumentUpload.tsx b/services/common/src/components/projectSummary/AuthorizationSupportDocumentUpload.tsx index 1888a0e112..2f7976dcdd 100644 --- a/services/common/src/components/projectSummary/AuthorizationSupportDocumentUpload.tsx +++ b/services/common/src/components/projectSummary/AuthorizationSupportDocumentUpload.tsx @@ -26,6 +26,7 @@ interface AuthorizationSupportDocumentUploadProps { showExemptionSection: boolean; isAmendment: boolean; amendmentChanges: string[]; + isDisabled: boolean; } export const AuthorizationSupportDocumentUpload: FC = ({ @@ -38,6 +39,7 @@ export const AuthorizationSupportDocumentUpload: FC { const handleRemoveFile = (error, fileToRemove) => { if (error) { @@ -89,37 +91,12 @@ export const AuthorizationSupportDocumentUpload: FC - - handleFileLoad( - document_name, - document_manager_guid, - PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.LOCATION_MAP - ) - } - onRemoveFile={handleRemoveFile} - /> - {(!isAmendment || - (isAmendment && - isDocumentTypeRequired(PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.DISCHARGE_FACTOR))) && ( + {!isDisabled && ( )} - {isAmendment && ( + {!isDisabled && + (!isAmendment || + (isAmendment && + isDocumentTypeRequired(PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.DISCHARGE_FACTOR))) && ( + + handleFileLoad( + document_name, + document_manager_guid, + PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.DISCHARGE_FACTOR + ) + } + onRemoveFile={handleRemoveFile} + /> + )} + {!isDisabled && isAmendment && (
{isDocumentTypeRequired(PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.CONSENT_LETTER) && ( )} - {isDocumentTypeRequired(PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.CLAUSE_AMENDMENT_FORM) && ( - - handleFileLoad( - document_name, - document_manager_guid, - PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.CLAUSE_AMENDMENT_FORM - ) - } - onRemoveFile={handleRemoveFile} - /> - )} - {isDocumentTypeRequired( - PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.CHANGE_OF_OWNERSHIP_NAME_OR_ADDRESS_FORM - ) && ( - - handleFileLoad( - document_name, - document_manager_guid, - PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.CHANGE_OF_OWNERSHIP_NAME_OR_ADDRESS_FORM - ) - } - onRemoveFile={handleRemoveFile} - /> - )} + {!isDisabled && + isDocumentTypeRequired(PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.CLAUSE_AMENDMENT_FORM) && ( + + handleFileLoad( + document_name, + document_manager_guid, + PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.CLAUSE_AMENDMENT_FORM + ) + } + onRemoveFile={handleRemoveFile} + /> + )} + {!isDisabled && + isDocumentTypeRequired( + PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.CHANGE_OF_OWNERSHIP_NAME_OR_ADDRESS_FORM + ) && ( + + handleFileLoad( + document_name, + document_manager_guid, + PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.CHANGE_OF_OWNERSHIP_NAME_OR_ADDRESS_FORM + ) + } + onRemoveFile={handleRemoveFile} + /> + )}
)} - {showExemptionSection && ( + {!isDisabled && showExemptionSection && ( )} - - handleFileLoad( - document_name, - document_manager_guid, - PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.SUPPORTING - ) - } - onRemoveFile={handleRemoveFile} - /> + {!isDisabled && ( + + handleFileLoad( + document_name, + document_manager_guid, + PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.SUPPORTING + ) + } + onRemoveFile={handleRemoveFile} + /> + )}
); }; diff --git a/services/common/src/components/projectSummary/AuthorizationsInvolved.tsx b/services/common/src/components/projectSummary/AuthorizationsInvolved.tsx index 5d1a7ca743..67278146e3 100644 --- a/services/common/src/components/projectSummary/AuthorizationsInvolved.tsx +++ b/services/common/src/components/projectSummary/AuthorizationsInvolved.tsx @@ -53,11 +53,12 @@ import { ENVIRONMENTAL_MANAGMENT_ACT, WASTE_DISCHARGE_NEW_AUTHORIZATIONS_URL, WASTE_DISCHARGE_AMENDMENT_AUTHORIZATIONS_URL, + isFieldDisabled, } from "../.."; import { SystemFlagEnum } from "@mds/common/constants/enums"; import { getSystemFlag } from "@mds/common/redux/selectors/authenticationSelectors"; -const RenderEMAPermitCommonSections = ({ code, isAmendment, index }) => { +const RenderEMAPermitCommonSections = ({ code, isAmendment, index, isDisabled }) => { const dispatch = useDispatch(); const purposeLabel = isAmendment ? "Additional Amendment Request Information" @@ -152,6 +153,7 @@ const RenderEMAPermitCommonSections = ({ code, isAmendment, index }) => { return ( <> { placeholder="e.g. To Discharge air emissions from x number of stacks at a sawmill." /> { {showExemptionSection && (
{ showExemptionSection={showExemptionSection} isAmendment={isAmendment} amendmentChanges={sectionValues?.amendment_changes} + isDisabled={isDisabled} /> { ); }; -const RenderEMANewPermitSection = ({ code }) => { +const RenderEMANewPermitSection = ({ code, isDisabled }) => { return (
{ validate={[requiredRadioButton]} /> - +
); }; -const RenderEMAAmendFieldArray = ({ fields, code }) => { +const RenderEMAAmendFieldArray = ({ fields, code, isDisabled }) => { const handleRemoveAmendment = (index: number) => { fields.remove(index); }; @@ -317,6 +329,7 @@ const RenderEMAAmendFieldArray = ({ fields, code }) => { validate={[required, minLength(2), maxLength(6), digitCharactersOnly]} help="Number only (e.g. PC12345 should be entered as 12345)" component={RenderField} + isDisabled={isDisabled} /> { { label: "Significant", value: "SIG" }, { label: "Minor", value: "MIN" }, ]} + isDisabled={isDisabled} /> { { label: "Regulatory Change", value: "RCH" }, { label: "Other", value: "OTH" }, ]} + isDisabled={isDisabled} /> { required validate={[requiredRadioButton]} component={RenderRadioButtons} + isDisabled={isDisabled} + /> + - ))} @@ -363,7 +384,7 @@ const RenderEMAAmendFieldArray = ({ fields, code }) => { ); }; -const RenderEMAAuthCodeFormSection = ({ code }) => { +const RenderEMAAuthCodeFormSection = ({ code, isDisabled }) => { const { authorizations } = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY)); const codeAuthorizations = authorizations[code] ?? []; const hasAmendments = codeAuthorizations.AMENDMENT?.length > 0; @@ -388,6 +409,7 @@ const RenderEMAAuthCodeFormSection = ({ code }) => { return (
{
); }; -const RenderMinesActPermitSelect = () => { +const RenderMinesActPermitSelect = ({ isDisabled }) => { const dispatch = useDispatch(); const formValues = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY)); const { mine_guid } = formValues; @@ -464,6 +487,7 @@ const RenderMinesActPermitSelect = () => { return ( { ); }; -const RenderAuthCodeFormSection = ({ authorizationType, code }) => { +const RenderAuthCodeFormSection = ({ authorizationType, code, isDisabled }) => { const dropdownProjectSummaryPermitTypes = useSelector(getDropdownProjectSummaryPermitTypes); if (authorizationType === "ENVIRONMENTAL_MANAGMENT_ACT") { // AMS authorizations, have options of amend/new with more details - return ; + return ; } if (authorizationType === "OTHER_LEGISLATION") { return ( { { normalize={normalizeGroupCheckBox} /> {isMinesAct ? ( - + ) : ( val.split(",").map((v) => v.trim())} component={RenderField} @@ -610,6 +637,7 @@ export const AuthorizationsInvolved = () => { { /> )} diff --git a/services/common/src/components/projectSummary/BasicInformation.tsx b/services/common/src/components/projectSummary/BasicInformation.tsx index e99b2d8d4a..c4738ec601 100644 --- a/services/common/src/components/projectSummary/BasicInformation.tsx +++ b/services/common/src/components/projectSummary/BasicInformation.tsx @@ -1,11 +1,17 @@ import React from "react"; import { Typography } from "antd"; -import { Field } from "redux-form"; +import { Field, getFormValues } from "redux-form"; import { maxLength, required } from "@mds/common/redux/utils/Validate"; import RenderField from "@mds/common/components/forms/RenderField"; import RenderAutoSizeField from "@mds/common/components/forms/RenderAutoSizeField"; +import { useSelector } from "react-redux"; +import { FORM, isFieldDisabled } from "@mds/common/constants"; +import { getSystemFlag } from "@mds/common/redux/selectors/authenticationSelectors"; export const BasicInformation = () => { + const formValues = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY)); + const systemFlag = useSelector(getSystemFlag); + return ( <> Basic Information @@ -16,6 +22,7 @@ export const BasicInformation = () => { required component={RenderField} validate={[maxLength(300), required]} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> { labelSubtitle="If your company uses a tracking number to identify projects, please provide it here." component={RenderField} validate={[maxLength(20)]} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> { minRows={10} maximumCharacters={4000} validate={[maxLength(4000), required]} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> ); diff --git a/services/common/src/components/projectSummary/DocumentUpload.tsx b/services/common/src/components/projectSummary/DocumentUpload.tsx index 4842e5a3bd..98c9b08244 100644 --- a/services/common/src/components/projectSummary/DocumentUpload.tsx +++ b/services/common/src/components/projectSummary/DocumentUpload.tsx @@ -10,7 +10,12 @@ import { uploadedByColumn, } from "../documents/DocumentColumns"; import ProjectSummaryFileUpload from "./ProjectSummaryFileUpload"; -import { ENVIRONMENT, FORM, PROJECT_SUMMARY_DOCUMENT_TYPE_CODE } from "@mds/common/constants"; +import { + ENVIRONMENT, + FORM, + isDocumentFieldDisabled, + PROJECT_SUMMARY_DOCUMENT_TYPE_CODE, +} from "@mds/common/constants"; import { postNewDocumentVersion } from "@mds/common/redux/actionCreators/documentActionCreator"; import LinkButton from "../common/LinkButton"; import * as API from "@mds/common/constants/API"; @@ -20,6 +25,7 @@ import SpatialDocumentTable from "../documents/spatial/SpatialDocumentTable"; import { FormContext } from "../forms/FormWrapper"; import { useFeatureFlag } from "@mds/common/providers/featureFlags/useFeatureFlag"; import { Feature } from "../.."; +import { getSystemFlag } from "@mds/common/redux/selectors/authenticationSelectors"; const RenderOldDocuments = ({ documents, @@ -63,6 +69,7 @@ const RenderOldDocuments = ({ export const DocumentUpload: FC = () => { const dispatch = useDispatch(); + const systemFlag = useSelector(getSystemFlag); const { spatial_documents = [], support_documents = [], @@ -70,6 +77,7 @@ export const DocumentUpload: FC = () => { project_guid, project_summary_guid, documents, + status_code, } = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY)); const { isEditMode } = useContext(FormContext); @@ -207,7 +215,12 @@ export const DocumentUpload: FC = () => { {spatialFeatureEnabled ? ( <> {isEditMode && ( - )} @@ -227,6 +240,7 @@ export const DocumentUpload: FC = () => { Upload any supporting document and draft of{" "} downloadIRTTemplate( ENVIRONMENT.apiUrl + API.INFORMATION_REQUIREMENTS_TABLE_TEMPLATE_DOWNLOAD @@ -238,27 +252,29 @@ export const DocumentUpload: FC = () => { following the official template here. It is required to upload your final IRT in the form provided to proceed to the final application. - - onFileLoad( - document_name, - PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.SUPPORTING, - document_manager_guid, - version - ) - } - onRemoveFile={onRemoveFile} - params={fileUploadParams} - acceptedFileTypesMap={supportingAcceptedFileTypesMap} - listedFileTypes={["document", "image", "spreadsheet"]} - component={ProjectSummaryFileUpload} - props={{ - documents: documents, - label: "Upload Files", - }} - /> + {!isDocumentFieldDisabled(systemFlag, status_code) && ( + + onFileLoad( + document_name, + PROJECT_SUMMARY_DOCUMENT_TYPE_CODE.SUPPORTING, + document_manager_guid, + version + ) + } + onRemoveFile={onRemoveFile} + params={fileUploadParams} + acceptedFileTypesMap={supportingAcceptedFileTypesMap} + listedFileTypes={["document", "image", "spreadsheet"]} + component={ProjectSummaryFileUpload} + props={{ + documents: documents, + label: "Upload Files", + }} + /> + )} { + it("should render the component with expected fields", () => { + const { container } = render( + + {}}> + + + + ); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/services/common/src/components/projectSummary/FacilityOperator.tsx b/services/common/src/components/projectSummary/FacilityOperator.tsx index fe3e014e3e..60e178ee48 100644 --- a/services/common/src/components/projectSummary/FacilityOperator.tsx +++ b/services/common/src/components/projectSummary/FacilityOperator.tsx @@ -12,15 +12,17 @@ import { } from "@mds/common/redux/utils/Validate"; import RenderField from "../forms/RenderField"; import RenderSelect from "../forms/RenderSelect"; -import { FORM } from "../.."; +import { FORM, isFieldDisabled } from "../.."; import { getDropdownProvinceOptions } from "@mds/common/redux/selectors/staticContentSelectors"; import RenderRadioButtons from "../forms/RenderRadioButtons"; import RenderAutoSizeField from "../forms/RenderAutoSizeField"; import { normalizePhone } from "@mds/common/redux/utils/helpers"; import { getRegionOptions } from "@mds/common/redux/slices/regionsSlice"; +import { getSystemFlag } from "@mds/common/redux/selectors/authenticationSelectors"; export const FacilityOperator: FC = () => { const formValues = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY)); + const systemFlag = useSelector(getSystemFlag); const { zoning } = formValues; @@ -42,6 +44,7 @@ export const FacilityOperator: FC = () => { label="Facility Type" labelSubtitle="List the proposed facility type and/or mining activity." component={RenderField} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> { maximumCharacters={4000} rows={3} component={RenderAutoSizeField} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -62,6 +66,7 @@ export const FacilityOperator: FC = () => { label="Facility's Regional Location" component={RenderSelect} data={regionOptions} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -75,13 +80,20 @@ export const FacilityOperator: FC = () => { validate={[required, maxLength(400)]} component={RenderField} help="If no civic address, describe location (e.g. 3km north of Sechelt, BC, on Highway 101)" + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> - + { component={RenderField} /> { component={RenderSelect} /> { /> { /> {zoning === false && ( { { { { { { }, }, STATIC_CONTENT, + [AUTHENTICATION]: { + systemFlag: "core", + }, }); const { container, getByText } = render( {WrappedLegalLandOwnerInformation} @@ -49,6 +53,9 @@ describe("LegalLandOwnerInformation Component", () => { }, }, STATIC_CONTENT, + [AUTHENTICATION]: { + systemFlag: "core", + }, }); const { getByText } = render( {WrappedLegalLandOwnerInformation} @@ -75,6 +82,9 @@ describe("LegalLandOwnerInformation Component", () => { }, }, STATIC_CONTENT, + [AUTHENTICATION]: { + systemFlag: "core", + }, }); const { getByText } = render( {WrappedLegalLandOwnerInformation} diff --git a/services/common/src/components/projectSummary/LegalLandOwnerInformation.tsx b/services/common/src/components/projectSummary/LegalLandOwnerInformation.tsx index 0c71b89981..0f35f21d10 100644 --- a/services/common/src/components/projectSummary/LegalLandOwnerInformation.tsx +++ b/services/common/src/components/projectSummary/LegalLandOwnerInformation.tsx @@ -14,13 +14,14 @@ import { min, } from "@mds/common/redux/utils/Validate"; import { useSelector } from "react-redux"; -import { FORM } from "@mds/common/constants"; +import { FORM, isFieldDisabled } from "@mds/common/constants"; import RenderField from "../forms/RenderField"; import { getDropdownMunicipalities } from "@mds/common/redux/selectors/staticContentSelectors"; import RenderSelect from "@mds/common/components/forms/RenderSelect"; import { normalizePhone } from "@mds/common/redux/utils/helpers"; import CoreMap from "../common/Map"; import RenderAutoSizeField from "../forms/RenderAutoSizeField"; +import { getSystemFlag } from "@mds/common/redux/selectors/authenticationSelectors"; export const LegalLandOwnerInformation: FC = () => { const formValues = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY)); @@ -37,6 +38,7 @@ export const LegalLandOwnerInformation: FC = () => { const [pin, setPin] = useState>([]); const municipalityOptions = useSelector(getDropdownMunicipalities); + const systemFlag = useSelector(getSystemFlag); const dataSourceOptions = [ { value: "GPS", label: "GPS" }, @@ -65,6 +67,7 @@ export const LegalLandOwnerInformation: FC = () => { validate={[requiredRadioButton]} label="Is the Applicant the Legal Land Owner?" component={RenderRadioButtons} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> {!is_legal_land_owner && ( <> @@ -77,6 +80,7 @@ export const LegalLandOwnerInformation: FC = () => { validate={!is_legal_land_owner ? [requiredRadioButton] : []} label="Is this federal or provincial Crown land?" component={RenderRadioButtons} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -87,6 +91,7 @@ export const LegalLandOwnerInformation: FC = () => { validate={!is_legal_land_owner ? [requiredRadioButton] : []} label="Is the Legal Land Owner aware of the proposed application to discharge waste?" component={RenderRadioButtons} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -101,6 +106,7 @@ export const LegalLandOwnerInformation: FC = () => { required={!is_legal_land_owner} validate={!is_legal_land_owner ? [required] : []} help="If it is provincial or federal, write in that" + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -112,6 +118,7 @@ export const LegalLandOwnerInformation: FC = () => { validate={!is_legal_land_owner ? [requiredRadioButton] : []} label="Has the Legal Land Owner received a copy of this application?" component={RenderRadioButtons} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -125,6 +132,7 @@ export const LegalLandOwnerInformation: FC = () => { required={!is_legal_land_owner} validate={!is_legal_land_owner ? [phoneNumber, maxLength(12), required] : []} normalize={normalizePhone} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -135,6 +143,7 @@ export const LegalLandOwnerInformation: FC = () => { component={RenderField} required={!is_legal_land_owner} validate={!is_legal_land_owner ? [required, email] : []} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -150,6 +159,7 @@ export const LegalLandOwnerInformation: FC = () => { label="Latitude" component={RenderField} help="Must be between 47 and 60 with no more than 7 decimal places" + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> { label="Longitude" component={RenderField} help="Must be between -113 and -140 with no more than 7 decimal places" + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> { label="Source of Data" data={dataSourceOptions} component={RenderSelect} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -181,6 +193,7 @@ export const LegalLandOwnerInformation: FC = () => { maximumCharacters={4000} rows={3} component={RenderAutoSizeField} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> )} @@ -193,6 +206,7 @@ export const LegalLandOwnerInformation: FC = () => { component={RenderSelect} data={municipalityOptions} validate={[required]} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> @@ -203,6 +217,7 @@ export const LegalLandOwnerInformation: FC = () => { validate={!legal_land_desc ? [required, maxLength(100)] : [maxLength(100)]} maximumCharacters={100} required={!legal_land_desc} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> { rows={3} component={RenderAutoSizeField} required={!facility_pid_pin_crown_file_no} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> { required component={RenderField} validate={[required, maxLength(100)]} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} />
); diff --git a/services/common/src/components/projectSummary/PaymentContact.spec.tsx b/services/common/src/components/projectSummary/PaymentContact.spec.tsx index 334e15c34d..78df476bcb 100644 --- a/services/common/src/components/projectSummary/PaymentContact.spec.tsx +++ b/services/common/src/components/projectSummary/PaymentContact.spec.tsx @@ -39,7 +39,7 @@ describe("PaymentContact Component", () => { initialValues={MOCK.PERMITS} onSubmit={() => {}} > - + ); diff --git a/services/common/src/components/projectSummary/PaymentContact.tsx b/services/common/src/components/projectSummary/PaymentContact.tsx index e68b737274..613e3feb1f 100644 --- a/services/common/src/components/projectSummary/PaymentContact.tsx +++ b/services/common/src/components/projectSummary/PaymentContact.tsx @@ -19,7 +19,7 @@ import { FORM, CONTACTS_COUNTRY_OPTIONS } from "../.."; const { Title, Paragraph } = Typography; -export const PaymentContact: FC = () => { +export const PaymentContact = ({ isDisabled }) => { const dispatch = useDispatch(); const formValues = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY)); const { payment_contact = {} } = formValues; @@ -53,6 +53,7 @@ export const PaymentContact: FC = () => { { { { { { { { { - + { + it("should render the component with expected fields", () => { + const { container } = render( + + {}}> + + + + ); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/services/common/src/components/projectSummary/ProjectContacts.tsx b/services/common/src/components/projectSummary/ProjectContacts.tsx index 2e7b3431d7..17f2139356 100644 --- a/services/common/src/components/projectSummary/ProjectContacts.tsx +++ b/services/common/src/components/projectSummary/ProjectContacts.tsx @@ -14,13 +14,14 @@ import { } from "@mds/common/redux/utils/Validate"; import { normalizePhone } from "@mds/common/redux/utils/helpers"; import LinkButton from "@mds/common/components/common/LinkButton"; -import { FORM } from "@mds/common/constants/forms"; +import { FORM, isFieldDisabled } from "@mds/common/constants"; import RenderField from "@mds/common/components/forms/RenderField"; import RenderSelect from "@mds/common/components/forms/RenderSelect"; import { CONTACTS_COUNTRY_OPTIONS } from "@mds/common/constants"; import { getDropdownProvinceOptions } from "@mds/common/redux/selectors/staticContentSelectors"; +import { getSystemFlag } from "@mds/common/redux/selectors/authenticationSelectors"; -const RenderContacts = ({ fields }) => { +const RenderContacts = ({ fields, isDisabled }) => { const dispatch = useDispatch(); const provinceOptions = useSelector(getDropdownProvinceOptions); const handleClearProvince = (currentCountry, addressTypeCode, subDivisionCode, field) => { @@ -71,7 +72,7 @@ const RenderContacts = ({ fields }) => { okText="Remove" cancelText="Cancel" > - @@ -82,6 +83,7 @@ const RenderContacts = ({ fields }) => { { { { { { { { { /> - + { { { { ); })} fields.push({ is_primary: false })} title="Add additional project contacts" > @@ -243,6 +262,7 @@ export const ProjectContacts: FC = () => { const dispatch = useDispatch(); const formValues = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY)); const { contacts } = formValues; + const systemFlag = useSelector(getSystemFlag); useEffect(() => { if (isNil(contacts) || contacts.length === 0) { @@ -253,7 +273,11 @@ export const ProjectContacts: FC = () => { return ( <> Project Contacts - + ); }; diff --git a/services/common/src/components/projectSummary/ProjectDates.tsx b/services/common/src/components/projectSummary/ProjectDates.tsx index 55326e89e6..6966c3e64f 100644 --- a/services/common/src/components/projectSummary/ProjectDates.tsx +++ b/services/common/src/components/projectSummary/ProjectDates.tsx @@ -4,15 +4,18 @@ import { Field, getFormValues } from "redux-form"; import { Typography } from "antd"; import { dateNotBeforeOther, dateNotAfterOther } from "@mds/common/redux/utils/Validate"; import Callout from "@mds/common/components/common/Callout"; -import { FORM } from "@mds/common/constants/forms"; +import { FORM, isFieldDisabled } from "@mds/common/constants"; import RenderDate from "@mds/common/components/forms/RenderDate"; +import { getSystemFlag } from "@mds/common/redux/selectors/authenticationSelectors"; export const ProjectDates = () => { + const formValues = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY)); const { expected_permit_application_date, expected_draft_irt_submission_date, expected_permit_receipt_date, - } = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY)); + } = formValues; + const systemFlag = useSelector(getSystemFlag); return ( <> @@ -41,6 +44,7 @@ export const ProjectDates = () => { placeholder="Please select date" component={RenderDate} validate={[dateNotAfterOther(expected_permit_application_date)]} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> { placeholder="Please select date" component={RenderDate} validate={[dateNotBeforeOther(expected_draft_irt_submission_date)]} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> { placeholder="Please select date" component={RenderDate} validate={[dateNotBeforeOther(expected_permit_application_date)]} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> { placeholder="Please select date" component={RenderDate} validate={[dateNotBeforeOther(expected_permit_receipt_date)]} + disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> ); diff --git a/services/common/src/components/projectSummary/ProjectLinks.tsx b/services/common/src/components/projectSummary/ProjectLinks.tsx index 6108ed9b86..c08537eeef 100644 --- a/services/common/src/components/projectSummary/ProjectLinks.tsx +++ b/services/common/src/components/projectSummary/ProjectLinks.tsx @@ -1,12 +1,17 @@ import React, { FC, useEffect, useState } from "react"; import { getProject, getProjects } from "@mds/common/redux/selectors/projectSelectors"; import { useSelector, useDispatch } from "react-redux"; -import { Field, change } from "redux-form"; +import { Field, change, getFormValues } from "redux-form"; import ProjectLinksTable from "@mds/common/components/projectSummary/ProjectLinksTable"; import { ILinkedProject, IProject } from "@mds/common/interfaces"; import { Button, Col, Row, Typography } from "antd"; -import { FORM, USER_ROLES, getProjectStatusDescription } from "@mds/common/constants"; +import { + FORM, + USER_ROLES, + getProjectStatusDescription, + isFieldDisabled, +} from "@mds/common/constants"; import { isProponent, userHasRole } from "@mds/common/redux/reducers/authenticationReducer"; import { createProjectLinks, @@ -15,6 +20,7 @@ import { import { dateSorter } from "@mds/common/redux/utils/helpers"; import RenderMultiSelect from "../forms/RenderMultiSelect"; import * as Strings from "@mds/common/constants/strings"; +import { getSystemFlag } from "@mds/common/redux/selectors/authenticationSelectors"; interface ProjectLinksProps { viewProject: (record: ILinkedProject) => string; @@ -26,6 +32,8 @@ const ProjectLinkInput = ({ unrelatedProjects = [], mineGuid, projectGuid }) => const [currentSelection, setCurrentSelection] = useState([]); const formName = FORM.ADD_EDIT_PROJECT_SUMMARY; const fieldName = "linked-projects"; + const formValues = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY)); + const systemFlag = useSelector(getSystemFlag); if (!projectGuid) { return ( @@ -58,6 +66,7 @@ const ProjectLinkInput = ({ unrelatedProjects = [], mineGuid, projectGuid }) => component={RenderMultiSelect} onChange={(...args) => handleChange(args)} /> - diff --git a/services/common/src/components/projectSummary/__snapshots__/Agent.spec.tsx.snap b/services/common/src/components/projectSummary/__snapshots__/Agent.spec.tsx.snap new file mode 100644 index 0000000000..153d6df069 --- /dev/null +++ b/services/common/src/components/projectSummary/__snapshots__/Agent.spec.tsx.snap @@ -0,0 +1,158 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Agent Component should render the component with expected fields 1`] = ` +
+
+
+

+ Representing Agent +

+
+ The applicant may authorize a representing agent to deal with the Ministry directly on future aspects of this application. This section must be completed in full if a representing agent is a person who is not an employee of the applicant. +
+
+ +
+
+
+
+ +
+
+
+
+
+ + +
+
+
+
+ +
+
+
+
+ +
+`; diff --git a/services/common/src/components/projectSummary/__snapshots__/Applicant.spec.tsx.snap b/services/common/src/components/projectSummary/__snapshots__/Applicant.spec.tsx.snap new file mode 100644 index 0000000000..780b3bf350 --- /dev/null +++ b/services/common/src/components/projectSummary/__snapshots__/Applicant.spec.tsx.snap @@ -0,0 +1,2996 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Applicant Component should render the component with expected fields 1`] = ` +
+
+
+

+ Applicant Information +

+
+ This must be the name of the company or person seeking authorization. +
+
+
+
+ +
+
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+ +
+ as registered with the BC Registrar of Companies +
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+ Mailing Address +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+ Legal Address +
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+ Billing Address +
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+

+ Contact for Payment +

+
+ Provide contact information for the responsible person for application payments. +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+ Mailing Address +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+ +
+`; diff --git a/services/common/src/components/projectSummary/__snapshots__/ApplicationSummary.spec.tsx.snap b/services/common/src/components/projectSummary/__snapshots__/ApplicationSummary.spec.tsx.snap new file mode 100644 index 0000000000..1228eb6148 --- /dev/null +++ b/services/common/src/components/projectSummary/__snapshots__/ApplicationSummary.spec.tsx.snap @@ -0,0 +1,512 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ApplicationSummary Component should render the component with expected fields 1`] = ` +
+
+
+

+ Application Summary +

+
+ Let's review what you're submitting. These files are not reviewed as part of the submission. +
+ +
+

+ Major Mines Office +

+
+
+
+ Mines Act +
+
+
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + +
+ Type + + Permit +
+ No Data Yet +
+
+
+
+
+
+
+
+

+ Ministry of Environment +

+
+
+
+ Environmental Management Act +
+
+
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + +
+ Type + + Authorization +
+ No Data Yet +
+
+
+
+
+
+
+
+
+
+
+ Water Sustainability Act +
+
+
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + +
+ Type + + Authorization +
+ No Data Yet +
+
+
+
+
+
+
+
+
+
+
+ Forestry Act +
+
+
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + +
+ Type + + Authorization +
+ No Data Yet +
+
+
+
+
+
+
+
+
+
+
+ Other Legislation +
+
+
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + +
+ Type + + Authorization +
+ No Data Yet +
+
+
+
+
+
+
+
+
+
+`; diff --git a/services/common/src/components/projectSummary/__snapshots__/AuthorizationSupportDocumentUpload.spec.tsx.snap b/services/common/src/components/projectSummary/__snapshots__/AuthorizationSupportDocumentUpload.spec.tsx.snap new file mode 100644 index 0000000000..e8044d8f22 --- /dev/null +++ b/services/common/src/components/projectSummary/__snapshots__/AuthorizationSupportDocumentUpload.spec.tsx.snap @@ -0,0 +1,280 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AuthorizationSupportDocumentUpload Component should render the component with expected fields 1`] = ` +
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ +
+`; diff --git a/services/common/src/components/projectSummary/__snapshots__/FacilityOperator.spec.tsx.snap b/services/common/src/components/projectSummary/__snapshots__/FacilityOperator.spec.tsx.snap new file mode 100644 index 0000000000..5dd5a4fea6 --- /dev/null +++ b/services/common/src/components/projectSummary/__snapshots__/FacilityOperator.spec.tsx.snap @@ -0,0 +1,1086 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`FacilityOperator Component should render the component with expected fields 1`] = ` +
+
+

+ Mine Components and Offsite Infrastructure +

+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+