Commit 6a731bcc authored by Roman's avatar Roman

BRCD-1678 feat(Play) - InputProcessor step Rate Mapping filter product param fields by play

parent 3b4c788a
......@@ -20,6 +20,10 @@ import {
removeRatingPriorityField,
removeRatingField,
} from '../../../actions/inputProcessorActions';
import {
customerIdentificationFieldsPlaySelector,
} from '../../../selectors/inputProcessorSelector';
class RateMapping extends Component {
static propTypes = {
......@@ -29,11 +33,13 @@ class RateMapping extends Component {
settings: PropTypes.instanceOf(Immutable.Map),
customRatingFields: PropTypes.instanceOf(Immutable.List),
rateCalculators: PropTypes.instanceOf(Immutable.List),
plays: PropTypes.instanceOf(Immutable.Set),
}
static defaultProps = {
settings: Immutable.Map(),
customRatingFields: Immutable.List(),
rateCalculators: Immutable.List(),
plays: Immutable.Set(),
};
state = {
......@@ -52,10 +58,20 @@ class RateMapping extends Component {
});
};
filterFiledByPlay = (field) => {
const { plays } = this.props;
const fieldPlays = field.get('plays', Immutable.List());
if (fieldPlays.isEmpty()) {
return true;
}
return plays.intersect(Immutable.Set(fieldPlays)).size > 0;
}
getCustomRatingFields = () => {
const { customRatingFields } = this.props;
return customRatingFields
.filter(field => (field.get('field_name', '').startsWith('params.')))
.filter(this.filterFiledByPlay)
.map(field => ({
value: field.get('field_name', ''),
label: field.get('title', ''),
......@@ -543,6 +559,7 @@ class RateMapping extends Component {
}
const mapStateToProps = (state, props) => ({
plays: customerIdentificationFieldsPlaySelector(state, props),
rateCalculators: props.settings.getIn(['rate_calculators', props.rateCategory, props.usaget]),
});
......
import { createSelector } from 'reselect';
import Immutable from 'immutable';
import {
subscriberFieldsSelector,
} from './settingsSelector';
const getCheckedFields = state => state.inputProcessor.get('fields', Immutable.List());
......@@ -12,3 +15,17 @@ export const allCheckedSelector = createSelector(
getAllFields,
selectAllChecked,
);
export const customerIdentificationFieldsPlaySelector = createSelector(
(state, props) => props.settings.getIn(['customer_identification_fields', props.usaget], Immutable.List()),
subscriberFieldsSelector,
(customerIdentificationFields, subscriberFields) => {
const plyas = customerIdentificationFields.map(customerIdentificationField =>
subscriberFields.find(subscriberField =>
subscriberField.get('field_name', '') === customerIdentificationField.get('target_key', ''),
null, Immutable.Map(),
).get('plays', Immutable.List()),
).reduce((acc, list) => acc.union(list), Immutable.Set());
return plyas;
},
);
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