mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
re-structure to monorepo.
This commit is contained in:
79
packages/webapp/src/containers/GlobalErrors/GlobalErrors.tsx
Normal file
79
packages/webapp/src/containers/GlobalErrors/GlobalErrors.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
// @ts-nocheck
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
import intl from 'react-intl-universal';
|
||||
import { AppToaster } from '@/components';
|
||||
|
||||
import withGlobalErrors from './withGlobalErrors';
|
||||
import withGlobalErrorsActions from './withGlobalErrorsActions';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
let toastKeySessionExpired;
|
||||
let toastKeySomethingWrong;
|
||||
|
||||
function GlobalErrors({
|
||||
// #withGlobalErrors
|
||||
globalErrors,
|
||||
|
||||
// #withGlobalErrorsActions
|
||||
globalErrorsSet,
|
||||
}) {
|
||||
if (globalErrors.something_wrong) {
|
||||
toastKeySessionExpired = AppToaster.show(
|
||||
{
|
||||
message: intl.get('ops_something_went_wrong'),
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => {
|
||||
globalErrorsSet({ something_wrong: false });
|
||||
},
|
||||
},
|
||||
toastKeySessionExpired,
|
||||
);
|
||||
}
|
||||
if (globalErrors.session_expired) {
|
||||
toastKeySomethingWrong = AppToaster.show(
|
||||
{
|
||||
message: intl.get('session_expired'),
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => {
|
||||
globalErrorsSet({ session_expired: false });
|
||||
},
|
||||
},
|
||||
toastKeySomethingWrong,
|
||||
);
|
||||
}
|
||||
if (globalErrors.access_denied) {
|
||||
toastKeySomethingWrong = AppToaster.show(
|
||||
{
|
||||
message: intl.get('global_error.you_dont_have_permissions'),
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => {
|
||||
globalErrorsSet({ access_denied: false });
|
||||
},
|
||||
},
|
||||
toastKeySomethingWrong,
|
||||
);
|
||||
}
|
||||
if (globalErrors.transactionsLocked) {
|
||||
AppToaster.show({
|
||||
message: intl.get('global_error.transactions_locked', {
|
||||
lockedToDate: globalErrors.transactionsLocked.formatted_locked_to_date,
|
||||
}),
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => {
|
||||
globalErrorsSet({ transactionsLocked: false });
|
||||
},
|
||||
});
|
||||
}
|
||||
if (globalErrors.userInactive) {
|
||||
AppToaster.show({
|
||||
message: intl.get('global_error.authorized_user_inactive'),
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => {
|
||||
globalErrorsSet({ userInactive: false });
|
||||
},
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export default compose(withGlobalErrors, withGlobalErrorsActions)(GlobalErrors);
|
||||
@@ -0,0 +1,11 @@
|
||||
// @ts-nocheck
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
globalErrors: state.globalErrors.data,
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps);
|
||||
@@ -0,0 +1,9 @@
|
||||
// @ts-nocheck
|
||||
import { connect } from 'react-redux';
|
||||
import { setGlobalErrors } from '@/store/globalErrors/globalErrors.actions';
|
||||
|
||||
export const mapDispatchToProps = (dispatch) => ({
|
||||
globalErrorsSet: (errors) => dispatch(setGlobalErrors(errors)),
|
||||
});
|
||||
|
||||
export default connect(null, mapDispatchToProps);
|
||||
Reference in New Issue
Block a user