297 lines
7.2 KiB
JavaScript
297 lines
7.2 KiB
JavaScript
import axios from "axios";
|
|
import { BASE_URL } from "../core/env";
|
|
import { consoleLogger } from "../core/logger";
|
|
import { buildHashedQueryUrl } from "../clients/relayClient";
|
|
import { getJson, requestJson } from "../clients/endpointClient";
|
|
|
|
export const getMyCases = (loggedInUserId) => {
|
|
return getJson(
|
|
BASE_URL +
|
|
"/api/endpoint/getmycases_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getMyInvolvements = async (loggedInUserId) => {
|
|
return getJson(
|
|
BASE_URL +
|
|
"/api/endpoint/getmyinvolvements_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getMyLPACases = (lpaid) => {
|
|
return getJson(
|
|
BASE_URL + "/api/endpoint/getmylpacases_api?lpaid=" + lpaid
|
|
).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getMyRepresentations = (loggedInUserId) => {
|
|
return getJson(
|
|
BASE_URL +
|
|
"/api/endpoint/getmyrepresentations_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getMyRepresentationsProxy = (loggedInUserId) => {
|
|
return getJson(
|
|
"/api/endpoint/getmyrepresentationsproxy_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getRepresentations = (incidentID) => {
|
|
return getJson(
|
|
"/api/endpoint/getrepresentations_api?incidentID=" + incidentID
|
|
).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getRepresentationsProxy = (incidentID) => {
|
|
return getJson(
|
|
"/api/endpoint/getrepresentationsproxy_api?incidentID=" + incidentID
|
|
).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getWatchedCases = (loggedInUserId) => {
|
|
return getJson(
|
|
BASE_URL +
|
|
"/api/endpoint/getwatchedcases_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getWatchedCasesProxy = (loggedInUserId) => {
|
|
return getJson(
|
|
"/api/endpoint/getwatchedcasesproxy_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getAwaitingSubmissionProxy = (loggedInUserId) => {
|
|
return getJson(
|
|
"/api/endpoint/getawaitingsubmissionproxy_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getAwaitingSubmission = (loggedInUserId) => {
|
|
return getJson(
|
|
BASE_URL +
|
|
"/api/endpoint/getawaitingsubmission_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const createWatchedCases = async (formValues) => {
|
|
var data = formValues;
|
|
var queryUrl = "/api/endpoint/createwatchedcases_api";
|
|
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: data
|
|
};
|
|
|
|
try {
|
|
return await requestJson(config);
|
|
} catch (error) {
|
|
consoleLogger(error);
|
|
}
|
|
};
|
|
|
|
export const deleteMyRepresentations = (myRepresentationsID) => {
|
|
var queryUrl =
|
|
"/api/endpoint/deletemyrepresentations_api?myRepresentationsID=" +
|
|
myRepresentationsID;
|
|
|
|
return buildHashedQueryUrl(queryUrl)
|
|
.then((signedUrl) =>
|
|
axios({
|
|
method: "delete",
|
|
url: signedUrl,
|
|
headers: {
|
|
"OData-MaxVersion": "4.0",
|
|
"OData-Version": "4.0",
|
|
"Accept": "application/json;odata.metadata=none",
|
|
"Prefer":
|
|
'odata.include-annotations="*",return=representation',
|
|
"Content-Type": "application/json"
|
|
}
|
|
})
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const deleteAwaitingSubmissions = (incidentID) => {
|
|
var queryUrl =
|
|
"/api/endpoint/deleteawaitingsubmissions_api?incidentID=" + incidentID;
|
|
|
|
var config = {
|
|
method: "delete",
|
|
url: queryUrl
|
|
};
|
|
|
|
return requestJson(config).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const deleteWatchedCases = async (watchedCaseID) => {
|
|
var queryUrl =
|
|
"/api/endpoint/deletewatchedcases_api?watchedCaseID=" + watchedCaseID;
|
|
|
|
return buildHashedQueryUrl(queryUrl)
|
|
.then((signedUrl) =>
|
|
axios({
|
|
method: "delete",
|
|
url: signedUrl
|
|
})
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const sendCaseCompleteMessage = async (
|
|
containerID,
|
|
caseReference,
|
|
inv
|
|
) => {
|
|
var hashQueryPath =
|
|
"/api/file/createappealcompletemessage_api?container=" +
|
|
containerID +
|
|
"&tempcaseref=" +
|
|
caseReference;
|
|
|
|
var queryUrl =
|
|
"/api/file/createappealcompletemessage_api?container=" +
|
|
containerID +
|
|
"&tempcaseref=" +
|
|
caseReference +
|
|
"&inv=" +
|
|
inv;
|
|
|
|
var signedQueryUrl = await buildHashedQueryUrl(hashQueryPath);
|
|
|
|
queryUrl = queryUrl + signedQueryUrl.replace(hashQueryPath, "");
|
|
|
|
var config = {
|
|
method: "get",
|
|
url: queryUrl
|
|
};
|
|
|
|
return requestJson(config).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const sendCaseCompleteMessageProxy = async (
|
|
containerID,
|
|
caseReference
|
|
) => {
|
|
var queryUrl =
|
|
"/api/file/createappealcompletemessageproxy_api?container=" +
|
|
containerID +
|
|
"&tempcaseref=" +
|
|
caseReference;
|
|
|
|
var config = {
|
|
method: "get",
|
|
url: queryUrl
|
|
};
|
|
|
|
return requestJson(config).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const sendRepCompleteMessage = async (
|
|
containerID,
|
|
caseReference,
|
|
fileName
|
|
) => {
|
|
var hashQueryPath =
|
|
"/api/file/createrepcompletemessage_api?container=" +
|
|
containerID +
|
|
"&tempcaseref=" +
|
|
caseReference +
|
|
"&repid=" +
|
|
fileName;
|
|
|
|
var queryUrl = await buildHashedQueryUrl(hashQueryPath);
|
|
|
|
var config = {
|
|
method: "get",
|
|
url: queryUrl
|
|
};
|
|
|
|
return requestJson(config).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const setRepInvolvment = async (caseid, contactid) => {
|
|
var queryUrl = "/api/file/createrepinvolvement_api";
|
|
|
|
var data = { "incidentid": caseid, "contactid": contactid };
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: data
|
|
};
|
|
|
|
try {
|
|
return await requestJson(config);
|
|
} catch (error) {
|
|
consoleLogger(error);
|
|
}
|
|
};
|
|
|
|
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 {
|
|
return await requestJson(config);
|
|
} catch (error) {
|
|
consoleLogger(error);
|
|
}
|
|
};
|