updated serching to reduce CRM calls for performance and stability
This commit is contained in:
+22
-15
@@ -532,23 +532,30 @@ export const getBasicSearchDetailsPaged = async (
|
||||
appealTypeName,
|
||||
caseReference,
|
||||
primaryIdAttribute,
|
||||
incidentID
|
||||
incidentIDs
|
||||
) => {
|
||||
//console.log("check appealtype:", appealType, caseReference);
|
||||
if (!incidentIDs || incidentIDs.length === 0) return [];
|
||||
|
||||
return axios
|
||||
.get(
|
||||
"/api/endpoint/getbasicsearchdetailspaged_api?appealTypeName=" +
|
||||
appealTypeName +
|
||||
"&primaryIdAttribute=" +
|
||||
primaryIdAttribute +
|
||||
"&incidentID=" +
|
||||
incidentID
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
// Build OData filter correctly
|
||||
const filter = incidentIDs
|
||||
.map((id) => `_${primaryIdAttribute}s_value eq ${id}`)
|
||||
.join(" or ");
|
||||
|
||||
const url = `/api/endpoint/getbasicsearchdetailspaged_api?appealTypeName=${appealTypeName}&primaryIdAttribute=${primaryIdAttribute}&incidentID=${encodeURIComponent(
|
||||
filter
|
||||
)}`;
|
||||
|
||||
// console.log(
|
||||
// `Fetching ${incidentIDs.length} incidents for appeal type: ${appealTypeName}`
|
||||
// );
|
||||
|
||||
try {
|
||||
const res = await axios.get(url);
|
||||
return res.data.value || []; // ensure returning an array
|
||||
} catch (error) {
|
||||
consoleLogger(error);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
export const getSearchDocumentDetails = (incidentID) => {
|
||||
|
||||
Reference in New Issue
Block a user