From ea57ee383b696653b5060a3886d8e919e283a2bc Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Wed, 10 Jul 2024 17:13:03 -0700 Subject: [PATCH] FE and backend logic for state changing for IAO users connected. WIP Debugging + button / manual lock feautre + ministry user work --- .../FOI/FOIRequest/BottomButtonGroup/index.js | 11 ++++++ .../components/FOI/FOIRequest/FOIRequest.js | 38 +++++++++++-------- .../request_api/schemas/foirequestwrapper.py | 2 +- 3 files changed, 35 insertions(+), 16 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 dd2344981..38221aab5 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/BottomButtonGroup/index.js @@ -77,6 +77,7 @@ const BottomButtonGroup = React.memo( axisMessage, attachmentsArray, oipcData, + validLockRecordsState, }) => { /** * Bottom Button Group of Review request Page @@ -120,6 +121,14 @@ const BottomButtonGroup = React.memo( setIsAddRequest(false); } + //Logic to change lock records to null (and have FE useEffect in FOIRequest.js/MinistryView.js logic takeover) if request goes back to open, cfr, harms, fee estimate, dedup + if (!validLockRecordsState(currentSelectedStatus)) { + console.log("GOT YA") + saveRequestObject.lockrecords = true; + } + + console.log("SAVE PBJ", saveRequestObject) + //add oipc Data to save request object and sync/validate isoipcreview attribute if (requestState.toLowerCase() !== StateEnum.intakeinprogress.name.toLowerCase() && requestState.toLowerCase() !== StateEnum.unopened.name.toLowerCase()) { saveRequestObject.oipcdetails = oipcData ? oipcData : []; @@ -253,6 +262,7 @@ const BottomButtonGroup = React.memo( }; const handleModal = (value) => { + console.log("LIQUIDD") setOpenModal(false); if (!value) { handleOpenRequest("", "", true); @@ -389,6 +399,7 @@ const BottomButtonGroup = React.memo( const handleSaveModal = (value, fileInfoList, files) => { setsaveModal(false); setFileCount(files?.length); + console.log("SNAKEE") if (!value) { handleSaveRequest(requestState, true, ""); diff --git a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js index 875934042..a241fc4b5 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js @@ -296,21 +296,6 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { } else if (window.location.href.indexOf("records") > -1) { tabclick("Records"); } - //Adjust lockRecords tab state if there is no BE/DB data recorded - const updateRecordsTabAccess = () => { - if(requestDetails.lockrecords === null) { - return ( - requestState === StateEnum.recordsreadyforreview.name || - requestState === StateEnum.review.name || - requestState === StateEnum.consult.name || - requestState === StateEnum.peerreview.name || - requestState === StateEnum.signoff.name || - requestState === StateEnum.response.name || - requestState === StateEnum.closed.name - ); - } - } - setLockRecordsTab(updateRecordsTabAccess()) }, []); useEffect(async () => { @@ -357,6 +342,20 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { if (bcgovcode) dispatch(fetchFOIMinistryAssignedToList(bcgovcode)); }, [requestId, ministryId, comment, attachments]); + const validLockRecordsState = (currentState) => { + console.log("MIQU", requestDetails) + console.log("BOOM", currentState) + return ( + currentState === StateEnum.recordsreadyforreview.name || + currentState === StateEnum.review.name || + currentState === StateEnum.consult.name || + currentState === StateEnum.peerreview.name || + currentState === StateEnum.signoff.name || + currentState === StateEnum.response.name || + currentState === StateEnum.closed.name + ); + } + useEffect(() => { const requestDetailsValue = requestDetails; setSaveRequestObject(requestDetailsValue); @@ -392,6 +391,14 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { } else { setIsOIPCReview(false); } + + //Adjust lockRecords value based on requestState if there is no manual user lockrecords value present in requestDetails from DB + const updateRecordsTabAccess = () => { + if(requestDetails.lockrecords === null) { + return validLockRecordsState(requestDetails.currentState) + } + } + setLockRecordsTab(updateRecordsTabAccess()); }, [requestDetails]); //useEffect to manage isoipcreview attribute for requestdetails state @@ -1416,6 +1423,7 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => { axisMessage={axisMessage} attachmentsArray={requestAttachments} oipcData={oipcData} + validLockRecordsState={validLockRecordsState} /> diff --git a/request-management-api/request_api/schemas/foirequestwrapper.py b/request-management-api/request_api/schemas/foirequestwrapper.py index 7ebc88f32..0d8925d1a 100644 --- a/request-management-api/request_api/schemas/foirequestwrapper.py +++ b/request-management-api/request_api/schemas/foirequestwrapper.py @@ -155,7 +155,7 @@ class Meta: # pylint: disable=too-few-public-methods identityVerified = fields.Str(data_key="identityVerified",allow_none=True) oipcdetails = fields.Nested(FOIMinistryRequestOIPCSchema, many=True,allow_none=True) - lockrecords = fields.Bool(data_key="isofflinepayment") + lockrecords = fields.Bool(data_key="lockrecords", allow_none=True) recordspagecount = fields.Int(data_key="recordspagecount",allow_none=True) axislanpagecount = fields.Int(data_key="axislanpagecount",allow_none=True)