Commit 4c9a4439 authored by Roman's avatar Roman

BRCD-1762 fix(Play-Discount) - added remove entity fields function and pass to <EntityFields />

parent 6351ff66
......@@ -20,6 +20,7 @@ export default class DiscountDetails extends Component {
currency: PropTypes.string,
errorMessages: PropTypes.object,
onFieldUpdate: PropTypes.func.isRequired,
onFieldRemove: PropTypes.func.isRequired,
availablePlans: PropTypes.instanceOf(Immutable.List),
availableServices: PropTypes.instanceOf(Immutable.List),
}
......@@ -71,6 +72,10 @@ export default class DiscountDetails extends Component {
this.props.onFieldUpdate(field, value);
}
onRemoveAdditionalField = (field) => {
this.props.onFieldRemove(field);
}
onChangeDiscountType = (e) => {
const { value } = e.target;
this.props.onFieldUpdate(['discount_type'], value);
......@@ -261,6 +266,7 @@ export default class DiscountDetails extends Component {
entityName="discounts"
entity={discount}
onChangeField={this.onChangeAdditionalField}
onRemoveField={this.onRemoveAdditionalField}
editable={editable}
/>
......
......@@ -142,6 +142,10 @@ class DiscountSetup extends Component {
}
}
onRemoveFieldValue = (path) => {
this.props.dispatch(deleteDiscountValue(path));
}
onChangeFieldValue = (path, value) => {
const stringPath = Array.isArray(path) ? path.join('.') : path;
const deletePathOnEmptyValue = ['limit', 'cycles', 'params.plan'];
......@@ -239,6 +243,7 @@ class DiscountSetup extends Component {
mode={mode}
currency={currency}
onFieldUpdate={this.onChangeFieldValue}
onFieldRemove={this.onRemoveFieldValue}
availablePlans={availablePlans}
availableServices={availableServices}
/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment