Fixes search queries on collection modal.

This commit is contained in:
mateuswetah 2020-09-25 17:48:40 -03:00
parent 489611152d
commit a8610d96c1
1 changed files with 12 additions and 6 deletions

View File

@ -69,10 +69,18 @@ export default class CollectionModal extends React.Component {
paged: this.state.collectionPage
}
if (this.props.filterOptionsBy && Object.keys(this.props.filterOptionsBy).length !== 0)
query = {...query, meta_query: this.props.filterOptionsBy}
if (this.props.filterOptionsBy && Object.keys(this.props.filterOptionsBy).length !== 0) {
let metaqueries = [];
for (let metaquery of Object.keys(this.props.filterOptionsBy)) {
metaqueries.push({
key: metaquery,
value: this.props.filterOptionsBy[metaquery]
})
}
query = {...query, metaquery: metaqueries}
}
let endpoint = '/collections/?' + qs.stringify(query);
if (this.state.collectionOrderBy == 'date')
@ -146,14 +154,12 @@ export default class CollectionModal extends React.Component {
for (let metaquery of Object.keys(this.props.filterOptionsBy)) {
metaqueries.push({
key: metaquery,
value: this.props.filterOptionsBy[key]
value: this.props.filterOptionsBy[metaquery]
})
}
query = {...query, metaquery: metaqueries}
}
let endpoint = '/collections/?' + qs.stringify(query);
if (name != undefined && name != '')