321 lines
7.6 KiB
JavaScript
321 lines
7.6 KiB
JavaScript
import { BASE_URL } from "../core/env";
|
|
import { consoleLogger } from "../core/logger";
|
|
import { buildHashedQueryUrl } from "../clients/relayClient";
|
|
import { getJson, requestJson } from "../clients/endpointClient";
|
|
import {
|
|
buildFileQuery,
|
|
withBaseUrl,
|
|
appendQuerySuffix
|
|
} from "../clients/fileRouteBuilder";
|
|
|
|
export const getMyCases = (loggedInUserId) => {
|
|
const route = buildFileQuery("/api/endpoint/getmycases_api", {
|
|
loggedInUserId
|
|
});
|
|
|
|
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getMyInvolvements = async (loggedInUserId) => {
|
|
const route = buildFileQuery("/api/endpoint/getmyinvolvements_api", {
|
|
loggedInUserId
|
|
});
|
|
|
|
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getMyLPACases = (lpaid) => {
|
|
const route = buildFileQuery("/api/endpoint/getmylpacases_api", {
|
|
lpaid
|
|
});
|
|
|
|
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getMyRepresentations = (loggedInUserId) => {
|
|
const route = buildFileQuery("/api/endpoint/getmyrepresentations_api", {
|
|
loggedInUserId
|
|
});
|
|
|
|
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getMyRepresentationsProxy = (loggedInUserId) => {
|
|
const route = buildFileQuery(
|
|
"/api/endpoint/getmyrepresentationsproxy_api",
|
|
{
|
|
loggedInUserId
|
|
}
|
|
);
|
|
|
|
return getJson(route).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getRepresentations = (incidentID) => {
|
|
const route = buildFileQuery("/api/endpoint/getrepresentations_api", {
|
|
incidentID
|
|
});
|
|
|
|
return getJson(route).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getRepresentationsProxy = (incidentID) => {
|
|
const route = buildFileQuery("/api/endpoint/getrepresentationsproxy_api", {
|
|
incidentID
|
|
});
|
|
|
|
return getJson(route).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getWatchedCases = (loggedInUserId) => {
|
|
const route = buildFileQuery("/api/endpoint/getwatchedcases_api", {
|
|
loggedInUserId
|
|
});
|
|
|
|
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getWatchedCasesProxy = (loggedInUserId) => {
|
|
const route = buildFileQuery("/api/endpoint/getwatchedcasesproxy_api", {
|
|
loggedInUserId
|
|
});
|
|
|
|
return getJson(route).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getAwaitingSubmissionProxy = (loggedInUserId) => {
|
|
const route = buildFileQuery(
|
|
"/api/endpoint/getawaitingsubmissionproxy_api",
|
|
{
|
|
loggedInUserId
|
|
}
|
|
);
|
|
|
|
return getJson(route).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getAwaitingSubmission = (loggedInUserId) => {
|
|
const route = buildFileQuery("/api/endpoint/getawaitingsubmission_api", {
|
|
loggedInUserId
|
|
});
|
|
|
|
return getJson(withBaseUrl(BASE_URL, route)).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 = buildFileQuery("/api/endpoint/deletemyrepresentations_api", {
|
|
myRepresentationsID
|
|
});
|
|
|
|
return buildHashedQueryUrl(queryUrl)
|
|
.then((signedUrl) =>
|
|
requestJson({
|
|
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"
|
|
}
|
|
})
|
|
)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const deleteAwaitingSubmissions = (incidentID) => {
|
|
var queryUrl = buildFileQuery(
|
|
"/api/endpoint/deleteawaitingsubmissions_api",
|
|
{
|
|
incidentID
|
|
}
|
|
);
|
|
|
|
var config = {
|
|
method: "delete",
|
|
url: queryUrl
|
|
};
|
|
|
|
return requestJson(config).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const deleteWatchedCases = async (watchedCaseID) => {
|
|
var queryUrl = buildFileQuery("/api/endpoint/deletewatchedcases_api", {
|
|
watchedCaseID
|
|
});
|
|
|
|
return buildHashedQueryUrl(queryUrl)
|
|
.then((signedUrl) =>
|
|
requestJson({
|
|
method: "delete",
|
|
url: signedUrl
|
|
})
|
|
)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const sendCaseCompleteMessage = async (
|
|
containerID,
|
|
caseReference,
|
|
inv
|
|
) => {
|
|
var hashQueryPath = buildFileQuery(
|
|
"/api/file/createappealcompletemessage_api",
|
|
{
|
|
container: containerID,
|
|
tempcaseref: caseReference
|
|
}
|
|
);
|
|
|
|
var queryUrl = buildFileQuery("/api/file/createappealcompletemessage_api", {
|
|
container: containerID,
|
|
tempcaseref: caseReference,
|
|
inv
|
|
});
|
|
|
|
var signedQueryUrl = await buildHashedQueryUrl(hashQueryPath);
|
|
|
|
queryUrl = appendQuerySuffix(
|
|
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 = buildFileQuery(
|
|
"/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 = buildFileQuery(
|
|
"/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);
|
|
}
|
|
};
|