import { connect } from 'react-redux';

import generic from 'store/generic';
import genericApollo from 'store/genericApollo';
import file from 'store/file';
import app from 'store/app';
import GenericFields, { GenericFieldsProps } from './GenericFields';

const mapStateToProps = (state): Record<string, any> => ({
  content: state.content.raw,
  lg: state.content.lg,
});

const mapDispatchToProps = {
  loadData: generic.actions.search.request.action,
  loadApolloData: genericApollo.actions.search.request.action,
  loadOne: generic.actions.detail.request.action,
  upload: generic.actions.upload.request.action,
  uploadS3: generic.actions.uploadS3Url.request.action,
  uploadApollo: file.actions.upload.request.action,
  dialogShow: app.actions.dialog.show.action,
  dialogHide: app.actions.dialog.hide.action,
};

const Wrapped = connect<GenericFieldsProps>(mapStateToProps, mapDispatchToProps)(GenericFields);

export default Wrapped;
