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

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

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

const mapDispatchToProps = {
  loadData: blog.actions.loadOne.request.action,
  dialogShow: app.actions.dialog.error.action,
  publishArticle: blog.actions.publish.request.action,
  unpublishArticle: blog.actions.unpublish.request.action,
};

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

export default Wrapped;
