mirror of
https://github.com/Unleash/unleash.git
synced 2024-10-18 20:09:08 +02:00
5342c86b60
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai> Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
27 lines
838 B
JavaScript
27 lines
838 B
JavaScript
import { connect } from 'react-redux';
|
|
import ContextComponent from './form-context-component';
|
|
import { updateContextField, validateName } from './../../store/context/actions';
|
|
|
|
const mapStateToProps = (state, props) => {
|
|
const contextFieldBase = { name: '', description: '', legalValues: [] };
|
|
const field = state.context.toJS().find(n => n.name === props.contextFieldName);
|
|
const contextField = Object.assign(contextFieldBase, field);
|
|
if (!field) {
|
|
contextField.initial = true;
|
|
}
|
|
|
|
return {
|
|
contextField,
|
|
};
|
|
};
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
validateName,
|
|
submit: contextField => updateContextField(contextField)(dispatch),
|
|
editMode: true,
|
|
});
|
|
|
|
const FormAddContainer = connect(mapStateToProps, mapDispatchToProps)(ContextComponent);
|
|
|
|
export default FormAddContainer;
|