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

import message from 'store/message';
import app from 'store/app';
import Message, { StateProps, DispatchProps, OwnProps } from './Message';

const mapStateToProps = (state: StoreState): {} => ({
  rooms: state.message.rooms,
  profile: state.account.profile,
});

const mapDispatchToProps = {
  getRooms: message.actions.getRooms.request.action,
  getMoreRooms: message.actions.getRoomsMore.request.action,
  createRoom: message.actions.createRoom.request.action,
  dialogShow: app.actions.dialog.show.action,
  dialogHide: app.actions.dialog.hide.action,
};

const Wrapped = connect<StateProps, DispatchProps, OwnProps>(
  mapStateToProps,
  mapDispatchToProps,
)(Message);

export default Wrapped;
