Merged PR 2262: shows primary lpa and then lists additional lps below on the portal summary tab
shows primary lpa and then lists additional lps below on the portal summary tab Related work items: #22699
This commit is contained in:
@@ -32,8 +32,8 @@
|
||||
import { azureHeaders } from "../../../actions/core/headers";
|
||||
import { getSelectQuery } from "../../../actions/selectQueryTypes";
|
||||
import { getNavigationPropertyByPrimaryAttribute } from "../../../components/utils";
|
||||
import { respondError } from "../middleware/apiResponse";
|
||||
import { relayGet } from "../middleware/relayForwarding";
|
||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
||||
import { relayGetData } from "../middleware/relayForwarding";
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
const appealTypeName = req.query.appealTypeName;
|
||||
@@ -88,45 +88,50 @@ export default async function ApiProxy(req, res) {
|
||||
navigationProperty +
|
||||
"($select=ticketnumber)";
|
||||
|
||||
//" and statuscode eq 1&$count=true";
|
||||
|
||||
// queryUrl =
|
||||
// queryUrl +
|
||||
// getSelectQuery(appealTypeName) +
|
||||
// ",_" +
|
||||
// (primaryIdAttribute == "pinswg_sipscase"
|
||||
// ? "pinswg_sipscase_value"
|
||||
// : primaryIdAttribute + "s_value");
|
||||
|
||||
queryUrl = queryUrl + getSelectQuery(appealTypeName);
|
||||
|
||||
// console.log(
|
||||
// "\n==========================================\n",
|
||||
// "\nSearch Details query ",
|
||||
// "\nAppealType: " + appealTypeName,
|
||||
// "\nIncident ID: " + incidentID,
|
||||
// "\n\nQuery url: " + queryUrl,
|
||||
// "\n==========================================\n"
|
||||
// );
|
||||
const incidentQueryUrl =
|
||||
"incidents(" +
|
||||
incidentID +
|
||||
")?$select=title,ticketnumber" +
|
||||
"&$expand=pinswg_Incident_Account_AdditionalLPAs($select=name,accountnumber)" +
|
||||
"&$count=true";
|
||||
|
||||
return relayGet({
|
||||
queryUrl,
|
||||
res,
|
||||
requestOptionsBuilder: (accessToken) => azureHeaders(accessToken),
|
||||
transformData: (data) => {
|
||||
let flattened = data.value.map((r) => ({
|
||||
...r,
|
||||
ticketnumber: r[navigationProperty]?.ticketnumber || null
|
||||
}));
|
||||
try {
|
||||
const [searchResult, incidentResult] = await Promise.all([
|
||||
relayGetData({
|
||||
queryUrl,
|
||||
requestOptionsBuilder: (accessToken) =>
|
||||
azureHeaders(accessToken)
|
||||
}),
|
||||
relayGetData({
|
||||
queryUrl: incidentQueryUrl,
|
||||
requestOptionsBuilder: (accessToken) =>
|
||||
azureHeaders(accessToken)
|
||||
})
|
||||
]);
|
||||
|
||||
data.value = flattened;
|
||||
const data = searchResult.data;
|
||||
const incidentData = incidentResult.data;
|
||||
const additionalLPAs =
|
||||
incidentData?.pinswg_Incident_Account_AdditionalLPAs || [];
|
||||
|
||||
return data;
|
||||
},
|
||||
errorResponse: {
|
||||
data.value = (data.value || []).map((r) => ({
|
||||
...r,
|
||||
ticketnumber:
|
||||
r[navigationProperty]?.ticketnumber ||
|
||||
incidentData?.ticketnumber ||
|
||||
null,
|
||||
incidenttitle: incidentData?.title || null,
|
||||
additionalLPAs
|
||||
}));
|
||||
|
||||
return respondSuccess(res, data);
|
||||
} catch (error) {
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "BASIC_SEARCH_DETAILS_FETCH_FAILED",
|
||||
message: "Failed to fetch basic search details"
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
*/
|
||||
|
||||
import _ from "lodash";
|
||||
import { azureHeadersPaged } from "../../../actions/core/headers";
|
||||
import { azureHeaders, azureHeadersPaged } from "../../../actions/core/headers";
|
||||
import { getSelectQuery } from "../../../actions/selectQueryTypes";
|
||||
import { getNavigationPropertyByPrimaryAttribute } from "../../../components/utils";
|
||||
import { respondError } from "../middleware/apiResponse";
|
||||
import { relayGet } from "../middleware/relayForwarding";
|
||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
||||
import { relayGetData } from "../middleware/relayForwarding";
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
const appealTypeName = req.query.appealTypeName;
|
||||
@@ -76,13 +76,6 @@ export default async function ApiProxy(req, res) {
|
||||
primaryIdAttribute
|
||||
).NavigationProperty;
|
||||
|
||||
// "?$filter=_" +
|
||||
// (primaryIdAttribute == "pinswg_sipscase"
|
||||
// ? "pinswg_sipscase_value"
|
||||
// : primaryIdAttribute + "s_value ") +
|
||||
// " eq " +
|
||||
// incidentID +
|
||||
|
||||
let queryUrl =
|
||||
appealTypeName +
|
||||
"?$filter=" +
|
||||
@@ -92,8 +85,6 @@ export default async function ApiProxy(req, res) {
|
||||
navigationProperty +
|
||||
"($select=ticketnumber)";
|
||||
|
||||
//" and statuscode eq 1&$count=true";
|
||||
|
||||
queryUrl =
|
||||
queryUrl +
|
||||
getSelectQuery(appealTypeName) +
|
||||
@@ -102,29 +93,53 @@ export default async function ApiProxy(req, res) {
|
||||
? "pinswg_sipscase_value"
|
||||
: primaryIdAttribute + "s_value");
|
||||
|
||||
return relayGet({
|
||||
queryUrl,
|
||||
res,
|
||||
requestOptionsBuilder: (accessToken) => azureHeadersPaged(accessToken),
|
||||
transformData: (data) => {
|
||||
let flattened = data.value.map((r) => ({
|
||||
...r,
|
||||
ticketnumber: r[navigationProperty]?.ticketnumber || null
|
||||
}));
|
||||
const incidentQueryUrl =
|
||||
"incidents(" +
|
||||
req.query.incidentID +
|
||||
")?$select=title,ticketnumber" +
|
||||
"&$expand=pinswg_Incident_Account_AdditionalLPAs($select=name,accountnumber)" +
|
||||
"&$count=true";
|
||||
|
||||
data.value = flattened;
|
||||
try {
|
||||
const [searchResult, incidentResult] = await Promise.all([
|
||||
relayGetData({
|
||||
queryUrl,
|
||||
requestOptionsBuilder: (accessToken) =>
|
||||
azureHeadersPaged(accessToken)
|
||||
}),
|
||||
relayGetData({
|
||||
queryUrl: incidentQueryUrl,
|
||||
requestOptionsBuilder: (accessToken) =>
|
||||
azureHeaders(accessToken)
|
||||
})
|
||||
]);
|
||||
|
||||
if (_.has(data, "@odata.nextLink") === true) {
|
||||
const dataStr = JSON.stringify(data["@odata.nextLink"]);
|
||||
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
|
||||
}
|
||||
const data = searchResult.data;
|
||||
const incidentData = incidentResult.data;
|
||||
const additionalLPAs =
|
||||
incidentData?.pinswg_Incident_Account_AdditionalLPAs || [];
|
||||
|
||||
return data;
|
||||
},
|
||||
errorResponse: {
|
||||
data.value = (data.value || []).map((r) => ({
|
||||
...r,
|
||||
ticketnumber:
|
||||
r[navigationProperty]?.ticketnumber ||
|
||||
incidentData?.ticketnumber ||
|
||||
null,
|
||||
incidenttitle: incidentData?.title || null,
|
||||
additionalLPAs
|
||||
}));
|
||||
|
||||
if (_.has(data, "@odata.nextLink") === true) {
|
||||
const dataStr = JSON.stringify(data["@odata.nextLink"]);
|
||||
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
|
||||
}
|
||||
|
||||
return respondSuccess(res, data);
|
||||
} catch (error) {
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "BASIC_SEARCH_DETAILS_PAGED_FETCH_FAILED",
|
||||
message: "Failed to fetch paged basic search details"
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user