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

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

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

const mapDispatchToProps = {
  getRoom: message.actions.getRoomInfo.request.action,
  getMessage: message.actions.getRoomMessage.request.action,
  createMessage: message.actions.createMessage.request.action,
  roomSeen: message.actions.roomSeen.request.action,
  cleanMessageRoom: message.actions.resetMessage.action,
  dialogShow: app.actions.dialog.show.action,
};

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

export default Wrapped;
