refactor(portal): normalize route composition with fileRouteBuilder
This commit is contained in:
@@ -2,104 +2,124 @@ 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) => {
|
||||
return getJson(
|
||||
BASE_URL +
|
||||
"/api/endpoint/getmycases_api?loggedInUserId=" +
|
||||
loggedInUserId
|
||||
).catch((error) => {
|
||||
const route = buildFileQuery("/api/endpoint/getmycases_api", {
|
||||
loggedInUserId
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getMyInvolvements = async (loggedInUserId) => {
|
||||
return getJson(
|
||||
BASE_URL +
|
||||
"/api/endpoint/getmyinvolvements_api?loggedInUserId=" +
|
||||
loggedInUserId
|
||||
).catch((error) => {
|
||||
const route = buildFileQuery("/api/endpoint/getmyinvolvements_api", {
|
||||
loggedInUserId
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getMyLPACases = (lpaid) => {
|
||||
return getJson(
|
||||
BASE_URL + "/api/endpoint/getmylpacases_api?lpaid=" + lpaid
|
||||
).catch((error) => {
|
||||
const route = buildFileQuery("/api/endpoint/getmylpacases_api", {
|
||||
lpaid
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getMyRepresentations = (loggedInUserId) => {
|
||||
return getJson(
|
||||
BASE_URL +
|
||||
"/api/endpoint/getmyrepresentations_api?loggedInUserId=" +
|
||||
loggedInUserId
|
||||
).catch((error) => {
|
||||
const route = buildFileQuery("/api/endpoint/getmyrepresentations_api", {
|
||||
loggedInUserId
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getMyRepresentationsProxy = (loggedInUserId) => {
|
||||
return getJson(
|
||||
"/api/endpoint/getmyrepresentationsproxy_api?loggedInUserId=" +
|
||||
const route = buildFileQuery(
|
||||
"/api/endpoint/getmyrepresentationsproxy_api",
|
||||
{
|
||||
loggedInUserId
|
||||
).catch((error) => {
|
||||
}
|
||||
);
|
||||
|
||||
return getJson(route).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getRepresentations = (incidentID) => {
|
||||
return getJson(
|
||||
"/api/endpoint/getrepresentations_api?incidentID=" + incidentID
|
||||
).catch((error) => {
|
||||
const route = buildFileQuery("/api/endpoint/getrepresentations_api", {
|
||||
incidentID
|
||||
});
|
||||
|
||||
return getJson(route).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getRepresentationsProxy = (incidentID) => {
|
||||
return getJson(
|
||||
"/api/endpoint/getrepresentationsproxy_api?incidentID=" + incidentID
|
||||
).catch((error) => {
|
||||
const route = buildFileQuery("/api/endpoint/getrepresentationsproxy_api", {
|
||||
incidentID
|
||||
});
|
||||
|
||||
return getJson(route).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getWatchedCases = (loggedInUserId) => {
|
||||
return getJson(
|
||||
BASE_URL +
|
||||
"/api/endpoint/getwatchedcases_api?loggedInUserId=" +
|
||||
loggedInUserId
|
||||
).catch((error) => {
|
||||
const route = buildFileQuery("/api/endpoint/getwatchedcases_api", {
|
||||
loggedInUserId
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getWatchedCasesProxy = (loggedInUserId) => {
|
||||
return getJson(
|
||||
"/api/endpoint/getwatchedcasesproxy_api?loggedInUserId=" +
|
||||
loggedInUserId
|
||||
).catch((error) => {
|
||||
const route = buildFileQuery("/api/endpoint/getwatchedcasesproxy_api", {
|
||||
loggedInUserId
|
||||
});
|
||||
|
||||
return getJson(route).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getAwaitingSubmissionProxy = (loggedInUserId) => {
|
||||
return getJson(
|
||||
"/api/endpoint/getawaitingsubmissionproxy_api?loggedInUserId=" +
|
||||
const route = buildFileQuery(
|
||||
"/api/endpoint/getawaitingsubmissionproxy_api",
|
||||
{
|
||||
loggedInUserId
|
||||
).catch((error) => {
|
||||
}
|
||||
);
|
||||
|
||||
return getJson(route).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getAwaitingSubmission = (loggedInUserId) => {
|
||||
return getJson(
|
||||
BASE_URL +
|
||||
"/api/endpoint/getawaitingsubmission_api?loggedInUserId=" +
|
||||
loggedInUserId
|
||||
).catch((error) => {
|
||||
const route = buildFileQuery("/api/endpoint/getawaitingsubmission_api", {
|
||||
loggedInUserId
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
@@ -122,9 +142,9 @@ export const createWatchedCases = async (formValues) => {
|
||||
};
|
||||
|
||||
export const deleteMyRepresentations = (myRepresentationsID) => {
|
||||
var queryUrl =
|
||||
"/api/endpoint/deletemyrepresentations_api?myRepresentationsID=" +
|
||||
myRepresentationsID;
|
||||
var queryUrl = buildFileQuery("/api/endpoint/deletemyrepresentations_api", {
|
||||
myRepresentationsID
|
||||
});
|
||||
|
||||
return buildHashedQueryUrl(queryUrl)
|
||||
.then((signedUrl) =>
|
||||
@@ -147,8 +167,12 @@ export const deleteMyRepresentations = (myRepresentationsID) => {
|
||||
};
|
||||
|
||||
export const deleteAwaitingSubmissions = (incidentID) => {
|
||||
var queryUrl =
|
||||
"/api/endpoint/deleteawaitingsubmissions_api?incidentID=" + incidentID;
|
||||
var queryUrl = buildFileQuery(
|
||||
"/api/endpoint/deleteawaitingsubmissions_api",
|
||||
{
|
||||
incidentID
|
||||
}
|
||||
);
|
||||
|
||||
var config = {
|
||||
method: "delete",
|
||||
@@ -161,8 +185,9 @@ export const deleteAwaitingSubmissions = (incidentID) => {
|
||||
};
|
||||
|
||||
export const deleteWatchedCases = async (watchedCaseID) => {
|
||||
var queryUrl =
|
||||
"/api/endpoint/deletewatchedcases_api?watchedCaseID=" + watchedCaseID;
|
||||
var queryUrl = buildFileQuery("/api/endpoint/deletewatchedcases_api", {
|
||||
watchedCaseID
|
||||
});
|
||||
|
||||
return buildHashedQueryUrl(queryUrl)
|
||||
.then((signedUrl) =>
|
||||
@@ -181,23 +206,26 @@ export const sendCaseCompleteMessage = async (
|
||||
caseReference,
|
||||
inv
|
||||
) => {
|
||||
var hashQueryPath =
|
||||
"/api/file/createappealcompletemessage_api?container=" +
|
||||
containerID +
|
||||
"&tempcaseref=" +
|
||||
caseReference;
|
||||
var hashQueryPath = buildFileQuery(
|
||||
"/api/file/createappealcompletemessage_api",
|
||||
{
|
||||
container: containerID,
|
||||
tempcaseref: caseReference
|
||||
}
|
||||
);
|
||||
|
||||
var queryUrl =
|
||||
"/api/file/createappealcompletemessage_api?container=" +
|
||||
containerID +
|
||||
"&tempcaseref=" +
|
||||
caseReference +
|
||||
"&inv=" +
|
||||
inv;
|
||||
var queryUrl = buildFileQuery("/api/file/createappealcompletemessage_api", {
|
||||
container: containerID,
|
||||
tempcaseref: caseReference,
|
||||
inv
|
||||
});
|
||||
|
||||
var signedQueryUrl = await buildHashedQueryUrl(hashQueryPath);
|
||||
|
||||
queryUrl = queryUrl + signedQueryUrl.replace(hashQueryPath, "");
|
||||
queryUrl = appendQuerySuffix(
|
||||
queryUrl,
|
||||
signedQueryUrl.replace(hashQueryPath, "")
|
||||
);
|
||||
|
||||
var config = {
|
||||
method: "get",
|
||||
@@ -213,11 +241,13 @@ export const sendCaseCompleteMessageProxy = async (
|
||||
containerID,
|
||||
caseReference
|
||||
) => {
|
||||
var queryUrl =
|
||||
"/api/file/createappealcompletemessageproxy_api?container=" +
|
||||
containerID +
|
||||
"&tempcaseref=" +
|
||||
caseReference;
|
||||
var queryUrl = buildFileQuery(
|
||||
"/api/file/createappealcompletemessageproxy_api",
|
||||
{
|
||||
container: containerID,
|
||||
tempcaseref: caseReference
|
||||
}
|
||||
);
|
||||
|
||||
var config = {
|
||||
method: "get",
|
||||
@@ -234,13 +264,14 @@ export const sendRepCompleteMessage = async (
|
||||
caseReference,
|
||||
fileName
|
||||
) => {
|
||||
var hashQueryPath =
|
||||
"/api/file/createrepcompletemessage_api?container=" +
|
||||
containerID +
|
||||
"&tempcaseref=" +
|
||||
caseReference +
|
||||
"&repid=" +
|
||||
fileName;
|
||||
var hashQueryPath = buildFileQuery(
|
||||
"/api/file/createrepcompletemessage_api",
|
||||
{
|
||||
container: containerID,
|
||||
tempcaseref: caseReference,
|
||||
repid: fileName
|
||||
}
|
||||
);
|
||||
|
||||
var queryUrl = await buildHashedQueryUrl(hashQueryPath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user