Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
updateQuery = (value, props) => {
const {
customQuery, filterLabel, showFilter, URLParams,
} = props;
let customQueryOptions;
let query = DataSearch.defaultQuery(value, props);
if (customQuery) {
const customQueryTobeSet = customQuery(value, props) || {};
const queryTobeSet = customQueryTobeSet.query;
if (queryTobeSet) {
query = [queryTobeSet];
}
customQueryOptions = getOptionsFromQuery(customQueryTobeSet);
}
// query options should be applied to the source component,
// not on internal component, hence using `this.props.componentId` here
props.setQueryOptions(props.componentId, {
...this.queryOptions,
...customQueryOptions,
});
if (!this.isPending) {
props.updateQuery({
componentId: props.componentId,
query,
value,
label: filterLabel,
showFilter,
URLParams,
updateQuery = (value, props) => {
const { customQuery } = props;
let query = RangeSlider.defaultQuery(value, props);
let customQueryOptions;
if (customQuery) {
({ query } = customQuery(value, props) || {});
customQueryOptions = getOptionsFromQuery(customQuery(value, props));
}
const {
showFilter,
range: { start, end },
} = props;
const [currentStart, currentEnd] = value;
// check if the slider is at its initial position
const isInitialValue = currentStart === start && currentEnd === end;
props.setQueryOptions(props.componentId, customQueryOptions);
props.updateQuery({
componentId: props.componentId,
query,
value,
label: props.filterLabel,
showFilter: showFilter && !isInitialValue,
URLParams: props.URLParams,
updateQuery = (value, props, category = this.state.currentCategory) => {
const {
customQuery, filterLabel, showFilter, URLParams,
} = props;
let customQueryOptions;
let query = CategorySearch.defaultQuery(value, props, category);
if (customQuery) {
const customQueryTobeSet = customQuery(value, props, category) || {};
if (customQueryTobeSet.query) {
({ query } = customQueryTobeSet);
}
customQueryOptions = getOptionsFromQuery(customQueryTobeSet);
}
// query options should be applied to the source component,
// not on internal component, hence using `this.props.componentId` here
props.setQueryOptions(props.componentId, {
...this.queryOptions,
...customQueryOptions,
});
if (!this.isPending) {
props.updateQuery({
componentId: props.componentId,
query,
value,
label: filterLabel,
showFilter,
URLParams,
updateQuery = (value, props) => {
const { customQuery } = props;
let customQueryOptions;
let currentValue = value;
if (value !== props.selectAllLabel) {
currentValue = props.data.find(item => item.label === value);
currentValue = currentValue ? currentValue.value : null;
}
let query = SingleDataList.defaultQuery(currentValue, props);
if (customQuery) {
({ query } = customQuery(currentValue, props) || {});
customQueryOptions = getOptionsFromQuery(customQuery(currentValue, props));
}
props.setQueryOptions(props.componentId, customQueryOptions);
props.updateQuery({
componentId: props.componentId,
query,
value: currentValue ? value : null,
label: props.filterLabel,
showFilter: props.showFilter,
URLParams: props.URLParams,
componentType: componentTypes.singleDataList,
});
};
this.internalComponent = `${props.componentId}__internal`;
}
props.addComponent(props.componentId);
props.setComponentProps(props.componentId, props);
if (this.internalComponent) {
props.addComponent(this.internalComponent);
}
this.setReact(props);
if (this.internalComponent && props.defaultQuery) {
this.defaultQuery = props.defaultQuery();
const { query } = this.defaultQuery || {};
const defaultQueryOptions = this.defaultQuery
? getOptionsFromQuery(this.defaultQuery)
: null;
if (defaultQueryOptions) {
props.setQueryOptions(
this.internalComponent,
{ ...defaultQueryOptions, ...this.getAggsQuery() },
false,
);
} else this.props.setQueryOptions(this.internalComponent, this.getAggsQuery());
props.updateQuery({
componentId: this.internalComponent,
query: query || null,
});
}
}
updateQuery = (value, props) => {
const { customQuery } = props;
let query = SingleDropdownList.defaultQuery(value, props);
let customQueryOptions;
if (customQuery) {
({ query } = customQuery(value, props) || {});
customQueryOptions = getOptionsFromQuery(customQuery(value, props));
}
props.setQueryOptions(props.componentId, customQueryOptions);
props.updateQuery({
componentId: props.componentId,
query,
value,
label: props.filterLabel,
showFilter: props.showFilter,
URLParams: props.URLParams,
componentType: componentTypes.singleDropdownList,
});
};
updateDefaultQuery = (value, props) => {
const { defaultQuery } = props;
let defaultQueryOptions;
let query = DataSearch.defaultQuery(value, props);
if (defaultQuery) {
const defaultQueryTobeSet = defaultQuery(value, props) || {};
if (defaultQueryTobeSet.query) {
({ query } = defaultQueryTobeSet);
}
defaultQueryOptions = getOptionsFromQuery(defaultQueryTobeSet);
}
props.setSuggestionsSearchValue(value);
props.setQueryOptions(this.internalComponent, {
...this.queryOptions,
...defaultQueryOptions,
});
props.updateQuery({
componentId: this.internalComponent,
query,
value,
componentType: componentTypes.dataSearch,
});
};
updateDefaultQuery = (value, props, category = this.state.currentCategory) => {
const { defaultQuery } = props;
let defaultQueryOptions;
let query = CategorySearch.defaultQuery(value, props, category);
if (defaultQuery) {
const defaultQueryTobeSet = defaultQuery(value, props, category) || {};
if (defaultQueryTobeSet.query) {
({ query } = defaultQueryTobeSet);
}
defaultQueryOptions = getOptionsFromQuery(defaultQueryTobeSet);
}
props.setSuggestionsSearchValue(value);
const aggsQuery = this.getCombinedAggsQuery();
props.setQueryOptions(this.internalComponent, {
...this.queryOptions,
...aggsQuery,
...defaultQueryOptions,
});
props.updateQuery({
componentId: this.internalComponent,
query,
value,
category,
componentType: componentTypes.categorySearch,
});
};
updateQuery = (value, props) => {
const { customQuery } = props;
let query = MultiList.defaultQuery(value, props);
let customQueryOptions;
if (customQuery) {
({ query } = customQuery(value, props) || {});
customQueryOptions = getOptionsFromQuery(customQuery(value, props));
}
props.setQueryOptions(props.componentId, {
...MultiList.generateQueryOptions(props, this.state.prevAfter),
...customQueryOptions,
});
props.updateQuery({
componentId: props.componentId,
query,
value,
label: props.filterLabel,
showFilter: props.showFilter,
URLParams: props.URLParams,
componentType: componentTypes.multiList,
});
};
} = props;
const selectedDistance = this.getSelectedLabel(distance);
let value = null;
if (selectedDistance) {
value = {
label: selectedDistance.label,
location: this.state.currentLocation,
};
}
let query = this.defaultQuery(this.coordinates, distance, props);
if (customQuery) {
const customQueryTobeSet = customQuery(this.coordinates, distance, props);
if (customQueryTobeSet.query) {
({ query } = customQueryTobeSet);
}
props.setQueryOptions(this.props.componentId, getOptionsFromQuery(customQueryTobeSet));
}
props.updateQuery({
componentId,
query,
value,
label: filterLabel,
showFilter,
URLParams,
});
};