Merged PR 1272: added in debug and async some calls

added in debug and async some calls

Related work items: #12609
This commit is contained in:
Robert Bond
2024-11-01 14:34:56 +00:00
5 changed files with 132 additions and 9 deletions
+18
View File
@@ -1942,6 +1942,24 @@ export const setRepInvolvment = async (caseid, contactid) => {
}
};
export const setCaseInvolvment = async (caseid, contactid) => {
var queryUrl = "/api/file/createrepinvolvement_api";
var data = { "incidentid": caseid, "contactid": contactid };
var config = {
method: "post",
url: queryUrl,
data: data,
};
try {
const res = await axios(config);
return res.data;
} catch (error) {
consoleLogger(error);
}
};
export const getAddressSearch = async (searchString) => {
const params = new URLSearchParams(searchString);
const str = params.toString();
+1 -1
View File
@@ -148,7 +148,7 @@ const CaseSummary = (props) => {
: props[currentType];
let setCaseDetailsObj =
currentType == "directResultsObj"
? props.searchDetailsObj
? props.searchResultsObj.searchDetailsObj
: props[currentType + "Details"];
var casesObj = {};
+25 -6
View File
@@ -69,11 +69,22 @@ export const getRadioLabel = (data, radiotListName, radioListID) => {
* Get the details of a case from the appeal type
* @param object searchResultsObj
*/
export const getSearchDetails = (searchResultsObj) => {
export const getSearchDetails = async (searchResultsObj) => {
let detailsArr = [];
searchResultsObj = searchResultsObj.value;
const detailsObj = searchResultsObj.map((searchDetail, index) => {
let formMeta = getFormCollectionByID(
searchDetail.pinswg_appealcasetype
);
console.log(
"------------------- Details: ",
formMeta.LogicalCollectionName,
searchDetail.title,
formMeta.PrimaryIdAttribute,
searchDetail.incidentid
);
if (searchDetail.pinswg_appealcasetype == null) {
detailsArr.push(
getBasicSearchDetails(
@@ -81,22 +92,30 @@ export const getSearchDetails = (searchResultsObj) => {
searchDetail.title,
"pinswg_dnsid",
searchDetail.incidentid
)
) || {
"@odata.count": 1,
"value": [{ "title": searchDetail.title }],
}
);
} else {
let formMeta = getFormCollectionByID(
searchDetail.pinswg_appealcasetype
);
detailsArr.push(
getBasicSearchDetails(
formMeta.LogicalCollectionName,
searchDetail.title,
formMeta.PrimaryIdAttribute,
searchDetail.incidentid
)
) || {
"@odata.count": 1,
"value": [{ "title": searchDetail.title }],
}
);
}
});
// Promise.all(detailsArr).then((data) => {
// console.log(data);
// console.log(detailsArr);
// return data;
// });
return Promise.all(detailsArr);
};
+12 -2
View File
@@ -117,10 +117,20 @@ export const getServerSideProps = wrapper.getServerSideProps(
(store) =>
async ({ query, req, res }) => {
console.log("query-", query);
//console.log("search array:", Object.entries(query));
console.log("search array:", Object.entries(query));
const searchResultsObj = await getAdvancedSearch(query);
const searchDetailsObj = await getSearchDetails(searchResultsObj);
console.log(
"=============================== Advanced Search results:",
searchResultsObj
);
const searchDetailsObj =
(await getSearchDetails(searchResultsObj)) || null;
console.log(
"=============================== Advanced Search results details:",
searchDetailsObj
);
const showLoginCheck = process.env.SHOWLOGIN || false;
const showReps = process.env.SHOWREPRESENTATIONS || false;
store.dispatch(setShowReps(showReps, showLoginCheck));
@@ -0,0 +1,76 @@
/**
* @swagger
* /api/endpoint/createmywatchedcases_api:
* post:
* tags: [Portal,Case]
* summary: Phase 2
* description: Create my watched cases
* responses:
* 200:
* description: Success
*/
import axios from "axios";
import CryptoJS from "crypto-js";
import { consoleLogger, getToken } from "../../../actions";
const WORDKEY = process.env.HASHKEY;
const WEBAPI_URL =
process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
const hashAPIPath = (queryPath) => {
var hashlink = CryptoJS.HmacSHA256(
queryPath,
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString(CryptoJS.enc.Hex);
//return "&hash=" + hashlink;
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) {
var token = await getToken();
var contactid = req.body.contactid;
var queryUrl =
"incidents(" +
req.body.incidentid +
")/pinswg_incident_contact_case_involvement/$ref";
console.log(req.body, queryUrl);
var crmUrl = "https://" + process.env.CRMURL;
var data = {
"@odata.id": crmUrl + "/api/data/v8.2/contacts(" + contactid + ")",
};
var config = {
method: "post",
url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
"Accept": "application/json",
"If-None-Match": "null",
"Prefer": 'odata.include-annotations="*",return=representation',
"Authorization": "Bearer " + token.access_token,
"Content-Type": "application/json",
},
data: data,
};
return axios(config)
.then(({ data }) => {
res.status(200).json(data);
})
.catch((error) => {
return error.status == 412
? res.status(200).json({ "record": "exists" })
: (consoleLogger(Object.assign(error, data)),
res.status(400).json(error));
});
}