From a696e89662a999d97657017836ea539b1b3e382f Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Tue, 28 Nov 2023 13:14:08 -0800 Subject: [PATCH] WIP Flag Ingtegration + code adjustments --- .../FOI/FOIRequest/BottomButtonGroup/index.js | 8 ++++++-- .../src/components/FOI/FOIRequest/FOIRequest.js | 10 ++++++++++ .../FOI/FOIRequest/OIPCDetails/OIPCDetailsList.jsx | 2 +- .../components/FOI/FOIRequest/OIPCDetails/oipcHook.js | 8 +++++--- forms-flow-web/src/components/FOI/FOIRequest/utils.js | 2 +- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js b/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js index 1b2d06b3c..fa6a7df22 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js @@ -120,9 +120,13 @@ const BottomButtonGroup = React.memo( setIsAddRequest(false); } - //add oipc Data to save request object + //add oipc Data to save request object and sync/validate isoipcreview attribute saveRequestObject.oipcdetails = oipcData; - if (oipcData.length <= 0) saveRequestObject.isoipcreview = false; + if (oipcData.length > 0) { + saveRequestObject.isoipcreview = true; + } else { + saveRequestObject.isoipcreview = false; + } dispatch(setFOILoader(setLoader)) dispatch( diff --git a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js index 6dfa7961b..8a6ae0ec4 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js @@ -345,6 +345,16 @@ const FOIRequest = React.memo(({ userDetail }) => { } }, [requestDetails]); + //useEffect to manage isoipcreview attribute for requestdetails state + useEffect(() => { + if(Object.keys(requestDetails).length !== 0 && oipcData?.length <= 0) { + requestDetails.isoipcreview = false; + setShowOIPCDetails(false); + } + }, [oipcData]) + + console.log(requestDetails) + useEffect(() => { if (isIAORestricted) dispatch(fetchRestrictedRequestCommentTagList(requestId, ministryId)); diff --git a/forms-flow-web/src/components/FOI/FOIRequest/OIPCDetails/OIPCDetailsList.jsx b/forms-flow-web/src/components/FOI/FOIRequest/OIPCDetails/OIPCDetailsList.jsx index afa6f2fa8..2e06dfe43 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/OIPCDetails/OIPCDetailsList.jsx +++ b/forms-flow-web/src/components/FOI/FOIRequest/OIPCDetails/OIPCDetailsList.jsx @@ -10,7 +10,7 @@ const OIPCDetailsList = (props) => { return ( <> - {index !== (oipcData.length - 1) && } + {index !== (oipcData?.length - 1) && } ); }); diff --git a/forms-flow-web/src/components/FOI/FOIRequest/OIPCDetails/oipcHook.js b/forms-flow-web/src/components/FOI/FOIRequest/OIPCDetails/oipcHook.js index d9fb732a4..f75a4e500 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/OIPCDetails/oipcHook.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/OIPCDetails/oipcHook.js @@ -28,8 +28,6 @@ const useOIPCHook = () => { issubsequentappeal: false, }]; } - } else { - return []; } } const [oipcData, setOipcData] = useState(requestDetails.oipcdetails); @@ -45,7 +43,7 @@ const useOIPCHook = () => { const addOIPC = () => { setOipcData((prev) => { return [...prev, { - id: oipcData.length > 0 ? oipcData[oipcData.length - 1].id + 1 : 0, + id: oipcData?.length > 0 ? oipcData[oipcData.length - 1].id + 1 : 0, oipcno: "", reviewtypeid: null, reasonid: null, @@ -79,6 +77,9 @@ const useOIPCHook = () => { }); }); } + const removeAllOIPCs = () => { + setOipcData([]); + } return { oipcData, @@ -86,6 +87,7 @@ const useOIPCHook = () => { removeOIPC, updateOIPC, stageOIPCData, + removeAllOIPCs, }; }; diff --git a/forms-flow-web/src/components/FOI/FOIRequest/utils.js b/forms-flow-web/src/components/FOI/FOIRequest/utils.js index f71148f4b..81d20752c 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/utils.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/utils.js @@ -348,7 +348,7 @@ export const checkValidationError = ( !requiredRequestDetailsValues.receivedDate || !requiredRequestDetailsValues.requestStartDate || !requiredAxisDetails.axisRequestId || - (oipcData.length > 0 && isOipcReview && oipcData.some((oipc) => { + (oipcData?.length > 0 && isOipcReview && oipcData?.some((oipc) => { return oipc.oipcno === "" || oipc.receiveddate === null || oipc.reviewtypeid === null || oipc.reasonid === null || oipc.statusid === null || oipc.inquiryattributes?.orderno === "" || oipc.inquiryattributes?.inquiryoutcome === null || oipc.inquiryattributes?.inquirydate === null; }))