2022-12-01 21:06:08 +02:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2023-05-28 17:38:10 +03:00
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2022-12-01 21:06:08 +02:00
|
|
|
import { openModal } from 'flavours/glitch/actions/modal';
|
2022-10-11 11:17:04 +03:00
|
|
|
import { me } from 'flavours/glitch/initial_state';
|
2023-05-28 17:38:10 +03:00
|
|
|
import { logOut } from 'flavours/glitch/utils/log_out';
|
|
|
|
|
|
|
|
import NavigationBar from '../components/navigation_bar';
|
2019-04-20 21:32:16 +03:00
|
|
|
|
2022-12-01 21:06:08 +02:00
|
|
|
const messages = defineMessages({
|
|
|
|
logoutMessage: { id: 'confirmations.logout.message', defaultMessage: 'Are you sure you want to log out?' },
|
|
|
|
logoutConfirm: { id: 'confirmations.logout.confirm', defaultMessage: 'Log out' },
|
|
|
|
});
|
|
|
|
|
2019-04-20 21:32:16 +03:00
|
|
|
const mapStateToProps = state => {
|
|
|
|
return {
|
|
|
|
account: state.getIn(['accounts', me]),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-12-01 21:06:08 +02:00
|
|
|
const mapDispatchToProps = (dispatch, { intl }) => ({
|
|
|
|
onLogout () {
|
2023-05-25 16:42:37 +03:00
|
|
|
dispatch(openModal({
|
|
|
|
modalType: 'CONFIRM',
|
|
|
|
modalProps: {
|
|
|
|
message: intl.formatMessage(messages.logoutMessage),
|
|
|
|
confirm: intl.formatMessage(messages.logoutConfirm),
|
|
|
|
closeWhenConfirm: false,
|
|
|
|
onConfirm: () => logOut(),
|
|
|
|
},
|
2022-12-01 21:06:08 +02:00
|
|
|
}));
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(NavigationBar));
|