rep defect 17

This commit is contained in:
2025-01-03 07:58:01 +00:00
parent 5e1ffd3067
commit b79e21c419
+21 -12
View File
@@ -51,6 +51,7 @@ import {
setWatchedCases,
setWatchedCasesDetails,
} from "../../store/watchedCases/action";
import pLimit from "p-limit";
const Home = (props) => {
const {
@@ -374,12 +375,14 @@ export const getServerSideProps = wrapper.getServerSideProps(
const getDetails = async (resultsObj, detailsType) => {
let detailsArr = [];
const limitRequests = pLimit(5); // Limit to 5 concurrent requests
resultsObj =
detailsType == "mySubmittedReps" ? resultsObj : resultsObj.value;
if (detailsType == "myRepresentations") {
const repsObj = resultsObj.map((searchDetail, index) => {
limitRequests(async () => {
resultsObj.map((searchDetail, index) => {
detailsArr.push(
getCase(searchDetail["incidentID"])
.then(async (data) => {
@@ -409,8 +412,9 @@ const getDetails = async (resultsObj, detailsType) => {
caseID = data.pinswg_title;
}
return await getPortalModuleDetails(
getFormCollectionByID(data.pinswg_appealcasetype)
.LogicalCollectionName,
getFormCollectionByID(
data.pinswg_appealcasetype
).LogicalCollectionName,
caseID
).catch((error) => {
console.log(
@@ -427,9 +431,13 @@ const getDetails = async (resultsObj, detailsType) => {
})
);
});
});
}
//debugger;
const detailsObj = resultsObj.map(async (searchDetail, index) => {
await Promise.all(
resultsObj.map(async (searchDetail, index) => {
limitRequests(async () => {
try {
let caseID = "";
switch (detailsType) {
@@ -457,18 +465,19 @@ const getDetails = async (resultsObj, detailsType) => {
searchDetail.pinswg_appealcasetype != null &&
detailsArr.push(
await getPortalModuleDetails(
getFormCollectionByID(searchDetail.pinswg_appealcasetype)
.LogicalCollectionName,
getPortalModuleDetails(
getFormCollectionByID(
searchDetail.pinswg_appealcasetype
).LogicalCollectionName,
caseID
// detailsType != "myWatchedCases"
// ? searchDetail.ticketnumber
// : searchDetail[
// "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
// ]
)
);
} catch (error) {
console.log("Error processing case:", error);
}
});
})
);
let detArr = Promise.all(detailsArr);
// console.log(detArr);