2022-12-01 11:06:08 -08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2023-05-28 07:38:10 -07:00
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2022-12-01 11:06:08 -08:00
|
|
|
import { openModal } from 'flavours/glitch/actions/modal';
|
2022-10-11 01:17:04 -07:00
|
|
|
import { me } from 'flavours/glitch/initial_state';
|
2023-05-28 07:38:10 -07:00
|
|
|
import { logOut } from 'flavours/glitch/utils/log_out';
|
|
|
|
|
|
|
|
import NavigationBar from '../components/navigation_bar';
|
2019-04-20 11:32:16 -07:00
|
|
|
|
2022-12-01 11:06:08 -08: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 11:32:16 -07:00
|
|
|
const mapStateToProps = state => {
|
|
|
|
return {
|
|
|
|
account: state.getIn(['accounts', me]),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-12-01 11:06:08 -08:00
|
|
|
const mapDispatchToProps = (dispatch, { intl }) => ({
|
|
|
|
onLogout () {
|
|
|
|
dispatch(openModal('CONFIRM', {
|
|
|
|
message: intl.formatMessage(messages.logoutMessage),
|
|
|
|
confirm: intl.formatMessage(messages.logoutConfirm),
|
|
|
|
closeWhenConfirm: false,
|
|
|
|
onConfirm: () => logOut(),
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(NavigationBar));
|