import { connect } from 'react-redux';
import { StoreState } from 'store/rootReducer';
import app from 'store/app';
import auth from 'store/auth';

import { withRouter } from 'react-router';
import account from 'store/account';
import Header, { HeaderProps } from './Header';

const mapStateToProps = (state: StoreState): Record<string, any> => ({
  user: state.account,
  paragraphUser: state.paragraph && state.paragraph.user,
});

const mapDispatchToProps = {
  logout: auth.actions.logout.request.action,
  logoutFirebase: auth.actions.firebase.logout.request.action,
  dialogShow: app.actions.dialog.show.action,
  selectResource: account.actions.selectAccountResource.action,
  sideMenuShow: app.actions.sideMenu.show.action,
  showSuccess: app.actions.dialog.success.action,
  sideMenuHide: app.actions.sideMenu.hide.action,
};

const Wrapped = connect<HeaderProps>(mapStateToProps, mapDispatchToProps)(Header);

export default withRouter(Wrapped);
