update proxy for get - update appeal record data
This commit is contained in:
+48
-38
@@ -137,8 +137,8 @@ export const getBasicSearchDetails = (appealType, caseReference) => {
|
||||
};
|
||||
|
||||
export const getFormData = (whichForm) => {
|
||||
console.log("got to axios", whichForm);
|
||||
console.log("api_root: ", BASE_URL);
|
||||
//console.log("got to axios", whichForm);
|
||||
//console.log("api_root: ", BASE_URL);
|
||||
return axios
|
||||
.get(
|
||||
WEBAPI_URL +
|
||||
@@ -299,7 +299,7 @@ export const getAppealTypeDetail = (caseReference, appealcasetype) => {
|
||||
//https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/pinswg_planningappeals78s?$filter=pinswg_name eq 'CAS-00015-L7J9H1'
|
||||
|
||||
export const getLPA = () => {
|
||||
console.log("api_root: ", BASE_URL);
|
||||
// console.log("api_root: ", BASE_URL);
|
||||
return axios
|
||||
.get(WEBAPI_URL + "accounts?$count=true&$select=name", azureHeaders)
|
||||
.then((res) => res.data)
|
||||
@@ -323,6 +323,32 @@ export const getPersonalAccount = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getAppealID = (
|
||||
caseReference,
|
||||
updateFormCollection,
|
||||
primaryAttribute
|
||||
) => {
|
||||
const weburl =
|
||||
"/api/proxy/" +
|
||||
updateFormCollection +
|
||||
"?$count=true&$select=_" +
|
||||
primaryAttribute +
|
||||
"s_value&$filter=pinswg_name eq '" +
|
||||
caseReference +
|
||||
"'";
|
||||
|
||||
console.log("proxy url", weburl);
|
||||
return axios
|
||||
.get(weburl, azureHeaders)
|
||||
.then((res) => {
|
||||
var appealID = res.data.value[0][primaryAttribute];
|
||||
return appealID;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("thi serror", error);
|
||||
});
|
||||
};
|
||||
|
||||
export const createCase = (appealTypeId) => {
|
||||
appealTypeId = parseInt(appealTypeId);
|
||||
var data = JSON.stringify({
|
||||
@@ -345,7 +371,7 @@ export const createCase = (appealTypeId) => {
|
||||
},
|
||||
data: data,
|
||||
};
|
||||
console.log(config);
|
||||
// console.log(config);
|
||||
return axios(config)
|
||||
.then((res) => {
|
||||
// console.log("posted ", res.data);
|
||||
@@ -356,13 +382,27 @@ export const createCase = (appealTypeId) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const updateCase = (incidentId, updateBody, updateFormCollection) => {
|
||||
export const updateCase = async (
|
||||
incidentId,
|
||||
updateBody,
|
||||
updateFormCollection,
|
||||
primaryAttribute,
|
||||
caseReference
|
||||
) => {
|
||||
var data = JSON.stringify(updateBody);
|
||||
|
||||
var appealObj = await getAppealID(
|
||||
caseReference,
|
||||
updateFormCollection,
|
||||
primaryAttribute
|
||||
);
|
||||
|
||||
console.log("appeal obj ", appealObj);
|
||||
|
||||
var config = {
|
||||
method: "patch",
|
||||
//url: WEBAPI_URL + updateFormCollection + "(" + incidentId + ")",
|
||||
url: "/api/proxy/" + updateFormCollection + "(" + incidentId + ")",
|
||||
url: "/api/proxy/" + updateFormCollection + "(" + appealObj + ")",
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
@@ -373,7 +413,8 @@ export const updateCase = (incidentId, updateBody, updateFormCollection) => {
|
||||
},
|
||||
data: data,
|
||||
};
|
||||
// console.log(config);
|
||||
|
||||
console.log(config);
|
||||
return axios(config)
|
||||
.then((res) => {
|
||||
console.log("patched ", res.data);
|
||||
@@ -384,37 +425,6 @@ export const updateCase = (incidentId, updateBody, updateFormCollection) => {
|
||||
});
|
||||
};
|
||||
|
||||
// //jquery version to get case number from an lpa and an appeal type
|
||||
// var entity = {};
|
||||
// entity.caseorigincode = 3;
|
||||
// entity["customerid_account@odata.bind"] = "/accounts(c75f6f84-49da-eb11-aabd-00224800d1bd)";
|
||||
// entity.pinswg_appealcasetype = 846040004;
|
||||
|
||||
// $.ajax({
|
||||
// type: "POST",
|
||||
// contentType: "application/json; charset=utf-8",
|
||||
// datatype: "json",
|
||||
// url: Xrm.Page.context.getClientUrl() + "/api/data/v8.2/incidents",
|
||||
// data: JSON.stringify(entity),
|
||||
// beforeSend: function(XMLHttpRequest) {
|
||||
// XMLHttpRequest.setRequestHeader("OData-MaxVersion", "4.0");
|
||||
// XMLHttpRequest.setRequestHeader("OData-Version", "4.0");
|
||||
// XMLHttpRequest.setRequestHeader("Accept", "application/json");
|
||||
// XMLHttpRequest.setRequestHeader("Prefer", "odata.include-annotations=\"*\",return=representation");
|
||||
// },
|
||||
// async: true,
|
||||
// success: function(data, textStatus, xhr) {
|
||||
// var uri = xhr.getResponseHeader("OData-EntityId");
|
||||
// var regExp = /\(([^)]+)\)/;
|
||||
// var matches = regExp.exec(uri);
|
||||
// var newEntityId = matches[1];
|
||||
// //Handle returned attributes
|
||||
// },
|
||||
// error: function(xhr, textStatus, errorThrown) {
|
||||
// Xrm.Utility.alertDialog(textStatus + " " + errorThrown);
|
||||
// }
|
||||
// });
|
||||
|
||||
export const getMyCases = () => {
|
||||
return (
|
||||
axios
|
||||
|
||||
Reference in New Issue
Block a user