updated translations for dcuments lsit on case details

This commit is contained in:
2021-10-08 08:09:49 +01:00
parent b5f3432da2
commit b233f42f31
7 changed files with 71 additions and 32 deletions
+35 -22
View File
@@ -1,6 +1,7 @@
import axios from "axios";
import https from "https";
import CryptoJS from "crypto-js";
import { response } from "express";
const PROXY_RELAY_URL =
"https://" +
@@ -62,24 +63,9 @@ const getSASToken = () => {
export default async function ApiProxy(req, res) {
console.log(req.method);
var updateBody = {
"pinswg_areaofsiteinhectaresdec": 21,
"pinswg_developmentaffectsettingifalisted": false,
"pinswg_floorspaceinsquaremeters": "123123124",
"pinswg_incarelatestoca": false,
"pinswg_isfloodinganissue": true,
"pinswg_isthesitewithinanaonb": false,
"pinswg_landuse": "846040002",
"pinswg_sitewithinsssi": true,
"pinswg_sitewithinagreenbelt": false,
"pinswg_siteviewablefromroad": false,
"pinswg_typeofplanningapplication": "846040000",
};
var data = JSON.stringify(req.body);
const SASToken = getSASToken();
// console.log(SASToken);
var configNoData = {
method: req.method,
//url: PROXY_RELAY_URL + updateFormCollection + "(" + incidentId + ")",
@@ -109,17 +95,44 @@ export default async function ApiProxy(req, res) {
data: data,
};
console.log(req.url.split("/api/proxy/")[1]);
var configDocument = {
method: req.method,
url: PROXY_RELAY_URL + req.url.split("/api/proxy/")[1],
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
"Accept": "application/json",
"Prefer": 'odata.include-annotations="*",return=representation',
"Authorization": SASToken,
"Content-Type": "application/json",
},
responseType: "arraybuffer",
};
return new Promise((resolve, reject) => {
console.log(config);
axios(req.method == "GET" ? configNoData : config)
let apiPath = req.url.split("/api/proxy/")[1];
let hasDocument = apiPath.indexOf("/download") > 0 ? true : false;
axios(
req.method == "GET"
? hasDocument
? configDocument
: configNoData
: config
)
.then((response) => {
// console.log(response);
res.statusCode = 200;
res.setHeader("Content-Type", "application/json");
res.setHeader("Cache-Control", "max-age=1800000");
res.end(JSON.stringify(response.data));
console.log("response data", response.data);
if (hasDocument) {
res.setHeader("Content-Type", "text/plain");
res.end(response.data);
} else {
res.setHeader("Content-Type", "application/json");
res.setHeader("Cache-Control", "max-age=1800000");
res.end(JSON.stringify(response.data));
}
//console.log("response data", response.data);
resolve();
})
.catch((error) => {