Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MDS-6178] CORE project summary edit mode bugs, contd #3285

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 70 additions & 54 deletions services/common/src/components/projectSummary/ProjectDates.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { useSelector } from "react-redux";
import { Field, getFormValues } from "redux-form";
import { Typography } from "antd";
import { Col, Row, Typography } from "antd";
import {
dateNotBeforeOther,
dateNotAfterOther,
Expand All @@ -24,59 +24,75 @@ export const ProjectDates = () => {
return (
<>
<Typography.Title level={3}>Project Dates</Typography.Title>
<Callout
message={
<>
These dates are for guidance and planning purposes only and do not reflect actual
delivery dates. The{" "}
<a
target="_blank"
rel="noopener noreferrer"
title="Major Mines Permitting Office"
href="https://www2.gov.bc.ca/gov/content/industry/mineral-exploration-mining/permitting/major-mines-permitting-office"
>
Major Mines Office
</a>{" "}
will work with you on a more definitive schedule.
</>
}
/>
<Field
id="expected_draft_irt_submission_date"
name="expected_draft_irt_submission_date"
label="When do you anticipate submitting a draft Information Requirements Table?"
placeholder="Please select date"
component={RenderDate}
validate={[dateInFuture, dateNotAfterOther(expected_permit_application_date)]}
disabled={isFieldDisabled(systemFlag, formValues?.status_code)}
/>
<Field
id="expected_permit_application_date"
name="expected_permit_application_date"
label="When do you anticipate submitting a permit application?"
placeholder="Please select date"
component={RenderDate}
validate={[dateInFuture, dateNotBeforeOther(expected_draft_irt_submission_date)]}
disabled={isFieldDisabled(systemFlag, formValues?.status_code)}
/>
<Field
id="expected_permit_receipt_date"
name="expected_permit_receipt_date"
label="When do you hope to receive your permit/amendment(s)?"
placeholder="Please select date"
component={RenderDate}
validate={[dateInFuture, dateNotBeforeOther(expected_permit_application_date)]}
disabled={isFieldDisabled(systemFlag, formValues?.status_code)}
/>
<Field
id="expected_project_start_date"
name="expected_project_start_date"
label="When do you anticipate starting work on this project?"
placeholder="Please select date"
component={RenderDate}
validate={[dateInFuture, dateNotBeforeOther(expected_permit_receipt_date)]}
disabled={isFieldDisabled(systemFlag, formValues?.status_code)}
/>
<Row gutter={[0, 16]}>
<Col>
<Callout
message={
<>
These dates are for guidance and planning purposes only and do not reflect actual
delivery dates. The{" "}
<a
target="_blank"
rel="noopener noreferrer"
title="Major Mines Permitting Office"
href="https://www2.gov.bc.ca/gov/content/industry/mineral-exploration-mining/permitting/major-mines-permitting-office"
>
Major Mines Office
</a>{" "}
will work with you on a more definitive schedule.
</>
}
/>
</Col>
<Col span={24}>
<Field
id="expected_draft_irt_submission_date"
name="expected_draft_irt_submission_date"
label="When do you anticipate submitting a draft Information Requirements Table?"
placeholder="Please select date"
component={RenderDate}
allowClear
validate={[dateInFuture, dateNotAfterOther(expected_permit_application_date, "the expected permit application date")]}
disabled={isFieldDisabled(systemFlag, formValues?.status_code)}
/>
</Col>
<Col span={24}>
<Field
id="expected_permit_application_date"
name="expected_permit_application_date"
label="When do you anticipate submitting a permit application?"
placeholder="Please select date"
component={RenderDate}
allowClear
validate={[dateInFuture, dateNotBeforeOther(expected_draft_irt_submission_date, "the expected draft IRT submission date")]}
disabled={isFieldDisabled(systemFlag, formValues?.status_code)}
/>
</Col>
<Col span={24}>
<Field
id="expected_permit_receipt_date"
name="expected_permit_receipt_date"
label="When do you hope to receive your permit/amendment(s)?"
placeholder="Please select date"
component={RenderDate}
allowClear
validate={[dateInFuture, dateNotBeforeOther(expected_permit_application_date, "the expected permit application date")]}
disabled={isFieldDisabled(systemFlag, formValues?.status_code)}
/>
</Col>
<Col span={24}>
<Field
id="expected_project_start_date"
name="expected_project_start_date"
label="When do you anticipate starting work on this project?"
placeholder="Please select date"
component={RenderDate}
allowClear
validate={[dateInFuture, dateNotBeforeOther(expected_permit_receipt_date, "the expected permit receipt date")]}
disabled={isFieldDisabled(systemFlag, formValues?.status_code)}
/>
</Col>
</Row>
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useEffect, useState } from "react";
import React, { FC, useContext, useEffect, useState } from "react";
import { getProject, getProjects } from "@mds/common/redux/selectors/projectSelectors";
import { useSelector, useDispatch } from "react-redux";
import { Field, change, getFormValues } from "redux-form";
Expand All @@ -21,6 +21,7 @@ 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";
import { FormContext } from "../forms/FormWrapper";

interface ProjectLinksProps {
viewProject: (record: ILinkedProject) => string;
Expand Down Expand Up @@ -53,6 +54,7 @@ const ProjectLinkInput = ({ unrelatedProjects = [], mineGuid, projectGuid }) =>

const addRelatedProjects = () => {
dispatch(createProjectLinks(mineGuid, projectGuid, currentSelection)).then(() => {
setCurrentSelection([]);
dispatch(change(formName, fieldName, []));
});
};
Expand Down Expand Up @@ -102,6 +104,7 @@ const ProjectLinks: FC<ProjectLinksProps> = ({ viewProject, tableOnly = false })
const canEditProjects = useSelector((state) =>
userHasRole(state, USER_ROLES.role_edit_project_summaries)
);
const { isEditMode } = useContext(FormContext);
const hasModifyPermission = isUserProponent || canEditProjects;

const separateProjectLists = (projects: IProject[]): [ILinkedProject[], IProject[]] => {
Expand Down Expand Up @@ -160,7 +163,7 @@ const ProjectLinks: FC<ProjectLinksProps> = ({ viewProject, tableOnly = false })
<Typography.Paragraph>
Description of related major project applications for this mine are listed below.
</Typography.Paragraph>
{!tableOnly && (
{!tableOnly && isEditMode && (
<ProjectLinkInput
unrelatedProjects={unrelatedProjects}
mineGuid={project.mine_guid}
Expand Down
Loading
Loading