385 lines
9.7 KiB
JavaScript
385 lines
9.7 KiB
JavaScript
import axios from "axios";
|
|
import { BASE_URL } from "../core/env";
|
|
import { consoleLogger } from "../core/logger";
|
|
|
|
export const getBasicSearch = (searchString) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getbasicsearch_api?searchString=" +
|
|
searchString
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(error);
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getAddressSearchPaged = (
|
|
searchString,
|
|
pageNumber,
|
|
orderBy,
|
|
fieldSort,
|
|
showNumberOfRecords
|
|
) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getbasicsearch_by_address_paged_api?searchString=" +
|
|
searchString +
|
|
"&pageNumber=" +
|
|
pageNumber +
|
|
"&orderby=" +
|
|
orderBy +
|
|
"&fieldSort=" +
|
|
fieldSort +
|
|
"&showNumberOfRecords=" +
|
|
showNumberOfRecords
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getBasicSearchPaged = (
|
|
searchString,
|
|
pageNumber,
|
|
orderBy,
|
|
fieldSort,
|
|
showNumberOfRecords
|
|
) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getbasicsearchpaged_api?searchString=" +
|
|
searchString +
|
|
"&pageNumber=" +
|
|
pageNumber +
|
|
"&orderby=" +
|
|
orderBy +
|
|
"&fieldSort=" +
|
|
fieldSort +
|
|
"&showNumberOfRecords=" +
|
|
showNumberOfRecords
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getDNSCoords = () => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getdnscoords_api")
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
let ErrResponse = {
|
|
value: [],
|
|
errorCode: error.response.status,
|
|
errorMsg: error.response.statusText
|
|
};
|
|
|
|
return ErrResponse;
|
|
});
|
|
};
|
|
|
|
export const getDNSList = (searchString) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getdnslist_api")
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getBasicDNSSearch = (searchString) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getbasicdnssearch_api")
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(error);
|
|
let ErrResponse = {
|
|
value: [],
|
|
errorCode: error.response.status,
|
|
errorMsg: error.response.statusText
|
|
};
|
|
|
|
return ErrResponse;
|
|
});
|
|
};
|
|
|
|
export const getBasicSearchDetails = async (
|
|
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) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getBasicPartSavedDetails = (
|
|
appealTypeName,
|
|
caseReference,
|
|
primaryIdAttribute,
|
|
incidentID
|
|
) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getbasicpartsaveddetails_api?appealTypeName=" +
|
|
appealTypeName +
|
|
"&primaryIdAttribute=" +
|
|
primaryIdAttribute +
|
|
"&incidentID=" +
|
|
incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this error", error);
|
|
});
|
|
};
|
|
|
|
export const getBasicSearchDetailsPaged = async (
|
|
appealTypeName,
|
|
caseReference,
|
|
primaryIdAttribute,
|
|
incidentIDs
|
|
) => {
|
|
if (!incidentIDs || incidentIDs.length === 0) return [];
|
|
|
|
console.log("=======", primaryIdAttribute);
|
|
|
|
const filter = incidentIDs
|
|
.map((id) => {
|
|
const suffix =
|
|
primaryIdAttribute === "pinswg_sipscase"
|
|
? `_${primaryIdAttribute}_value`
|
|
: `_${primaryIdAttribute}s_value`;
|
|
|
|
return `${suffix} eq ${id}`;
|
|
})
|
|
.join(" or ");
|
|
|
|
const url = `/api/endpoint/getbasicsearchdetailspaged_api?appealTypeName=${appealTypeName}&primaryIdAttribute=${primaryIdAttribute}&incidentID=${encodeURIComponent(
|
|
filter
|
|
)}`;
|
|
|
|
console.log(
|
|
`Fetching ${incidentIDs.length} incidents for appeal type: ${appealTypeName}`
|
|
);
|
|
|
|
try {
|
|
const res = await axios.get(url);
|
|
return res.data.value || [];
|
|
} catch (error) {
|
|
consoleLogger(error);
|
|
return [];
|
|
}
|
|
};
|
|
|
|
export const getSearchDocumentDetails = (incidentID) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getsearchdocumentdetails_api?incidentid=" +
|
|
incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
throw error;
|
|
});
|
|
};
|
|
|
|
export const getSearchDocumentTypes = (incidentID) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getsearchdocumentTypes_api?incidentid=" + incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getSearchDocumentDetailsPaged = (
|
|
incidentID,
|
|
pageNumber,
|
|
orderBy,
|
|
fieldSort,
|
|
showNumberOfRecords,
|
|
documentType
|
|
) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getsearchdocumentdetailspaged_api?incidentid=" +
|
|
incidentID +
|
|
"&pageNumber=" +
|
|
pageNumber +
|
|
"&orderby=" +
|
|
orderBy +
|
|
"&fieldSort=" +
|
|
fieldSort +
|
|
"&showNumberOfRecords=" +
|
|
showNumberOfRecords +
|
|
"&documentType=" +
|
|
documentType
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getLinkedCases = (parentIncidentid) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getlinkedcases_api?parentincidentid=" +
|
|
parentIncidentid
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getAddressSearch = async (searchString) => {
|
|
const params = new URLSearchParams(searchString);
|
|
const str = params.toString();
|
|
|
|
var queryUrl =
|
|
BASE_URL + "/api/endpoint/getbasicsearch_by_address_api?" + str;
|
|
|
|
var config = {
|
|
method: "get",
|
|
url: queryUrl
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
let ErrResponse = {
|
|
value: [],
|
|
errorCode: error.response.status,
|
|
errorMsg: error.response.statusText
|
|
};
|
|
return ErrResponse;
|
|
});
|
|
};
|