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

import app from 'store/app';

import account from 'store/account';
import Login, { LoginProps } from './Login';

const mapStateToProps = (state: StoreState): Record<string, any> => ({
  loading: state.generic.loading,
});

const mapDispatchToProps = {
  logout: auth.actions.logout.request.action,
  login: auth.actions.login.request.action,
  loginFirebase: auth.actions.firebase.login.request.action,
  logoutFirebase: auth.actions.firebase.logout.request.action,
  initAccount: account.actions.init.request.action,
  showError: app.actions.dialog.error.action,
};

const Wrapped = connect<LoginProps>(mapStateToProps, mapDispatchToProps)(Login);

export default Wrapped;
