From 0f2b1f6442002e63ed4097eeb5b1296ecc9ce017 Mon Sep 17 00:00:00 2001 From: asinn134 <127789479+asinn134@users.noreply.github.com> Date: Wed, 8 Nov 2023 09:28:22 -0800 Subject: [PATCH] [MDS-5590] Adjusting esup creation flow for permit and application sections (#2789) adjusting esup creation flow for permit and application sections --- .../ExplosivesPermitFormNew.tsx | 34 +++++++++++++------ .../ExplosivesPermit/ExplosivesPermit.tsx | 4 +-- .../modalContent/AddExplosivesPermitModal.tsx | 1 + 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/services/core-web/src/components/Forms/ExplosivesPermit/ExplosivesPermitFormNew.tsx b/services/core-web/src/components/Forms/ExplosivesPermit/ExplosivesPermitFormNew.tsx index 1bece1d49f..fd96967464 100644 --- a/services/core-web/src/components/Forms/ExplosivesPermit/ExplosivesPermitFormNew.tsx +++ b/services/core-web/src/components/Forms/ExplosivesPermit/ExplosivesPermitFormNew.tsx @@ -1,7 +1,14 @@ import React, { FC, useEffect, useState } from "react"; import { connect } from "react-redux"; import { compose } from "redux"; -import { Field, formValueSelector, getFormValues, InjectedFormProps, reduxForm } from "redux-form"; +import { + Field, + formValueSelector, + getFormValues, + InjectedFormProps, + reduxForm, + change, +} from "redux-form"; import { Form } from "@ant-design/compatible"; import "@ant-design/compatible/assets/index.css"; import { Alert, Button, Col, Popconfirm, Row, Table, Typography, Radio } from "antd"; @@ -52,6 +59,7 @@ interface ExplosivesPermitFormProps { isAmendment?: boolean; inspectors: IGroupedDropdownList[]; documents: IExplosivesPermitDocument[]; + dispatch: any; } interface StateProps { @@ -120,9 +128,7 @@ export const ExplosivesPermitFormNew: FC( - !initialValues?.explosives_permit_id && props.isPermitTab - ); + const [isHistoric, setIsHistoric] = useState(!initialValues?.explosives_permit_id); const disabled = isProcessed; @@ -130,6 +136,14 @@ export const ExplosivesPermitFormNew: FC(!isAmendment); const [isAmendSelected, setIsAmend] = useState(false); + useEffect(() => { + props.dispatch(change(FORM.EXPLOSIVES_PERMIT_NEW, "is_historic", isHistoric)); + }, [isHistoric]); + + useEffect(() => { + setIsHistoric(radioSelection === 1); + }, []); + const handleRadioChange = (e) => { setRadioSelection(e.target.value); setIsHistoric(e.target.value === 1); @@ -294,7 +308,7 @@ export const ExplosivesPermitFormNew: FC Explosives Permit Details - {props.isPermitTab && ( + {isHistoric && ( <> @@ -341,7 +355,7 @@ export const ExplosivesPermitFormNew: FC )} - {props.isPermitTab && ( + {isHistoric && ( )} - + ({ }); export default compose( - connect(mapStateToProps, null), + connect(mapStateToProps), reduxForm({ form: FORM.EXPLOSIVES_PERMIT_NEW, touchOnBlur: true, diff --git a/services/core-web/src/components/mine/ExplosivesPermit/ExplosivesPermit.tsx b/services/core-web/src/components/mine/ExplosivesPermit/ExplosivesPermit.tsx index f02a7dd5dd..606d251c3b 100644 --- a/services/core-web/src/components/mine/ExplosivesPermit/ExplosivesPermit.tsx +++ b/services/core-web/src/components/mine/ExplosivesPermit/ExplosivesPermit.tsx @@ -115,7 +115,7 @@ export const ExplosivesPermit: FC = ({ }; const handleAddExplosivesPermit = (values) => { - const system = values.permit_tab ? "MMS" : "Core"; + const system = values.is_historic ? "MMS" : "Core"; const payload = { originating_system: system, ...values, @@ -157,7 +157,7 @@ export const ExplosivesPermit: FC = ({ }; const handleOpenAddExplosivesPermitModal = (event, permitTab, record = null) => { - const initialValues = record || { permit_tab: permitTab }; + const initialValues = record || {}; const isProcessed = record !== null && record?.application_status !== "REC"; event.preventDefault(); props.openModal({ diff --git a/services/core-web/src/components/modalContent/AddExplosivesPermitModal.tsx b/services/core-web/src/components/modalContent/AddExplosivesPermitModal.tsx index 8492a397ea..9747c8b2a4 100644 --- a/services/core-web/src/components/modalContent/AddExplosivesPermitModal.tsx +++ b/services/core-web/src/components/modalContent/AddExplosivesPermitModal.tsx @@ -16,6 +16,7 @@ interface ExplosivesPermitModalProps { closeModal: () => void; isProcessed: boolean; isAmendment: boolean; + dispatch: any; } export const AddExplosivesPermitModal: FC = (props) => (