41 lines
1.2 KiB
JavaScript

import { AppConstants } from '../constants/AppConstants.js';
import { EnumAppActions } from './AppActions.js';
class BaseActions {
constructor() {}
get AppConstants() {
return AppConstants;
}
getErrorMessage(jqxhr, textStatus, error) {
let message = null;
console.log("Request Failed: " + textStatus + ", " + error + ' ' + jqxhr.responseText);
if (jqxhr.readyState === 4) {
// HTTP error (can be checked by XMLHttpRequest.status and XMLHttpRequest.statusText)
message = textStatus + ", " + error + ' ' + jqxhr.responseText;
}
else if (jqxhr.readyState === 0) {
// Network error (i.e. connection refused, access denied due to CORS, etc.)
message = textStatus + ", network connection";
}
else {
// something weird is happening
message = textStatus + ", " + error + ' ' + jqxhr.responseText;
}
return message;
}
showLoader() {
return { type: EnumAppActions.LOADER_SHOW }
}
hideLoader() {
return { type: EnumAppActions.LOADER_HIDE }
}
}
export default BaseActions;