911 lines
23 KiB
JavaScript
911 lines
23 KiB
JavaScript
import axios from "axios";
|
|
import https from "https";
|
|
import CryptoJS from "crypto-js";
|
|
import HmacSHA256 from "crypto-js/hmac-sha256";
|
|
|
|
let BASE_URL;
|
|
const port = parseInt(process.env.PORT, 10) || 3000;
|
|
|
|
if (process.browser) {
|
|
BASE_URL = window.apiRoot;
|
|
} else {
|
|
BASE_URL = process.env.API_ROOT || `http://localhost:${port}`;
|
|
}
|
|
const WORDKEY = process.env.HASHKEY;
|
|
|
|
const cache = {};
|
|
const API_PATH = "/api/data/v8.2/";
|
|
|
|
const accessTokenEndpoint = process.env.ACCESS_TOKEN_ENDPOINT;
|
|
const tenantId = process.env.TENANT;
|
|
|
|
const WEBAPI_URL =
|
|
process.env.RELAY_ROOT ||
|
|
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
|
|
|
const agent = new https.Agent({
|
|
rejectUnauthorized: false,
|
|
});
|
|
|
|
export const getToken = () => {
|
|
return axios
|
|
.post(
|
|
`${accessTokenEndpoint}${tenantId}/oauth2/v2.0/token`,
|
|
tokenBody,
|
|
tokenConfig
|
|
)
|
|
.then((res) => res.data)
|
|
.then((data) => {
|
|
cache.tokenResponse = data;
|
|
return data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("error :", error.response);
|
|
// return error;
|
|
});
|
|
};
|
|
|
|
const tokenBody =
|
|
"grant_type=" +
|
|
process.env.GRANT_TYPE +
|
|
"&client_id=" +
|
|
process.env.CLIENT_ID +
|
|
"&client_secret=" +
|
|
process.env.CLIENT_SECRET +
|
|
"&scope=" +
|
|
"https://" +
|
|
process.env.RELAYURI +
|
|
"/.default";
|
|
|
|
const tokenConfig = {
|
|
headers: {
|
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
"Cache-Control": "no-cache",
|
|
},
|
|
};
|
|
|
|
export const azureHeaders = (access_token) => {
|
|
return {
|
|
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",
|
|
"Authorization": "Bearer " + access_token,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const azureHeadersPaged = (access_token) => {
|
|
return {
|
|
headers: {
|
|
"OData-MaxVersion": "4.0",
|
|
"OData-Version": "4.0",
|
|
"Accept": "application/json;odata.metadata=none",
|
|
"Prefer":
|
|
'odata.include-annotations="*",return=representation, odata.maxpagesize=10',
|
|
"Content-Type": "application/json",
|
|
"Authorization": "Bearer " + access_token,
|
|
},
|
|
};
|
|
};
|
|
export const azureHeadersPagedCustom = (access_token, showNumberOfRecords) => {
|
|
return {
|
|
headers: {
|
|
"OData-MaxVersion": "4.0",
|
|
"OData-Version": "4.0",
|
|
"Accept": "application/json;odata.metadata=none",
|
|
"Prefer":
|
|
'odata.include-annotations="*",return=representation, odata.maxpagesize=' +
|
|
showNumberOfRecords,
|
|
"Content-Type": "application/json",
|
|
"Authorization": "Bearer " + access_token,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const hashAPIPath = (queryPath) => {
|
|
var hashlink = CryptoJS.HmacSHA256(
|
|
queryPath,
|
|
CryptoJS.enc.Hex.parse(WORDKEY)
|
|
);
|
|
hashlink = hashlink.toString(CryptoJS.enc.Hex);
|
|
|
|
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
|
|
};
|
|
|
|
export const hashString = (stringToHash) => {
|
|
console.log("string to hash", stringToHash);
|
|
let hashedStr = CryptoJS.AES.encrypt(stringToHash, "pedw");
|
|
console.log("hashed String", hashedStr.toString());
|
|
return hashedStr.toString();
|
|
};
|
|
|
|
export const dehashString = (stringToDeHash) => {
|
|
console.log("string to dehash", stringToDeHash);
|
|
let dehashedStr = CryptoJS.AES.decrypt(decodeURI(stringToDeHash), "pedw");
|
|
console.log("dehshed string:", dehashedStr.toString(CryptoJS.enc.Utf8));
|
|
return dehashedStr.toString(CryptoJS.enc.Utf8);
|
|
};
|
|
|
|
export const getBasicSearch = (searchString) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getbasicsearch_api?searchString=" +
|
|
searchString
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getBasicDNSURLSearch = (searchString) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getbasicdnsurlsearch_api?searchString=" +
|
|
searchString
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getBasicSearchPaged = (
|
|
searchString,
|
|
pageNumber,
|
|
orderBy,
|
|
fieldSort,
|
|
showNumberOfRecords
|
|
) => {
|
|
//console.log(queryUrl);
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getbasicsearchpaged_api?searchString=" +
|
|
searchString +
|
|
"&pageNumber=" +
|
|
pageNumber +
|
|
"&orderby=" +
|
|
orderBy +
|
|
"&fieldSort=" +
|
|
fieldSort +
|
|
"&showNumberOfRecords=" +
|
|
showNumberOfRecords
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getBasicDNSSearch = (searchString) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getbasicdnssearch_api")
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getBasicDNSSearchPaged = (
|
|
pageNumber,
|
|
orderBy,
|
|
fieldSort,
|
|
showNumberOfRecords
|
|
) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getbasicdnssearchpaged_api?pageNumber=" +
|
|
pageNumber +
|
|
"&orderby=" +
|
|
orderBy +
|
|
"&fieldSort=" +
|
|
fieldSort +
|
|
"&showNumberOfRecords=" +
|
|
showNumberOfRecords
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getAdvancedSearch = (searchString) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getadvancedsearch_api?searchstring=" +
|
|
JSON.stringify(searchString)
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
let ErrResponse = {
|
|
value: [],
|
|
errorCode: error.response.status,
|
|
errorMsg: error.response.statusText,
|
|
};
|
|
|
|
return ErrResponse;
|
|
});
|
|
};
|
|
|
|
export const getAdvancedSearchPaged = (
|
|
searchString,
|
|
pageNumber,
|
|
orderBy,
|
|
fieldSort,
|
|
showNumberOfRecords
|
|
) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getadvancedsearchpaged_api?searchstring=" +
|
|
JSON.stringify(searchString) +
|
|
"&pageNumber=" +
|
|
pageNumber +
|
|
"&orderby=" +
|
|
orderBy +
|
|
"&fieldSort=" +
|
|
fieldSort +
|
|
"&showNumberOfRecords=" +
|
|
showNumberOfRecords
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
let ErrResponse = {
|
|
value: [],
|
|
errorCode: error.response.status,
|
|
errorMsg: error.response.statusText,
|
|
};
|
|
|
|
return ErrResponse;
|
|
});
|
|
};
|
|
|
|
export const getBasicSearchDetails = (
|
|
appealTypeName,
|
|
caseReference,
|
|
primaryIdAttribute,
|
|
incidentID
|
|
) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getbasicsearchdetails_api?appealTypeName=" +
|
|
appealTypeName +
|
|
"&primaryIdAttribute=" +
|
|
primaryIdAttribute +
|
|
"&incidentID=" +
|
|
incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this error", error);
|
|
});
|
|
};
|
|
|
|
export const getBasicSearchDetailsPaged = (
|
|
appealTypeName,
|
|
caseReference,
|
|
primaryIdAttribute,
|
|
incidentID
|
|
) => {
|
|
//console.log("check appealtype:", appealType, caseReference);
|
|
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getbasicsearchdetailspaged_api?appealTypeName=" +
|
|
appealTypeName +
|
|
"&primaryIdAttribute=" +
|
|
primaryIdAttribute +
|
|
"&incidentID=" +
|
|
incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this error", error);
|
|
});
|
|
};
|
|
|
|
export const getSearchDocumentDetails = (incidentID) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getsearchdocumentdetails_api?incidentid=" +
|
|
incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getSearchDocumentDetailsPaged = (
|
|
incidentID,
|
|
pageNumber,
|
|
orderBy,
|
|
fieldSort,
|
|
showNumberOfRecords
|
|
) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getsearchdocumentdetailspaged_api?incidentid=" +
|
|
incidentID +
|
|
"&pageNumber=" +
|
|
pageNumber +
|
|
"&orderby=" +
|
|
orderBy +
|
|
"&fieldSort=" +
|
|
fieldSort +
|
|
"&showNumberOfRecords=" +
|
|
showNumberOfRecords
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getSearchDocumentHistory = (documentID) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getsearchdocumenthistory_api?documentid=" +
|
|
documentID
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getSearchDocumentHistoryPaged = (documentID, pageNumber) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getsearchdocumenthistorypaged_api?documentid=" +
|
|
documentID +
|
|
"&pageNumber=" +
|
|
pageNumber
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getLinkedCases = (parentIncidentid) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getlinkedcases_api?parentincidentid=" +
|
|
parentIncidentid
|
|
)
|
|
.then((res) => {
|
|
//console.log(" linked date", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getAppealsTypes = () => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getappealtypes_api")
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log(error);
|
|
let ErrResponse = {
|
|
value: [],
|
|
errorCode: error.response.status,
|
|
errorMsg: error.response.statusText,
|
|
};
|
|
|
|
return ErrResponse;
|
|
});
|
|
};
|
|
|
|
export const getLPA = () => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getlpa_api")
|
|
.then((res) => {
|
|
//console.log(res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
let ErrResponse = {
|
|
value: [],
|
|
errorCode: error.response.status,
|
|
errorMsg: error.response.statusText,
|
|
};
|
|
|
|
return ErrResponse;
|
|
});
|
|
};
|
|
|
|
// iteration 2 methods
|
|
|
|
export const getFormData = (whichForm) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getformdata_api?whichForm=" + whichForm)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getMandatoryFields = (whichForm) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getmandatoryfields_api?whichForm=" +
|
|
whichForm
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getPickLists = (whichForm) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getpicklists_api?whichForm=" + whichForm)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getPersonalAccount = (contactid) => {
|
|
console.log(contactid);
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getpersonalaccount_api?contactid=" +
|
|
contactid
|
|
)
|
|
.then((res) => {
|
|
console.log(res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("returned:", error);
|
|
// let ErrResponse = {
|
|
// value: [],
|
|
// errorCode: error.response.status,
|
|
// errorMsg: error.response.statusText,
|
|
// };
|
|
|
|
// return ErrResponse;
|
|
});
|
|
};
|
|
|
|
export const getAppealID = (
|
|
caseReference,
|
|
updateFormCollection,
|
|
primaryAttribute
|
|
) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getappealid_api?updateFormCollection=" +
|
|
updateFormCollection +
|
|
"&primaryAttribute=" +
|
|
primaryAttribute +
|
|
"&caseReference=" +
|
|
caseReference
|
|
)
|
|
.then((res) => {
|
|
console.log(res.data);
|
|
var appealID = res.data.value[0][primaryAttribute];
|
|
return appealID;
|
|
})
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getLogin = (emailAddress, pwd) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getlogin_api?emailAddress=" +
|
|
emailAddress +
|
|
"&pwd=" +
|
|
pwd
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const createCase = (appealTypeId, lpaID, contactid) => {
|
|
appealTypeId = parseInt(appealTypeId);
|
|
|
|
var queryUrl =
|
|
"/api/endpoint/createcase_api?appealTypeId=" +
|
|
appealTypeId +
|
|
"&lpaID=" +
|
|
lpaID +
|
|
"&contactid=" +
|
|
contactid;
|
|
|
|
var config = {
|
|
method: "get",
|
|
url: BASE_URL + queryUrl,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getMyCases = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getmycases_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getMyRepresentations = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getmyrepresentations_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getMyRepresentationsProxy = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getmyrepresentationsproxy_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getRepresentations = (incidentID) => {
|
|
return axios
|
|
.get("/api/endpoint/getrepresentations_api?incidentID=" + incidentID)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getRepresentationsProxy = (incidentID) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getrepresentationsproxy_api?incidentID=" +
|
|
incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getWatchedCases = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getwatchedcases_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getWatchedCasesProxy = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getwatchedcasesproxy_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getAwaitingSubmissionProxy = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getawaitingsubmissionproxy_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getAwaitingSubmission = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getawaitingsubmission_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getPortalModuleDetails = (appealType, caseReference) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getportalmoduledetails_api?appealType=" +
|
|
appealType +
|
|
"&caseReference=" +
|
|
caseReference
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getPortalModuleDetailsProxy = (appealType, caseReference) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getportalmoduledetailsproxy_api?appealType=" +
|
|
appealType +
|
|
"&caseReference=" +
|
|
caseReference
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getEmailAccountCheck = (emailAddress) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getemailaccountcheck_api?emailAddress=" +
|
|
emailAddress
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
//uses more than get methods
|
|
|
|
export const updatePassword = (contactId, newpassword) => {
|
|
var queryUrl = "/api/endpoint/updateaccount_api?contactId=" + contactId;
|
|
var data = { "pinswg_custom_password": newpassword };
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: data,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const updateAccount = async (contactId, updateBody) => {
|
|
var queryUrl = "/api/endpoint/updateaccount_api?contactId=" + contactId;
|
|
var data = updateBody;
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: data,
|
|
};
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this error:", error);
|
|
});
|
|
};
|
|
|
|
export const createWatchedCases = (formValues) => {
|
|
var data = formValues;
|
|
var queryUrl = window.apiRoot + "/api/endpoint/createwatchedcases_api";
|
|
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: data,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const updateCase = async (
|
|
incidentId,
|
|
updateBody,
|
|
updateFormCollection,
|
|
primaryAttribute,
|
|
caseReference
|
|
) => {
|
|
var data = updateBody;
|
|
|
|
var appealObj = await getAppealID(
|
|
caseReference,
|
|
updateFormCollection,
|
|
primaryAttribute
|
|
);
|
|
|
|
var queryUrl =
|
|
"/api/endpoint/updatecase_api?updateFormCollection=" +
|
|
updateFormCollection +
|
|
"&appealObj=" +
|
|
appealObj;
|
|
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: data,
|
|
};
|
|
|
|
console.log(data);
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const patchCase = async (incidentid) => {
|
|
var queryUrl = "/api/endpoint/patchcase_api?incidentid=" + incidentid;
|
|
var config = {
|
|
method: "get",
|
|
url: queryUrl,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this error:", 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",
|
|
},
|
|
};
|
|
// console.log(config);
|
|
return axios(config)
|
|
.then((res) => {
|
|
//console.log("deleted ", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const deleteAwaitingSubmissions = (incidentID) => {
|
|
var queryUrl =
|
|
"/api/endpoint/deleteawaitingsubmissions_api?incidentID=" + incidentID;
|
|
|
|
var config = {
|
|
method: "delete",
|
|
url: queryUrl,
|
|
};
|
|
// console.log(config);
|
|
return axios(config)
|
|
.then((res) => {
|
|
//console.log("deleted ", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const deleteWatchedCases = (watchedCaseID) => {
|
|
var queryUrl =
|
|
"/api/endpoint/deletewatchedcases_api?watchedCaseID=" + watchedCaseID;
|
|
var config = {
|
|
method: "delete",
|
|
url: queryUrl,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
//console.log("deleted ", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const createAccount = (formValues) => {
|
|
var data = formValues;
|
|
var queryUrl = "/api/endpoint/createaccount_api";
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: data,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
// console.log("posted ", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|