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

import shop from 'store/shop';
import SingleOrder, { StateProps, DispatchProps, OwnProps } from './SingleOrder';

const mapStateToProps = (state: StoreState): {} => ({
  detail: state.shop.detail,
  lg: state.content.lg,
});

const mapDispatchToProps = {
  // Orders
  orderMarkPaid: shop.actions.order.markPaid.request.action,
  orderMarkUnPaid: shop.actions.order.markUnPaid.request.action,
  orderCancel: shop.actions.order.cancel.request.action,
  orderReimburse: shop.actions.order.reimburse.request.action,
};

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

export default withRouter(Wrapped);
