Skip to content

Commit

Permalink
WIP Flag Ingtegration + code adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman-Hundal committed Nov 28, 2023
1 parent e6f9afd commit a696e89
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const OIPCDetailsList = (props) => {
return (
<>
<OIPCItem oipcObj={oipcObj} key={oipcObj.id} updateOIPC={updateOIPC} removeOIPC={removeOIPC} />
{index !== (oipcData.length - 1) && <Divider/>}
{index !== (oipcData?.length - 1) && <Divider/>}
</>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ const useOIPCHook = () => {
issubsequentappeal: false,
}];
}
} else {
return [];
}
}
const [oipcData, setOipcData] = useState(requestDetails.oipcdetails);
Expand All @@ -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,
Expand Down Expand Up @@ -79,13 +77,17 @@ const useOIPCHook = () => {
});
});
}
const removeAllOIPCs = () => {
setOipcData([]);
}

return {
oipcData,
addOIPC,
removeOIPC,
updateOIPC,
stageOIPCData,
removeAllOIPCs,
};
};

Expand Down
2 changes: 1 addition & 1 deletion forms-flow-web/src/components/FOI/FOIRequest/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}))
Expand Down

0 comments on commit a696e89

Please sign in to comment.