Commit 58755d93 authored by Roman's avatar Roman

BRCD-1676 refactor(Play) - remove duplicate function (same logic from different btanches)

parent 4a0e2299
......@@ -4,7 +4,7 @@ import Immutable from 'immutable';
import changeCase from 'change-case';
import EntityList from '../EntityList';
import { getItemDateValue, getConfig } from '../../common/Util';
import { playsIsEnabledSelector } from '../../selectors/settingsSelector';
import { isPlaysEnabledSelector } from '../../selectors/settingsSelector';
class SubscriptionsList extends Component {
......@@ -170,7 +170,7 @@ class SubscriptionsList extends Component {
const mapStateToProps = (state, props) => ({
isPlaysEnabled: playsIsEnabledSelector(state, props),
isPlaysEnabled: isPlaysEnabledSelector(state, props),
});
export default connect(mapStateToProps)(SubscriptionsList);
......@@ -8,11 +8,8 @@ import EntityField from './EntityField';
import { getSettings } from '../../actions/settingsActions';
import {
entityFieldSelector,
availablePlaysSettingsSelector,
isPlaysEnabledSelector,
} from '../../selectors/settingsSelector';
import {
shouldUsePlays,
} from '../../common/Util';
class EntityFields extends Component {
......@@ -27,9 +24,9 @@ class EntityFields extends Component {
highlightPramas: PropTypes.instanceOf(Immutable.List),
fieldsFilter: PropTypes.func,
editable: PropTypes.bool,
isPlaysEnabled: PropTypes.bool,
onChangeField: PropTypes.func,
dispatch: PropTypes.func.isRequired,
availablePlays: PropTypes.instanceOf(Immutable.List),
};
static defaultProps = {
......@@ -38,8 +35,8 @@ class EntityFields extends Component {
highlightPramas: Immutable.List(),
fieldsFilter: null,
editable: true,
isPlaysEnabled: false,
onChangeField: () => {},
availablePlays: Immutable.List(),
}
componentDidMount() {
......@@ -104,8 +101,8 @@ class EntityFields extends Component {
}
filterPlayFields = (field) => {
const { availablePlays, entity } = this.props;
if (!shouldUsePlays(availablePlays)) {
const { entity, isPlaysEnabled } = this.props;
if (!isPlaysEnabled) {
return true;
}
const play = entity.get('play', '');
......@@ -177,7 +174,7 @@ class EntityFields extends Component {
const mapStateToProps = (state, props) => ({
fields: entityFieldSelector(state, props),
availablePlays: availablePlaysSettingsSelector(state, props),
isPlaysEnabled: isPlaysEnabledSelector(state, props),
});
export default connect(mapStateToProps)(EntityFields);
......@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
import Immutable from 'immutable';
import changeCase from 'change-case';
import EntityList from '../EntityList';
import { playsIsEnabledSelector } from '../../selectors/settingsSelector';
import { isPlaysEnabledSelector } from '../../selectors/settingsSelector';
const PlansList = (props) => {
......@@ -92,7 +92,7 @@ PlansList.defaultProps = {
};
const mapStateToProps = (state, props) => ({
isPlaysEnabled: playsIsEnabledSelector(state, props),
isPlaysEnabled: isPlaysEnabledSelector(state, props),
});
export default connect(mapStateToProps)(PlansList);
......@@ -7,7 +7,7 @@ import { LoadingItemPlaceholder } from '../Elements';
import {
getSettings,
} from '../../actions/settingsActions';
import { playsIsEnabledSelector } from '../../selectors/settingsSelector';
import { isPlaysEnabledSelector } from '../../selectors/settingsSelector';
class ProductsList extends Component {
......@@ -106,7 +106,7 @@ class ProductsList extends Component {
const mapStateToProps = (state, props) => ({
fields: state.settings.getIn(['rates', 'fields']) || undefined,
isPlaysEnabled: playsIsEnabledSelector(state, props),
isPlaysEnabled: isPlaysEnabledSelector(state, props),
});
export default connect(mapStateToProps)(ProductsList);
......@@ -8,7 +8,7 @@ import {
getConfig,
convertServiceBalancePeriodToObject,
} from '../../common/Util';
import { playsIsEnabledSelector } from '../../selectors/settingsSelector';
import { isPlaysEnabledSelector } from '../../selectors/settingsSelector';
const ServicesList = (props) => {
......@@ -79,7 +79,7 @@ ServicesList.defaultProps = {
};
const mapStateToProps = (state, props) => ({
isPlaysEnabled: playsIsEnabledSelector(state, props),
isPlaysEnabled: isPlaysEnabledSelector(state, props),
});
export default connect(mapStateToProps)(ServicesList);
......@@ -285,11 +285,6 @@ export const isPlaysEnabledSelector = createSelector(
(playsEnabled = Immutable.List()) => playsEnabled.size > 1,
);
export const playsIsEnabledSelector = createSelector(
playsEnabledSelector,
(plays = Immutable.List()) => plays && plays.size > 1,
);
export const availablePlaysSettingsSelector = createSelector(
getPlaysSettings,
plays => (plays ? plays.filter(play => play.get('enabled', true)) : undefined),
......
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