From 146f73cf5cc210ebafa276e16ba9da4d8607e2f5 Mon Sep 17 00:00:00 2001 From: Tara Epp <102187683+taraepp@users.noreply.github.com> Date: Mon, 21 Oct 2024 22:53:05 +0000 Subject: [PATCH 1/7] sneaky Help Guide button style fixing --- services/common/src/components/help/HelpGuide.tsx | 12 ++++++++++-- .../core-web/src/styles/components/HelpGuide.scss | 12 ++++++++++++ .../src/styles/components/HelpGuide.scss | 13 +++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/services/common/src/components/help/HelpGuide.tsx b/services/common/src/components/help/HelpGuide.tsx index 26235b21af..78f3df1c8d 100644 --- a/services/common/src/components/help/HelpGuide.tsx +++ b/services/common/src/components/help/HelpGuide.tsx @@ -27,6 +27,8 @@ import DOMPurify from "dompurify"; import { useFeatureFlag } from "@mds/common/providers/featureFlags/useFeatureFlag"; import { Feature } from "@mds/common/utils"; import Loading from "../common/Loading"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faQuestionCircle } from "@fortawesome/pro-regular-svg-icons"; interface HelpGuideProps { helpKey: string; @@ -138,8 +140,14 @@ export const HelpGuideContent: FC = ({ helpKey }) => { return ( <> - Date: Tue, 22 Oct 2024 19:51:15 +0000 Subject: [PATCH 2/7] disable province with international address --- .../projectSummary/ProjectContacts.tsx | 63 +++++++++---------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/services/common/src/components/projectSummary/ProjectContacts.tsx b/services/common/src/components/projectSummary/ProjectContacts.tsx index d4bea94d88..62f6f301bc 100644 --- a/services/common/src/components/projectSummary/ProjectContacts.tsx +++ b/services/common/src/components/projectSummary/ProjectContacts.tsx @@ -15,10 +15,9 @@ 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, isFieldDisabled } from "@mds/common/constants"; +import { FORM, isFieldDisabled, CONTACTS_COUNTRY_OPTIONS } 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"; @@ -46,9 +45,9 @@ const RenderContacts = ({ fields, isDisabled }) => { const { address_type_code, sub_division_code } = address ?? {}; const isInternational = address_type_code === "INT"; const isPrimary = contact.is_primary; + return ( - // eslint-disable-next-line react/no-array-index-key -
+
{index === 0 ? ( <> Primary project contact @@ -58,35 +57,33 @@ const RenderContacts = ({ fields, isDisabled }) => { ) : ( - <> - - - - - Additional project contact #{index} - - - - fields.remove(index)} - okText="Remove" - cancelText="Cancel" + + + + + Additional project contact #{index} + + + + fields.remove(index)} + okText="Remove" + cancelText="Cancel" + > + - - - - - + Delete + + + + + )} @@ -208,7 +205,7 @@ const RenderContacts = ({ fields, isDisabled }) => { Date: Tue, 22 Oct 2024 19:54:43 +0000 Subject: [PATCH 3/7] project dates validation- change data type from timestamp to date, use string comparison to ignorethe time in validation methods. Add validation for the date to be in the future --- ...__change_project_summary_dates_to_date.sql | 15 +++++++++++++ .../projectSummary/ProjectDates.tsx | 14 +++++++----- services/common/src/redux/utils/Validate.ts | 22 ++++++++++--------- .../project_summary/models/project_summary.py | 8 +++---- .../app/api/projects/response_models.py | 8 +++---- 5 files changed, 44 insertions(+), 23 deletions(-) create mode 100644 migrations/sql/V2024.11.22.10.31__change_project_summary_dates_to_date.sql diff --git a/migrations/sql/V2024.11.22.10.31__change_project_summary_dates_to_date.sql b/migrations/sql/V2024.11.22.10.31__change_project_summary_dates_to_date.sql new file mode 100644 index 0000000000..666e06c13e --- /dev/null +++ b/migrations/sql/V2024.11.22.10.31__change_project_summary_dates_to_date.sql @@ -0,0 +1,15 @@ +ALTER TABLE project_summary + ALTER COLUMN expected_draft_irt_submission_date TYPE date + USING expected_draft_irt_submission_date::date; + +ALTER TABLE project_summary + ALTER COLUMN expected_permit_application_date TYPE date + USING expected_permit_application_date::date; + +ALTER TABLE project_summary + ALTER COLUMN expected_permit_receipt_date TYPE date + USING expected_permit_receipt_date::date; + +ALTER TABLE project_summary + ALTER COLUMN expected_project_start_date TYPE date + USING expected_project_start_date::date; \ No newline at end of file diff --git a/services/common/src/components/projectSummary/ProjectDates.tsx b/services/common/src/components/projectSummary/ProjectDates.tsx index 6966c3e64f..f201180022 100644 --- a/services/common/src/components/projectSummary/ProjectDates.tsx +++ b/services/common/src/components/projectSummary/ProjectDates.tsx @@ -2,7 +2,11 @@ import React from "react"; import { useSelector } from "react-redux"; import { Field, getFormValues } from "redux-form"; import { Typography } from "antd"; -import { dateNotBeforeOther, dateNotAfterOther } from "@mds/common/redux/utils/Validate"; +import { + dateNotBeforeOther, + dateNotAfterOther, + dateInFuture, +} from "@mds/common/redux/utils/Validate"; import Callout from "@mds/common/components/common/Callout"; import { FORM, isFieldDisabled } from "@mds/common/constants"; import RenderDate from "@mds/common/components/forms/RenderDate"; @@ -43,7 +47,7 @@ export const ProjectDates = () => { label="When do you anticipate submitting a draft Information Requirements Table?" placeholder="Please select date" component={RenderDate} - validate={[dateNotAfterOther(expected_permit_application_date)]} + validate={[dateInFuture, dateNotAfterOther(expected_permit_application_date)]} disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> { label="When do you anticipate submitting a permit application?" placeholder="Please select date" component={RenderDate} - validate={[dateNotBeforeOther(expected_draft_irt_submission_date)]} + validate={[dateInFuture, dateNotBeforeOther(expected_draft_irt_submission_date)]} disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> { label="When do you hope to receive your permit/amendment(s)?" placeholder="Please select date" component={RenderDate} - validate={[dateNotBeforeOther(expected_permit_application_date)]} + validate={[dateInFuture, dateNotBeforeOther(expected_permit_application_date)]} disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> { label="When do you anticipate starting work on this project?" placeholder="Please select date" component={RenderDate} - validate={[dateNotBeforeOther(expected_permit_receipt_date)]} + validate={[dateInFuture, dateNotBeforeOther(expected_permit_receipt_date)]} disabled={isFieldDisabled(systemFlag, formValues?.status_code)} /> diff --git a/services/common/src/redux/utils/Validate.ts b/services/common/src/redux/utils/Validate.ts index 5ef8c2ef82..e377596824 100644 --- a/services/common/src/redux/utils/Validate.ts +++ b/services/common/src/redux/utils/Validate.ts @@ -276,11 +276,12 @@ export const dateTimezoneRequired = memoize((timezoneField) => (_value, allValue export const dateInFuture = (value) => value && !moment(value).isAfter() ? "Date must be in the future" : undefined; -export const dateNotBeforeOther = memoize((other) => (value) => - value && other && new Date(value) <= new Date(other) - ? `Date cannot be on or before ${new Date(other).toDateString()}` - : undefined -); +// NOTE: modified from version in CORE- change from <= to < +export const dateNotBeforeOther = memoize((other: string) => (value: string) => { + return value && other && value < other + ? `Date cannot be before ${moment(other).format("ddd MMM D YYYY")}` + : undefined; +}); export const dateNotBeforeStrictOther = memoize((other) => (value) => value && other && moment(value).isBefore(other) ? `Date cannot be before ${other}` : undefined @@ -298,11 +299,12 @@ export const timeNotBeforeOther = memoize( : undefined ); -export const dateNotAfterOther = memoize((other) => (value) => - value && other && new Date(value) >= new Date(other) - ? `Date cannot be on or after ${new Date(other).toDateString()}` - : undefined -); +// NOTE: modified from version in CORE- change from >= to > +export const dateNotAfterOther = memoize((other: string) => (value: string) => { + return value && other && value > other + ? `Date cannot be after ${moment(other).format("ddd MMM D YYYY")}` + : undefined; +}); export const yearNotInFuture = (value) => value && value > new Date().getFullYear() ? "Year cannot be in the future" : undefined; diff --git a/services/core-api/app/api/projects/project_summary/models/project_summary.py b/services/core-api/app/api/projects/project_summary/models/project_summary.py index c2d12d064e..4c81d4a3f5 100644 --- a/services/core-api/app/api/projects/project_summary/models/project_summary.py +++ b/services/core-api/app/api/projects/project_summary/models/project_summary.py @@ -47,10 +47,10 @@ class ProjectSummary(SoftDeleteMixin, AuditMixin, Base): db.Integer, server_default=FetchedValue(), nullable=False, unique=True) project_summary_description = db.Column(db.String(4000), nullable=True) submission_date = db.Column(db.DateTime, nullable=True) - expected_draft_irt_submission_date = db.Column(db.DateTime, nullable=True) - expected_permit_application_date = db.Column(db.DateTime, nullable=True) - expected_permit_receipt_date = db.Column(db.DateTime, nullable=True) - expected_project_start_date = db.Column(db.DateTime, nullable=True) + expected_draft_irt_submission_date = db.Column(db.Date, nullable=True) + expected_permit_application_date = db.Column(db.Date, nullable=True) + expected_permit_receipt_date = db.Column(db.Date, nullable=True) + expected_project_start_date = db.Column(db.Date, nullable=True) agent_party_guid = db.Column(UUID(as_uuid=True), db.ForeignKey('party.party_guid'), nullable=True) is_agent = db.Column(db.Boolean, nullable=True) facility_operator_guid = db.Column(UUID(as_uuid=True), db.ForeignKey('party.party_guid'), nullable=True) diff --git a/services/core-api/app/api/projects/response_models.py b/services/core-api/app/api/projects/response_models.py index bbed7deef8..34f3b22aab 100644 --- a/services/core-api/app/api/projects/response_models.py +++ b/services/core-api/app/api/projects/response_models.py @@ -188,11 +188,11 @@ def format(self, value): 'mine_name': fields.String, 'status_code': fields.String, 'proponent_project_id': fields.String, - 'expected_draft_irt_submission_date': fields.DateTime, + 'expected_draft_irt_submission_date': fields.Date, 'submission_date': fields.DateTime, - 'expected_permit_application_date': fields.DateTime, - 'expected_permit_receipt_date': fields.DateTime, - 'expected_project_start_date': fields.DateTime, + 'expected_permit_application_date': fields.Date, + 'expected_permit_receipt_date': fields.Date, + 'expected_project_start_date': fields.Date, 'documents': fields.List(fields.Nested(PROJECT_SUMMARY_DOCUMENT_MODEL)), 'contacts': fields.List(fields.Nested(PROJECT_CONTACT_MODEL)), 'authorizations': fields.List(fields.Nested(PROJECT_SUMMARY_AUTHORIZATION_MODEL)), From 91373258a1ad2842f4f3ccfd6401b9a97f3cc379 Mon Sep 17 00:00:00 2001 From: Tara Epp <102187683+taraepp@users.noreply.github.com> Date: Tue, 22 Oct 2024 19:55:26 +0000 Subject: [PATCH 4/7] disable add button on project links when there's no selection --- .../common/src/components/projectSummary/ProjectLinks.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/common/src/components/projectSummary/ProjectLinks.tsx b/services/common/src/components/projectSummary/ProjectLinks.tsx index c08537eeef..b3cf017dab 100644 --- a/services/common/src/components/projectSummary/ProjectLinks.tsx +++ b/services/common/src/components/projectSummary/ProjectLinks.tsx @@ -77,7 +77,9 @@ const ProjectLinkInput = ({ unrelatedProjects = [], mineGuid, projectGuid }) => onChange={(...args) => handleChange(args)} />