huridocs/uwazi

View on GitHub
app/react/Entities/containers/EntityForm.js

Summary

Maintainability
A
0 mins
Test Coverage
F
0%
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

import { saveEntity, resetForm } from 'app/Entities/actions/actions';
import { actions, MetadataForm } from 'app/Metadata';

function mapStateToProps(state) {
  return {
    model: 'entityView.entityForm',
    templateId: state.entityView.entityForm.template,
    templates: state.templates,
    thesauris: state.thesauris,
  };
}

export function mapDispatchToProps(dispatch) {
  return bindActionCreators(
    {
      changeTemplate: actions.changeTemplate,
      onSubmit: saveEntity,
      componentWillUnmount: resetForm,
    },
    dispatch
  );
}

export default connect(mapStateToProps, mapDispatchToProps)(MetadataForm);