Files
pedwfrontend/actions/services/portalDirectService.js
T

333 lines
7.8 KiB
JavaScript

import axios from "axios";
import { BASE_URL } from "../core/env";
import { consoleLogger } from "../core/logger";
import { hashAPIPath } from "../core/hash";
export const getMyCases = (loggedInUserId) => {
return axios
.get(
BASE_URL +
"/api/endpoint/getmycases_api?loggedInUserId=" +
loggedInUserId
)
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error);
});
};
export const getMyInvolvements = async (loggedInUserId) => {
try {
const res = await axios.get(
BASE_URL +
"/api/endpoint/getmyinvolvements_api?loggedInUserId=" +
loggedInUserId
);
return res.data;
} catch (error) {
consoleLogger(error);
}
};
export const getMyLPACases = (lpaid) => {
return axios
.get(BASE_URL + "/api/endpoint/getmylpacases_api?lpaid=" + lpaid)
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error);
});
};
export const getMyRepresentations = (loggedInUserId) => {
return axios
.get(
BASE_URL +
"/api/endpoint/getmyrepresentations_api?loggedInUserId=" +
loggedInUserId
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
};
export const getMyRepresentationsProxy = (loggedInUserId) => {
return axios
.get(
"/api/endpoint/getmyrepresentationsproxy_api?loggedInUserId=" +
loggedInUserId
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
};
export const getRepresentations = (incidentID) => {
return axios
.get("/api/endpoint/getrepresentations_api?incidentID=" + incidentID)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
};
export const getRepresentationsProxy = (incidentID) => {
return axios
.get(
"/api/endpoint/getrepresentationsproxy_api?incidentID=" + incidentID
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
};
export const getWatchedCases = (loggedInUserId) => {
return axios
.get(
BASE_URL +
"/api/endpoint/getwatchedcases_api?loggedInUserId=" +
loggedInUserId
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
};
export const getWatchedCasesProxy = (loggedInUserId) => {
return axios
.get(
"/api/endpoint/getwatchedcasesproxy_api?loggedInUserId=" +
loggedInUserId
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
};
export const getAwaitingSubmissionProxy = (loggedInUserId) => {
return axios
.get(
"/api/endpoint/getawaitingsubmissionproxy_api?loggedInUserId=" +
loggedInUserId
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
};
export const getAwaitingSubmission = (loggedInUserId) => {
return axios
.get(
BASE_URL +
"/api/endpoint/getawaitingsubmission_api?loggedInUserId=" +
loggedInUserId
)
.then((res) => {
return res.data;
})
.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 {
const res = await axios(config);
return res.data;
} catch (error) {
consoleLogger(error);
}
};
export const deleteMyRepresentations = (myRepresentationsID) => {
var queryUrl =
"/api/endpoint/deletemyrepresentations_api?myRepresentationsID=" +
myRepresentationsID;
var config = {
method: "delete",
url: queryUrl + hashAPIPath(queryUrl),
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"
}
};
return axios(config)
.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 axios(config)
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error);
});
};
export const deleteWatchedCases = async (watchedCaseID) => {
var queryUrl =
"/api/endpoint/deletewatchedcases_api?watchedCaseID=" + watchedCaseID;
var config = {
method: "delete",
url: queryUrl
};
try {
const res = await axios(config);
return res.data;
} catch (error) {
consoleLogger(error);
}
};
export const sendCaseCompleteMessage = async (
containerID,
caseReference,
inv
) => {
var queryUrl =
"/api/file/createappealcompletemessage_api?container=" +
containerID +
"&tempcaseref=" +
caseReference +
"&inv=" +
inv;
var config = {
method: "get",
url: queryUrl
};
return axios(config)
.then((res) => {
return res.data;
})
.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 axios(config)
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error);
});
};
export const sendRepCompleteMessage = async (
containerID,
caseReference,
fileName
) => {
var queryUrl =
"/api/file/createrepcompletemessage_api?container=" +
containerID +
"&tempcaseref=" +
caseReference +
"&repid=" +
fileName;
var config = {
method: "get",
url: queryUrl
};
return axios(config)
.then((res) => {
return res.data;
})
.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 {
const res = await axios(config);
return res.data;
} 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 {
const res = await axios(config);
return res.data;
} catch (error) {
consoleLogger(error);
}
};