TASK22224: modernize involvement and updatecase handlers
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import { getToken } from "../../../actions/core/token";
|
||||
import { hashAPIPath } from "../../../actions/core/hash";
|
||||
@@ -10,12 +9,12 @@ const WEBAPI_URL =
|
||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
var data = JSON.stringify(req.body);
|
||||
var appealObj = req.query.appealObj;
|
||||
var incidentID = req.query.incident;
|
||||
const data = JSON.stringify(req.body);
|
||||
const appealObj = req.query.appealObj;
|
||||
const incidentID = req.query.incident;
|
||||
|
||||
var updateFormCollection = req.query.updateFormCollection;
|
||||
var queryUrl = updateFormCollection + "(" + appealObj + ")";
|
||||
const updateFormCollection = req.query.updateFormCollection;
|
||||
const queryUrl = updateFormCollection + "(" + appealObj + ")";
|
||||
|
||||
if (
|
||||
typeof updateFormCollection === "undefined" ||
|
||||
@@ -35,9 +34,9 @@ export default async function ApiProxy(req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
var token = await getToken();
|
||||
const token = await getToken();
|
||||
|
||||
var config = {
|
||||
const config = {
|
||||
method: "patch",
|
||||
url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
headers: {
|
||||
@@ -53,16 +52,15 @@ export default async function ApiProxy(req, res) {
|
||||
|
||||
//console.log("update case:", data);
|
||||
|
||||
return axios(config)
|
||||
.then(({ data }) => {
|
||||
return respondSuccess(res, data);
|
||||
})
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "UPDATE_CASE_FAILED",
|
||||
message: "Failed to update case"
|
||||
});
|
||||
try {
|
||||
const { data: responseData } = await axios(config);
|
||||
return respondSuccess(res, responseData);
|
||||
} catch (error) {
|
||||
consoleLogger(error);
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "UPDATE_CASE_FAILED",
|
||||
message: "Failed to update case"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user