From 2d5a8b8a12d72afe198c456f20d3678d06accfd5 Mon Sep 17 00:00:00 2001 From: Sinn Date: Fri, 6 Sep 2024 13:20:02 -0700 Subject: [PATCH 1/7] adding warning for some areas that deal with assessed liability --- .../projectSummary/AuthorizationsInvolved.tsx | 28 ++++++++++--------- .../AuthorizationsInvolved.spec.tsx.snap | 21 ++++---------- services/common/src/constants/strings.tsx | 10 +++---- services/core-web/common/utils/Validate.ts | 5 ++++ .../components/Forms/PermitAmendmentForm.js | 2 ++ .../components/Forms/Securities/BondForm.js | 2 ++ .../permits/PermitAmendmentSecurityForm.js | 8 +++++- .../src/styles/settings/themeOverride.scss | 7 +++++ .../__snapshots__/BondForm.spec.js.snap | 5 ++++ .../PermitAmendmentForm.spec.js.snap | 5 ++++ .../PermitAmendmentSecurityForm.spec.js.snap | 5 ++++ 11 files changed, 63 insertions(+), 35 deletions(-) diff --git a/services/common/src/components/projectSummary/AuthorizationsInvolved.tsx b/services/common/src/components/projectSummary/AuthorizationsInvolved.tsx index a776783bfa..5d1a7ca743 100644 --- a/services/common/src/components/projectSummary/AuthorizationsInvolved.tsx +++ b/services/common/src/components/projectSummary/AuthorizationsInvolved.tsx @@ -51,9 +51,8 @@ import { Link } from "react-router-dom"; import { PROJECT_SUMMARY_DOCUMENT_TYPE_CODE_STATE, ENVIRONMENTAL_MANAGMENT_ACT, - MUNICIPAL_WASTEWATER_REGULATION_URL, - HAZARDOUS_WASTE_REGULATION_URL, - WASTE_DISCHARGE_AUTHORIZATIONS_URL, + WASTE_DISCHARGE_NEW_AUTHORIZATIONS_URL, + WASTE_DISCHARGE_AMENDMENT_AUTHORIZATIONS_URL, } from "../.."; import { SystemFlagEnum } from "@mds/common/constants/enums"; import { getSystemFlag } from "@mds/common/redux/selectors/authenticationSelectors"; @@ -585,17 +584,20 @@ export const AuthorizationsInvolved = () => { {authorization.description} {authorization.code === ENVIRONMENTAL_MANAGMENT_ACT && ( - For registration under the{" "} - - Municipal Wastewater Regulation - {" "} - and{" "} - - Hazardous Waste Regulation, + For registration under the Municipal Wastewater Regulation and Hazardous Waste + Regulation, please refer to the{" "} + + new authorization {" "} - please refer to the{" "} - - waste discharge authorization + or{" "} + + authorization amendment {" "} guideline. diff --git a/services/common/src/components/projectSummary/__snapshots__/AuthorizationsInvolved.spec.tsx.snap b/services/common/src/components/projectSummary/__snapshots__/AuthorizationsInvolved.spec.tsx.snap index 1f9caf1ea6..6d4fa7f171 100644 --- a/services/common/src/components/projectSummary/__snapshots__/AuthorizationsInvolved.spec.tsx.snap +++ b/services/common/src/components/projectSummary/__snapshots__/AuthorizationsInvolved.spec.tsx.snap @@ -154,31 +154,22 @@ exports[`AuthorizationsInvolved renders properly 1`] = `
- For registration under the + For registration under the Municipal Wastewater Regulation and Hazardous Waste Regulation, please refer to the - Municipal Wastewater Regulation + new authorization - and + or - Hazardous Waste Regulation, - - - please refer to the - - - waste discharge authorization + authorization amendment guideline. diff --git a/services/common/src/constants/strings.tsx b/services/common/src/constants/strings.tsx index 59dc9f4a51..1bc972eebd 100755 --- a/services/common/src/constants/strings.tsx +++ b/services/common/src/constants/strings.tsx @@ -462,9 +462,7 @@ export const DISCHARGE_FACTOR_FORM_NEW = export const DISCHARGE_FACTOR_FORM_AMENDMENT = "https://www2.gov.bc.ca/assets/gov/environment/waste-management/waste-discharge-authorization/guides/forms/epd-ema-06_amend_discharge_factor_amendment_form.pdf"; -export const MUNICIPAL_WASTEWATER_REGULATION_URL = - "https://www.bclaws.gov.bc.ca/civix/document/id/complete/statreg/87_2012"; -export const HAZARDOUS_WASTE_REGULATION_URL = - "https://www.bclaws.gov.bc.ca/civix/document/id/complete/statreg/63_88_00"; -export const WASTE_DISCHARGE_AUTHORIZATIONS_URL = - "https://www2.gov.bc.ca/gov/content/environment/waste-management/waste-discharge-authorization"; +export const WASTE_DISCHARGE_NEW_AUTHORIZATIONS_URL = + "https://www2.gov.bc.ca/gov/content/environment/waste-management/waste-discharge-authorization/apply"; +export const WASTE_DISCHARGE_AMENDMENT_AUTHORIZATIONS_URL = + "https://www2.gov.bc.ca/gov/content/environment/waste-management/waste-discharge-authorization/change"; diff --git a/services/core-web/common/utils/Validate.ts b/services/core-web/common/utils/Validate.ts index 3cfbb5a7df..6247e3c779 100644 --- a/services/core-web/common/utils/Validate.ts +++ b/services/core-web/common/utils/Validate.ts @@ -346,3 +346,8 @@ export const validateIfApplicationTypeCorrespondsToPermitNumber = ( } return undefined; }; + +export const assessedLiabilityNegativeWarning = (value) => + value && (Number.isNaN(Number(value)) || Number(value) <= 0) + ? "A negative value will decrease the current assessed liability" + : undefined; diff --git a/services/core-web/src/components/Forms/PermitAmendmentForm.js b/services/core-web/src/components/Forms/PermitAmendmentForm.js index 8c4053d944..d76c450472 100644 --- a/services/core-web/src/components/Forms/PermitAmendmentForm.js +++ b/services/core-web/src/components/Forms/PermitAmendmentForm.js @@ -13,6 +13,7 @@ import { dateNotInFuture, number, validateSelectOptions, + assessedLiabilityNegativeWarning, } from "@common/utils/Validate"; import { resetForm, currencyMask } from "@common/utils/helpers"; import { renderConfig } from "@/components/common/config"; @@ -201,6 +202,7 @@ export class PermitAmendmentForm extends Component { {...currencyMask} validate={[number]} disabled={this.props.securityNotRequired} + warn={[assessedLiabilityNegativeWarning]} /> diff --git a/services/core-web/src/components/Forms/Securities/BondForm.js b/services/core-web/src/components/Forms/Securities/BondForm.js index 43e2a3a3e4..b379b7a23e 100644 --- a/services/core-web/src/components/Forms/Securities/BondForm.js +++ b/services/core-web/src/components/Forms/Securities/BondForm.js @@ -15,6 +15,7 @@ import { dateNotBeforeOther, dateNotAfterOther, validateSelectOptions, + assessedLiabilityNegativeWarning, } from "@common/utils/Validate"; import { resetForm, upperCase, currencyMask } from "@common/utils/helpers"; import { BOND_DOCUMENTS } from "@mds/common/constants/API"; @@ -166,6 +167,7 @@ export class BondForm extends Component { {...currencyMask} validate={[required, number, currency]} disabled={this.props.editBond} + warn={[assessedLiabilityNegativeWarning]} /> diff --git a/services/core-web/src/components/Forms/permits/PermitAmendmentSecurityForm.js b/services/core-web/src/components/Forms/permits/PermitAmendmentSecurityForm.js index 50d1d47146..e187d4c2dd 100644 --- a/services/core-web/src/components/Forms/permits/PermitAmendmentSecurityForm.js +++ b/services/core-web/src/components/Forms/permits/PermitAmendmentSecurityForm.js @@ -6,7 +6,12 @@ import { Field, reduxForm, formValueSelector, change } from "redux-form"; import { Form } from "@ant-design/compatible"; import "@ant-design/compatible/assets/index.css"; import { Button, Col, Row, Popconfirm } from "antd"; -import { currency, required, validateSelectOptions } from "@common/utils/Validate"; +import { + currency, + required, + validateSelectOptions, + assessedLiabilityNegativeWarning, +} from "@common/utils/Validate"; import { currencyMask } from "@common/utils/helpers"; import * as FORM from "@/constants/forms"; import { securityNotRequiredReasonOptions } from "@/constants/NOWConditions"; @@ -84,6 +89,7 @@ export const PermitAmendmentSecurityForm = (props) => { allowClear {...currencyMask} validate={[currency]} + warn={[assessedLiabilityNegativeWarning]} /> diff --git a/services/core-web/src/styles/settings/themeOverride.scss b/services/core-web/src/styles/settings/themeOverride.scss index 2c57a57c8c..d0849600a8 100644 --- a/services/core-web/src/styles/settings/themeOverride.scss +++ b/services/core-web/src/styles/settings/themeOverride.scss @@ -725,6 +725,13 @@ select { margin-bottom: 6px; } +.ant-legacy-form-item-control.has-warning { + .ant-legacy-form-explain { + color: #694f16 !important; + } +} + + .ant-legacy-form-vertical { .ant-legacy-form-item { padding-bottom: 2px; diff --git a/services/core-web/src/tests/components/Forms/Securities/__snapshots__/BondForm.spec.js.snap b/services/core-web/src/tests/components/Forms/Securities/__snapshots__/BondForm.spec.js.snap index 54a6292a2e..aca35a00f3 100644 --- a/services/core-web/src/tests/components/Forms/Securities/__snapshots__/BondForm.spec.js.snap +++ b/services/core-web/src/tests/components/Forms/Securities/__snapshots__/BondForm.spec.js.snap @@ -35,6 +35,11 @@ exports[`BondForm renders properly 1`] = ` [Function], ] } + warn={ + Array [ + [Function], + ] + } /> diff --git a/services/core-web/src/tests/components/Forms/__snapshots__/PermitAmendmentForm.spec.js.snap b/services/core-web/src/tests/components/Forms/__snapshots__/PermitAmendmentForm.spec.js.snap index e4714bdffb..95508f33be 100644 --- a/services/core-web/src/tests/components/Forms/__snapshots__/PermitAmendmentForm.spec.js.snap +++ b/services/core-web/src/tests/components/Forms/__snapshots__/PermitAmendmentForm.spec.js.snap @@ -112,6 +112,11 @@ exports[`PermitAmendmentForm renders properly 1`] = ` [Function], ] } + warn={ + Array [ + [Function], + ] + } /> Date: Fri, 6 Sep 2024 13:27:26 -0700 Subject: [PATCH 2/7] fixing common folder error --- services/common/src/redux/utils/Validate.ts | 5 +++++ services/minespace-web/common/utils/Validate.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/services/common/src/redux/utils/Validate.ts b/services/common/src/redux/utils/Validate.ts index 5ef8c2ef82..ca23689019 100644 --- a/services/common/src/redux/utils/Validate.ts +++ b/services/common/src/redux/utils/Validate.ts @@ -421,3 +421,8 @@ export const validateIfApplicationTypeCorrespondsToPermitNumber = ( } return undefined; }; + +export const assessedLiabilityNegativeWarning = (value) => + value && (Number.isNaN(Number(value)) || Number(value) <= 0) + ? "A negative value will decrease the current assessed liability" + : undefined; diff --git a/services/minespace-web/common/utils/Validate.ts b/services/minespace-web/common/utils/Validate.ts index 3cfbb5a7df..6247e3c779 100644 --- a/services/minespace-web/common/utils/Validate.ts +++ b/services/minespace-web/common/utils/Validate.ts @@ -346,3 +346,8 @@ export const validateIfApplicationTypeCorrespondsToPermitNumber = ( } return undefined; }; + +export const assessedLiabilityNegativeWarning = (value) => + value && (Number.isNaN(Number(value)) || Number(value) <= 0) + ? "A negative value will decrease the current assessed liability" + : undefined; From 9d65817a91fb51ae87d906db7d15560a6a71e018 Mon Sep 17 00:00:00 2001 From: Sinn Date: Fri, 6 Sep 2024 14:19:33 -0700 Subject: [PATCH 3/7] fixing snap test error --- .../__snapshots__/AuthorizationsInvolved.spec.tsx.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/common/src/components/projectSummary/__snapshots__/AuthorizationsInvolved.spec.tsx.snap b/services/common/src/components/projectSummary/__snapshots__/AuthorizationsInvolved.spec.tsx.snap index 6d4fa7f171..f2afefb64e 100644 --- a/services/common/src/components/projectSummary/__snapshots__/AuthorizationsInvolved.spec.tsx.snap +++ b/services/common/src/components/projectSummary/__snapshots__/AuthorizationsInvolved.spec.tsx.snap @@ -154,7 +154,7 @@ exports[`AuthorizationsInvolved renders properly 1`] = `
- For registration under the Municipal Wastewater Regulation and Hazardous Waste Regulation, please refer to the + For registration under the Municipal Wastewater Regulation and Hazardous Waste Regulation, please refer to the Date: Fri, 6 Sep 2024 14:33:25 -0700 Subject: [PATCH 4/7] adding test --- services/core-web/src/tests/utils/Validate.spec.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/services/core-web/src/tests/utils/Validate.spec.js b/services/core-web/src/tests/utils/Validate.spec.js index 7797811935..2e7cbf6e8b 100644 --- a/services/core-web/src/tests/utils/Validate.spec.js +++ b/services/core-web/src/tests/utils/Validate.spec.js @@ -12,6 +12,7 @@ import { validateStartDate, validateDateRanges, validateIncidentDate, + assessedLiabilityNegativeWarning, } from "@common/utils/Validate"; describe("Validate class", () => { @@ -477,4 +478,17 @@ describe("Validate class", () => { expect(errors.end_date).toContain(apptType); }); }); + describe("`assessedLiabilityNegativeWarning` function", () => { + it("returns `undefined` if `value` is not negative", () => { + const value = 1000; + expect(assessedLiabilityNegativeWarning(value)).toEqual(undefined); + }); + + it("returns `A negative value will decrease the current assessed liability` if value is a negative number", () => { + const value = -1000; + expect(assessedLiabilityNegativeWarning(value)).toEqual( + `A negative value will decrease the current assessed liability` + ); + }); + }); }); From 84ff8591b6628fa2e62994c62c04eb1cf9a828ec Mon Sep 17 00:00:00 2001 From: Sinn Date: Fri, 6 Sep 2024 14:45:22 -0700 Subject: [PATCH 5/7] update test --- services/common/src/redux/utils/Validate.ts | 5 ----- services/core-web/src/tests/utils/Validate.spec.js | 6 ++++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/services/common/src/redux/utils/Validate.ts b/services/common/src/redux/utils/Validate.ts index ca23689019..5ef8c2ef82 100644 --- a/services/common/src/redux/utils/Validate.ts +++ b/services/common/src/redux/utils/Validate.ts @@ -421,8 +421,3 @@ export const validateIfApplicationTypeCorrespondsToPermitNumber = ( } return undefined; }; - -export const assessedLiabilityNegativeWarning = (value) => - value && (Number.isNaN(Number(value)) || Number(value) <= 0) - ? "A negative value will decrease the current assessed liability" - : undefined; diff --git a/services/core-web/src/tests/utils/Validate.spec.js b/services/core-web/src/tests/utils/Validate.spec.js index 2e7cbf6e8b..9297d603c4 100644 --- a/services/core-web/src/tests/utils/Validate.spec.js +++ b/services/core-web/src/tests/utils/Validate.spec.js @@ -485,10 +485,12 @@ describe("Validate class", () => { }); it("returns `A negative value will decrease the current assessed liability` if value is a negative number", () => { - const value = -1000; - expect(assessedLiabilityNegativeWarning(value)).toEqual( + const negativeValue = -1000; + const positiveValue = 1000; + expect(assessedLiabilityNegativeWarning(negativeValue)).toEqual( `A negative value will decrease the current assessed liability` ); + expect(assessedLiabilityNegativeWarning(positiveValue)).toEqual(undefined); }); }); }); From ca8618abd0f9ee604e016eb1d251787b2bd65d0b Mon Sep 17 00:00:00 2001 From: Sinn Date: Fri, 6 Sep 2024 21:49:13 -0700 Subject: [PATCH 6/7] reduce duplicate code --- services/core-web/common/utils/Validate.ts | 2 +- services/minespace-web/common/utils/Validate.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/core-web/common/utils/Validate.ts b/services/core-web/common/utils/Validate.ts index 6247e3c779..6a525fc2ec 100644 --- a/services/core-web/common/utils/Validate.ts +++ b/services/core-web/common/utils/Validate.ts @@ -348,6 +348,6 @@ export const validateIfApplicationTypeCorrespondsToPermitNumber = ( }; export const assessedLiabilityNegativeWarning = (value) => - value && (Number.isNaN(Number(value)) || Number(value) <= 0) + positiveNumber(value) ? "A negative value will decrease the current assessed liability" : undefined; diff --git a/services/minespace-web/common/utils/Validate.ts b/services/minespace-web/common/utils/Validate.ts index 6247e3c779..6a525fc2ec 100644 --- a/services/minespace-web/common/utils/Validate.ts +++ b/services/minespace-web/common/utils/Validate.ts @@ -348,6 +348,6 @@ export const validateIfApplicationTypeCorrespondsToPermitNumber = ( }; export const assessedLiabilityNegativeWarning = (value) => - value && (Number.isNaN(Number(value)) || Number(value) <= 0) + positiveNumber(value) ? "A negative value will decrease the current assessed liability" : undefined; From c4f92a7a49b3de1c93c7c4e5f62b26925c211e39 Mon Sep 17 00:00:00 2001 From: Sinn Date: Tue, 10 Sep 2024 09:55:35 -0700 Subject: [PATCH 7/7] fixing warning not showing up for NoW and Bonds --- services/core-web/src/components/Forms/Securities/BondForm.js | 2 +- .../src/components/Forms/permits/PermitAmendmentSecurityForm.js | 2 +- .../modalContent/__snapshots__/AddBondModal.spec.js.snap | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/core-web/src/components/Forms/Securities/BondForm.js b/services/core-web/src/components/Forms/Securities/BondForm.js index b379b7a23e..c0d2f8801f 100644 --- a/services/core-web/src/components/Forms/Securities/BondForm.js +++ b/services/core-web/src/components/Forms/Securities/BondForm.js @@ -446,6 +446,6 @@ BondForm.defaultProps = defaultProps; export default reduxForm({ form: FORM.ADD_BOND, - touchOnBlur: false, + touchOnBlur: true, onSubmitSuccess: resetForm(FORM.ADD_BOND), })(BondForm); diff --git a/services/core-web/src/components/Forms/permits/PermitAmendmentSecurityForm.js b/services/core-web/src/components/Forms/permits/PermitAmendmentSecurityForm.js index e187d4c2dd..379ccd3f3b 100644 --- a/services/core-web/src/components/Forms/permits/PermitAmendmentSecurityForm.js +++ b/services/core-web/src/components/Forms/permits/PermitAmendmentSecurityForm.js @@ -152,7 +152,7 @@ export default compose( connect(mapStateToProps, mapDispatchToProps), reduxForm({ form: FORM.EDIT_PERMIT, - touchOnBlur: false, + touchOnBlur: true, enableReinitialize: true, }) )(PermitAmendmentSecurityForm); diff --git a/services/core-web/src/tests/components/modalContent/__snapshots__/AddBondModal.spec.js.snap b/services/core-web/src/tests/components/modalContent/__snapshots__/AddBondModal.spec.js.snap index 441b32bf13..da580ea5cb 100644 --- a/services/core-web/src/tests/components/modalContent/__snapshots__/AddBondModal.spec.js.snap +++ b/services/core-web/src/tests/components/modalContent/__snapshots__/AddBondModal.spec.js.snap @@ -80,7 +80,7 @@ exports[`AddBondModal renders properly 1`] = ` shouldWarn={[Function]} submitAsSideEffect={false} title="Add Bond" - touchOnBlur={false} + touchOnBlur={true} touchOnChange={false} updateUnregisteredFields={false} />