mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat: Fix axios interceptors.
This commit is contained in:
@@ -66,7 +66,6 @@ function Login({
|
||||
crediential: values.crediential,
|
||||
password: values.password,
|
||||
}).then(() => {
|
||||
history.go('/homepage');
|
||||
setSubmitting(false);
|
||||
}).catch((errors) => {
|
||||
const toastBuilders = [];
|
||||
|
||||
11
client/src/containers/Authentication/withAuthentication.js
Normal file
11
client/src/containers/Authentication/withAuthentication.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import { isAuthenticated } from 'store/authentication/authentication.reducer'
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
isAuthorized: isAuthenticated(state),
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps);
|
||||
47
client/src/containers/GlobalErrors/GlobalErrors.js
Normal file
47
client/src/containers/GlobalErrors/GlobalErrors.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
import { useIntl } from 'react-intl';
|
||||
import AppToaster from 'components/AppToaster';
|
||||
|
||||
import withGlobalErrors from './withGlobalErrors';
|
||||
import withGlobalErrorsActions from './withGlobalErrorsActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
let toastKeySessionExpired;
|
||||
let toastKeySomethingWrong;
|
||||
|
||||
function GlobalErrors({
|
||||
// #withGlobalErrors
|
||||
globalErrors,
|
||||
|
||||
// #withGlobalErrorsActions
|
||||
globalErrorsSet,
|
||||
}) {
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
if (globalErrors.something_wrong) {
|
||||
toastKeySessionExpired = AppToaster.show({
|
||||
message: formatMessage({ id: 'ops_something_went_wrong' }),
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => {
|
||||
globalErrorsSet({ something_wrong: false });
|
||||
}
|
||||
}, toastKeySessionExpired);
|
||||
}
|
||||
|
||||
if (globalErrors.session_expired) {
|
||||
toastKeySomethingWrong = AppToaster.show({
|
||||
message: formatMessage({ id: 'session_expired' }),
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => {
|
||||
globalErrorsSet({ session_expired: false });
|
||||
}
|
||||
}, toastKeySomethingWrong);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withGlobalErrors,
|
||||
withGlobalErrorsActions,
|
||||
)(GlobalErrors);
|
||||
10
client/src/containers/GlobalErrors/withGlobalErrors.js
Normal file
10
client/src/containers/GlobalErrors/withGlobalErrors.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
globalErrors: state.globalErrors.data,
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps);
|
||||
@@ -0,0 +1,9 @@
|
||||
import {connect} from 'react-redux';
|
||||
import { setGlobalErrors } from 'store/globalErrors/globalErrors.actions';
|
||||
import t from 'store/types';
|
||||
|
||||
export const mapDispatchToProps = (dispatch) => ({
|
||||
globalErrorsSet: (errors) => dispatch(setGlobalErrors(errors)),
|
||||
});
|
||||
|
||||
export default connect(null, mapDispatchToProps);
|
||||
Reference in New Issue
Block a user