From 7e136f8e6433a8a750c82aae7a3eaf77bceb85d2 Mon Sep 17 00:00:00 2001 From: Henry Oforeh Date: Mon, 22 Jan 2024 11:19:25 -0700 Subject: [PATCH] [MDS-5298] ministry follow up user flow (#2903) * rearrange form fields. * add rows * update header, remove unused imports and code. * Remove commented code. --- .../Forms/incidents/IncidentForm.tsx | 6 +- .../incidents/IncidentFormInitialReport.tsx | 154 +++++++++++++++++- .../IncidentFormMinistryFollowup.tsx | 125 +------------- 3 files changed, 158 insertions(+), 127 deletions(-) diff --git a/services/core-web/src/components/Forms/incidents/IncidentForm.tsx b/services/core-web/src/components/Forms/incidents/IncidentForm.tsx index 00080ff7f5..8c609945f8 100644 --- a/services/core-web/src/components/Forms/incidents/IncidentForm.tsx +++ b/services/core-web/src/components/Forms/incidents/IncidentForm.tsx @@ -142,7 +142,11 @@ export const IncidentForm: FC = (props) = {renderEditSaveControls()} - +
= ({ isEditMode, incident, + inspectorOptions, }) => { + const formValues = useSelector((state) => getFormValues(ADD_EDIT_INCIDENT)(state)); const showUnspecified = incident.mine_incident_guid && !incident.incident_location; const locationOptions = [ @@ -42,6 +48,14 @@ const IncidentFormInitialReport: FC = ({ ]; const incidentCategoryCodeOptions = useSelector(getDropdownIncidentCategoryCodeOptions); + const [inspectorContactedValidation, setInspectorContactedValidation] = useState({}); + const [inspectorContacted, setInspectorContacted] = useState(null); + + useEffect(() => { + const inspectorSet = formValues?.reported_to_inspector_party_guid; + setInspectorContactedValidation(inspectorSet ? { validate: [requiredRadioButton] } : {}); + setInspectorContacted(formValues?.reported_to_inspector_contacted); + }, [formValues]); return (
@@ -109,6 +123,140 @@ const IncidentFormInitialReport: FC = ({ + + +

Verbal Notification

+ + + + + {formValues.verbal_notification_provided && ( + + + + )} +
+ +

Ministry Inspector Details

+ + + + + + + + + + {inspectorContacted && ( + + + + + + cm?.inspectorOnly)} + disabled={!isEditMode} + validate={[required]} + /> + + + )} + + + + + + + + + + +
{/* Incident Details */} diff --git a/services/core-web/src/components/Forms/incidents/IncidentFormMinistryFollowup.tsx b/services/core-web/src/components/Forms/incidents/IncidentFormMinistryFollowup.tsx index 2dcebff408..95bbae238c 100644 --- a/services/core-web/src/components/Forms/incidents/IncidentFormMinistryFollowup.tsx +++ b/services/core-web/src/components/Forms/incidents/IncidentFormMinistryFollowup.tsx @@ -1,15 +1,14 @@ import { - INCIDENT_CONTACT_METHOD_OPTIONS, INCIDENT_DETERMINATION_TYPES, INCIDENT_FOLLOWUP_ACTIONS, } from "@mds/common/constants/strings"; -import React, { FC, useEffect, useState } from "react"; +import React, { FC } from "react"; import { useSelector } from "react-redux"; import { Field, FieldArray, getFormValues } from "redux-form"; import { ADD_EDIT_INCIDENT } from "@/constants/forms"; import { Button, Col, Row, Typography } from "antd"; import { renderConfig } from "@/components/common/config"; -import { required, requiredRadioButton, validateSelectOptions } from "@common/utils/Validate"; +import { required, validateSelectOptions } from "@common/utils/Validate"; import RenderDateTimeTz from "@/components/common/RenderDateTimeTz"; import { normalizeDatetime } from "@mds/common/redux/utils/helpers"; import { dateNotBeforeStrictOther, dateNotInFutureTZ } from "@mds/common/redux/utils/Validate"; @@ -32,17 +31,6 @@ const IncidentFormMinistryFollowup: FC = ({ }) => { const formValues = useSelector((state) => getFormValues(ADD_EDIT_INCIDENT)(state)); - const [inspectorContactedValidation, setInspectorContactedValidation] = useState({}); - const [inspectorContacted, setInspectorContacted] = useState(null); - - useEffect(() => { - const inspectorSet = formValues?.reported_to_inspector_party_guid; - - setInspectorContactedValidation(inspectorSet ? { validate: [requiredRadioButton] } : {}); - - setInspectorContacted(formValues?.reported_to_inspector_contacted); - }, [formValues]); - const filteredFollowUpActions = incidentFollowUpActionOptions.filter( (act) => act.mine_incident_followup_investigation_type !== INCIDENT_FOLLOWUP_ACTIONS.unknown ); @@ -119,18 +107,6 @@ const IncidentFormMinistryFollowup: FC = ({ /> )} - -

Verbal Notification

- - - - {formValues.verbal_notification_provided && ( = ({ /> )} - -

Follow-Up Information

- - - - - - - - {inspectorContacted && ( - <> - - - - - cm?.inspectorOnly)} - disabled={!isEditMode} - validate={[required]} - /> - - - )} - - - - - - - - -