import { connect } from 'react-redux';
import app from 'store/app';
import cms from 'store/cms';
import content, { ContentProps } from './Content';

const mapStateToProps = (state: StoreState) => ({
  pages: state.cms && state.cms.pages,
  search: state.cms.search,
});

const mapDispatchToProps = {
  loadList: cms.actions.list.request.action,
  updatePage: cms.actions.update.request.action,
  addPage: cms.actions.add.request.action,
  deletePage: cms.actions.delete.request.action,
  sideMenuShow: app.actions.sideMenu.show.action,
  syncContent: cms.actions.syncContent.request.action,
  globalSearch: cms.actions.search.action,
  sideMenuHide: app.actions.sideMenu.hide.action,
  dialogShow: app.actions.dialog.show.action,
};

const Wrapped = connect<ContentProps>(mapStateToProps, mapDispatchToProps)(content);

export default Wrapped;
