Skip to content

Commit

Permalink
[MDS-6121] Adding warning for areas that deal with assessed liability (
Browse files Browse the repository at this point in the history
…#3238)

* adding warning for some areas that deal with assessed liability

* fixing common folder error

* fixing snap test error

* adding test

* update test

* reduce duplicate code
  • Loading branch information
asinn134 authored Sep 9, 2024
1 parent 6a1357c commit 5d16223
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -585,17 +584,20 @@ export const AuthorizationsInvolved = () => {
<Typography.Title level={5}>{authorization.description}</Typography.Title>
{authorization.code === ENVIRONMENTAL_MANAGMENT_ACT && (
<Typography.Paragraph>
For registration under the{" "}
<Link to={{ pathname: MUNICIPAL_WASTEWATER_REGULATION_URL }} target="_blank">
Municipal Wastewater Regulation
</Link>{" "}
and{" "}
<Link to={{ pathname: HAZARDOUS_WASTE_REGULATION_URL }} target="_blank">
Hazardous Waste Regulation,
For registration under the Municipal Wastewater Regulation and Hazardous Waste
Regulation, please refer to the{" "}
<Link
to={{ pathname: WASTE_DISCHARGE_NEW_AUTHORIZATIONS_URL }}
target="_blank"
>
new authorization
</Link>{" "}
please refer to the{" "}
<Link to={{ pathname: WASTE_DISCHARGE_AUTHORIZATIONS_URL }} target="_blank">
waste discharge authorization
or{" "}
<Link
to={{ pathname: WASTE_DISCHARGE_AMENDMENT_AUTHORIZATIONS_URL }}
target="_blank"
>
authorization amendment
</Link>{" "}
guideline.
</Typography.Paragraph>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,31 +154,22 @@ exports[`AuthorizationsInvolved renders properly 1`] = `
<div
class="ant-typography"
>
For registration under the
For registration under the Municipal Wastewater Regulation and Hazardous Waste Regulation, please refer to the
<a
href="https://www.bclaws.gov.bc.ca/civix/document/id/complete/statreg/87_2012"
href="https://www2.gov.bc.ca/gov/content/environment/waste-management/waste-discharge-authorization/apply"
target="_blank"
>
Municipal Wastewater Regulation
new authorization
</a>
and
or
<a
href="https://www.bclaws.gov.bc.ca/civix/document/id/complete/statreg/63_88_00"
href="https://www2.gov.bc.ca/gov/content/environment/waste-management/waste-discharge-authorization/change"
target="_blank"
>
Hazardous Waste Regulation,
</a>
please refer to the
<a
href="https://www2.gov.bc.ca/gov/content/environment/waste-management/waste-discharge-authorization"
target="_blank"
>
waste discharge authorization
authorization amendment
</a>
guideline.
Expand Down
10 changes: 4 additions & 6 deletions services/common/src/constants/strings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
5 changes: 5 additions & 0 deletions services/core-web/common/utils/Validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,8 @@ export const validateIfApplicationTypeCorrespondsToPermitNumber = (
}
return undefined;
};

export const assessedLiabilityNegativeWarning = (value) =>
positiveNumber(value)
? "A negative value will decrease the current assessed liability"
: undefined;
2 changes: 2 additions & 0 deletions services/core-web/src/components/Forms/PermitAmendmentForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -201,6 +202,7 @@ export class PermitAmendmentForm extends Component {
{...currencyMask}
validate={[number]}
disabled={this.props.securityNotRequired}
warn={[assessedLiabilityNegativeWarning]}
/>
</Form.Item>
<Form.Item>
Expand Down
2 changes: 2 additions & 0 deletions services/core-web/src/components/Forms/Securities/BondForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -166,6 +167,7 @@ export class BondForm extends Component {
{...currencyMask}
validate={[required, number, currency]}
disabled={this.props.editBond}
warn={[assessedLiabilityNegativeWarning]}
/>
</Form.Item>
</Col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -84,6 +89,7 @@ export const PermitAmendmentSecurityForm = (props) => {
allowClear
{...currencyMask}
validate={[currency]}
warn={[assessedLiabilityNegativeWarning]}
/>
</Col>
<Col md={12} sm={24}>
Expand Down
7 changes: 7 additions & 0 deletions services/core-web/src/styles/settings/themeOverride.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ exports[`BondForm renders properly 1`] = `
[Function],
]
}
warn={
Array [
[Function],
]
}
/>
</FormItem>
</Col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ exports[`PermitAmendmentForm renders properly 1`] = `
[Function],
]
}
warn={
Array [
[Function],
]
}
/>
</FormItem>
<FormItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ exports[`PermitAmendmentSecurityForm renders properly 1`] = `
[Function],
]
}
warn={
Array [
[Function],
]
}
/>
</Col>
<Col
Expand Down
16 changes: 16 additions & 0 deletions services/core-web/src/tests/utils/Validate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
validateStartDate,
validateDateRanges,
validateIncidentDate,
assessedLiabilityNegativeWarning,
} from "@common/utils/Validate";

describe("Validate class", () => {
Expand Down Expand Up @@ -477,4 +478,19 @@ 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 negativeValue = -1000;
const positiveValue = 1000;
expect(assessedLiabilityNegativeWarning(negativeValue)).toEqual(
`A negative value will decrease the current assessed liability`
);
expect(assessedLiabilityNegativeWarning(positiveValue)).toEqual(undefined);
});
});
});
5 changes: 5 additions & 0 deletions services/minespace-web/common/utils/Validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,8 @@ export const validateIfApplicationTypeCorrespondsToPermitNumber = (
}
return undefined;
};

export const assessedLiabilityNegativeWarning = (value) =>
positiveNumber(value)
? "A negative value will decrease the current assessed liability"
: undefined;

0 comments on commit 5d16223

Please sign in to comment.