Skip to content

Commit

Permalink
FE and backend logic for state changing for IAO users connected. WIP …
Browse files Browse the repository at this point in the history
…Debugging + button / manual lock feautre + ministry user work
  • Loading branch information
Aman-Hundal committed Jul 11, 2024
1 parent 669c6a0 commit ea57ee3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const BottomButtonGroup = React.memo(
axisMessage,
attachmentsArray,
oipcData,
validLockRecordsState,
}) => {
/**
* Bottom Button Group of Review request Page
Expand Down Expand Up @@ -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 : [];
Expand Down Expand Up @@ -253,6 +262,7 @@ const BottomButtonGroup = React.memo(
};

const handleModal = (value) => {
console.log("LIQUIDD")
setOpenModal(false);
if (!value) {
handleOpenRequest("", "", true);
Expand Down Expand Up @@ -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, "");
Expand Down
38 changes: 23 additions & 15 deletions forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1416,6 +1423,7 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {
axisMessage={axisMessage}
attachmentsArray={requestAttachments}
oipcData={oipcData}
validLockRecordsState={validLockRecordsState}
/>
</>
</ConditionalComponent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ea57ee3

Please sign in to comment.