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

import app from 'store/app';
import paragraph from 'store/paragraph';
import Pages, { PagesProps } from './Pages';

const mapStateToProps = (state: StoreState): Record<string, any> => ({
  user: state.paragraph.user,
  pages: state.paragraph.list,
  search: state.paragraph.search,
});

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

const Wrapped = connect<PagesProps>(mapStateToProps, mapDispatchToProps)(Pages);

export default Wrapped;
