rep defect 17
This commit is contained in:
+21
-12
@@ -51,6 +51,7 @@ import {
|
|||||||
setWatchedCases,
|
setWatchedCases,
|
||||||
setWatchedCasesDetails,
|
setWatchedCasesDetails,
|
||||||
} from "../../store/watchedCases/action";
|
} from "../../store/watchedCases/action";
|
||||||
|
import pLimit from "p-limit";
|
||||||
|
|
||||||
const Home = (props) => {
|
const Home = (props) => {
|
||||||
const {
|
const {
|
||||||
@@ -374,12 +375,14 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
|
|
||||||
const getDetails = async (resultsObj, detailsType) => {
|
const getDetails = async (resultsObj, detailsType) => {
|
||||||
let detailsArr = [];
|
let detailsArr = [];
|
||||||
|
const limitRequests = pLimit(5); // Limit to 5 concurrent requests
|
||||||
|
|
||||||
resultsObj =
|
resultsObj =
|
||||||
detailsType == "mySubmittedReps" ? resultsObj : resultsObj.value;
|
detailsType == "mySubmittedReps" ? resultsObj : resultsObj.value;
|
||||||
|
|
||||||
if (detailsType == "myRepresentations") {
|
if (detailsType == "myRepresentations") {
|
||||||
const repsObj = resultsObj.map((searchDetail, index) => {
|
limitRequests(async () => {
|
||||||
|
resultsObj.map((searchDetail, index) => {
|
||||||
detailsArr.push(
|
detailsArr.push(
|
||||||
getCase(searchDetail["incidentID"])
|
getCase(searchDetail["incidentID"])
|
||||||
.then(async (data) => {
|
.then(async (data) => {
|
||||||
@@ -409,8 +412,9 @@ const getDetails = async (resultsObj, detailsType) => {
|
|||||||
caseID = data.pinswg_title;
|
caseID = data.pinswg_title;
|
||||||
}
|
}
|
||||||
return await getPortalModuleDetails(
|
return await getPortalModuleDetails(
|
||||||
getFormCollectionByID(data.pinswg_appealcasetype)
|
getFormCollectionByID(
|
||||||
.LogicalCollectionName,
|
data.pinswg_appealcasetype
|
||||||
|
).LogicalCollectionName,
|
||||||
caseID
|
caseID
|
||||||
).catch((error) => {
|
).catch((error) => {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -427,9 +431,13 @@ const getDetails = async (resultsObj, detailsType) => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
//debugger;
|
//debugger;
|
||||||
const detailsObj = resultsObj.map(async (searchDetail, index) => {
|
await Promise.all(
|
||||||
|
resultsObj.map(async (searchDetail, index) => {
|
||||||
|
limitRequests(async () => {
|
||||||
|
try {
|
||||||
let caseID = "";
|
let caseID = "";
|
||||||
|
|
||||||
switch (detailsType) {
|
switch (detailsType) {
|
||||||
@@ -457,18 +465,19 @@ const getDetails = async (resultsObj, detailsType) => {
|
|||||||
|
|
||||||
searchDetail.pinswg_appealcasetype != null &&
|
searchDetail.pinswg_appealcasetype != null &&
|
||||||
detailsArr.push(
|
detailsArr.push(
|
||||||
await getPortalModuleDetails(
|
getPortalModuleDetails(
|
||||||
getFormCollectionByID(searchDetail.pinswg_appealcasetype)
|
getFormCollectionByID(
|
||||||
.LogicalCollectionName,
|
searchDetail.pinswg_appealcasetype
|
||||||
|
).LogicalCollectionName,
|
||||||
caseID
|
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);
|
let detArr = Promise.all(detailsArr);
|
||||||
// console.log(detArr);
|
// console.log(detArr);
|
||||||
|
|||||||
Reference in New Issue
Block a user