14115 SIPs events under summary pages on myportal
This commit is contained in:
+162
-98
@@ -373,115 +373,179 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
}
|
||||
);
|
||||
|
||||
// const getDetails = async (resultsObj, detailsType) => {
|
||||
// let detailsArr = [];
|
||||
// const limitRequests = pLimit(1); // Limit to 5 concurrent requests
|
||||
|
||||
// resultsObj =
|
||||
// detailsType == "mySubmittedReps" ? resultsObj : resultsObj.value;
|
||||
|
||||
// if (detailsType == "myRepresentations") {
|
||||
// limitRequests(async () => {
|
||||
// resultsObj.map((searchDetail, index) => {
|
||||
// detailsArr.push(
|
||||
// getCase(searchDetail["incidentID"])
|
||||
// .then(async (data) => {
|
||||
// let caseID = "";
|
||||
|
||||
// switch (detailsType) {
|
||||
// case "myCases":
|
||||
// caseID = data.pinswg_title;
|
||||
// break;
|
||||
// case "myWatchedCases":
|
||||
// case "mySubmittedReps":
|
||||
// caseID =
|
||||
// data[
|
||||
// "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
// ];
|
||||
// break;
|
||||
// case "awaitingSubmission":
|
||||
// case "myRepresentations":
|
||||
// try {
|
||||
// caseID = data.ticketnumber;
|
||||
// } catch {
|
||||
// console.log("missing:", data);
|
||||
// }
|
||||
|
||||
// break;
|
||||
// default:
|
||||
// caseID = data.pinswg_title;
|
||||
// }
|
||||
// return await getPortalModuleDetails(
|
||||
// getFormCollectionByID(
|
||||
// data.pinswg_appealcasetype
|
||||
// ).LogicalCollectionName,
|
||||
// caseID
|
||||
// ).catch((error) => {
|
||||
// console.log(
|
||||
// "=============================\ngetPortalModuleDetails error",
|
||||
// error
|
||||
// );
|
||||
// });
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// console.log(
|
||||
// "=============================\ngetCase error",
|
||||
// error
|
||||
// );
|
||||
// })
|
||||
// );
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// //debugger;
|
||||
// await Promise.all(
|
||||
// resultsObj.map(async (searchDetail, index) => {
|
||||
// limitRequests(async () => {
|
||||
// try {
|
||||
// let caseID = "";
|
||||
|
||||
// switch (detailsType) {
|
||||
// case "myCases":
|
||||
// caseID = searchDetail.pinswg_title;
|
||||
// break;
|
||||
// case "myWatchedCases":
|
||||
// case "mySubmittedReps":
|
||||
// caseID =
|
||||
// searchDetail[
|
||||
// "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
// ];
|
||||
// break;
|
||||
// case "awaitingSubmission":
|
||||
// caseID = searchDetail.ticketnumber;
|
||||
// break;
|
||||
// case "myRepresentations":
|
||||
// caseID = searchDetail.casereference;
|
||||
// break;
|
||||
// default:
|
||||
// caseID = searchDetail.pinswg_title;
|
||||
// }
|
||||
|
||||
// console.log(detailsType, " case id : ", caseID);
|
||||
|
||||
// searchDetail.pinswg_appealcasetype != null &&
|
||||
// detailsArr.push(
|
||||
// getPortalModuleDetails(
|
||||
// getFormCollectionByID(
|
||||
// searchDetail.pinswg_appealcasetype
|
||||
// ).LogicalCollectionName,
|
||||
// caseID
|
||||
// )
|
||||
// );
|
||||
// } catch (error) {
|
||||
// console.log("Error processing case:", error);
|
||||
// }
|
||||
// });
|
||||
// })
|
||||
// );
|
||||
|
||||
// let detArr = Promise.all(detailsArr);
|
||||
// // console.log(detArr);
|
||||
// return detArr;
|
||||
// };
|
||||
|
||||
const getDetails = async (resultsObj, detailsType) => {
|
||||
let detailsArr = [];
|
||||
const limitRequests = pLimit(5); // Limit to 5 concurrent requests
|
||||
const limitRequests = pLimit(5); // Allow up to 5 concurrent requests
|
||||
|
||||
// Adjust resultsObj based on detailsType
|
||||
resultsObj =
|
||||
detailsType == "mySubmittedReps" ? resultsObj : resultsObj.value;
|
||||
detailsType === "mySubmittedReps" ? resultsObj : resultsObj.value;
|
||||
|
||||
if (detailsType == "myRepresentations") {
|
||||
limitRequests(async () => {
|
||||
resultsObj.map((searchDetail, index) => {
|
||||
detailsArr.push(
|
||||
getCase(searchDetail["incidentID"])
|
||||
.then(async (data) => {
|
||||
let caseID = "";
|
||||
const getDetailsForCase = async (searchDetail) => {
|
||||
try {
|
||||
let caseID = "";
|
||||
|
||||
switch (detailsType) {
|
||||
case "myCases":
|
||||
caseID = data.pinswg_title;
|
||||
break;
|
||||
case "myWatchedCases":
|
||||
case "mySubmittedReps":
|
||||
caseID =
|
||||
data[
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
];
|
||||
break;
|
||||
case "awaitingSubmission":
|
||||
case "myRepresentations":
|
||||
try {
|
||||
caseID = data.ticketnumber;
|
||||
} catch {
|
||||
console.log("missing:", data);
|
||||
}
|
||||
// Determine the case ID based on the detailsType
|
||||
switch (detailsType) {
|
||||
case "myCases":
|
||||
caseID = searchDetail.pinswg_title;
|
||||
break;
|
||||
case "myWatchedCases":
|
||||
case "mySubmittedReps":
|
||||
caseID =
|
||||
searchDetail[
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
];
|
||||
break;
|
||||
case "awaitingSubmission":
|
||||
caseID = searchDetail.ticketnumber;
|
||||
break;
|
||||
case "myRepresentations":
|
||||
caseID = searchDetail.casereference;
|
||||
break;
|
||||
default:
|
||||
caseID = searchDetail.pinswg_title;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
caseID = data.pinswg_title;
|
||||
}
|
||||
return await getPortalModuleDetails(
|
||||
getFormCollectionByID(
|
||||
data.pinswg_appealcasetype
|
||||
).LogicalCollectionName,
|
||||
caseID
|
||||
).catch((error) => {
|
||||
console.log(
|
||||
"=============================\ngetPortalModuleDetails error",
|
||||
error
|
||||
);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(
|
||||
"=============================\ngetCase error",
|
||||
error
|
||||
);
|
||||
})
|
||||
console.log(detailsType, " case id: ", caseID);
|
||||
|
||||
// If the appeal case type is valid, fetch the portal module details
|
||||
if (searchDetail.pinswg_appealcasetype != null) {
|
||||
const formCollectionName = getFormCollectionByID(
|
||||
searchDetail.pinswg_appealcasetype
|
||||
).LogicalCollectionName;
|
||||
|
||||
const details = await getPortalModuleDetails(
|
||||
formCollectionName,
|
||||
caseID
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
//debugger;
|
||||
await Promise.all(
|
||||
resultsObj.map(async (searchDetail, index) => {
|
||||
limitRequests(async () => {
|
||||
try {
|
||||
let caseID = "";
|
||||
detailsArr.push(details);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Error processing case:", error);
|
||||
}
|
||||
};
|
||||
|
||||
switch (detailsType) {
|
||||
case "myCases":
|
||||
caseID = searchDetail.pinswg_title;
|
||||
break;
|
||||
case "myWatchedCases":
|
||||
case "mySubmittedReps":
|
||||
caseID =
|
||||
searchDetail[
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
];
|
||||
break;
|
||||
case "awaitingSubmission":
|
||||
caseID = searchDetail.ticketnumber;
|
||||
break;
|
||||
case "myRepresentations":
|
||||
caseID = searchDetail.casereference;
|
||||
break;
|
||||
default:
|
||||
caseID = searchDetail.pinswg_title;
|
||||
}
|
||||
// Use limitRequests to manage concurrency
|
||||
const promises = resultsObj.map((searchDetail) => {
|
||||
return limitRequests(() => getDetailsForCase(searchDetail));
|
||||
});
|
||||
|
||||
console.log(detailsType, " case id : ", caseID);
|
||||
// Wait for all the requests to complete
|
||||
await Promise.all(promises);
|
||||
|
||||
searchDetail.pinswg_appealcasetype != null &&
|
||||
detailsArr.push(
|
||||
getPortalModuleDetails(
|
||||
getFormCollectionByID(
|
||||
searchDetail.pinswg_appealcasetype
|
||||
).LogicalCollectionName,
|
||||
caseID
|
||||
)
|
||||
);
|
||||
} catch (error) {
|
||||
console.log("Error processing case:", error);
|
||||
}
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
let detArr = Promise.all(detailsArr);
|
||||
// console.log(detArr);
|
||||
return detArr;
|
||||
return detailsArr;
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
|
||||
Reference in New Issue
Block a user