Skip to content

Commit

Permalink
feat: make use of fetchByFilter's customFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
p-runge committed Feb 21, 2022
1 parent e7f1fc1 commit f0e97ed
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions components/fsxa/sections/products/CategoryProducts.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Dataset, QueryBuilderQuery } from 'fsxa-api'
import type { Dataset, CustomFilter, QueryBuilderQuery } from 'fsxa-api'
import { ComparisonQueryOperatorEnum } from 'fsxa-api'
import { FSXABaseSection } from 'fsxa-pattern-library'
import { Component } from 'vue-property-decorator'
Expand Down Expand Up @@ -57,9 +57,18 @@ class CategoryProducts extends FSXABaseSection<Payload> {
value: this.payload.filterParams.category
})
}
const customFilter: CustomFilter = (items) =>
items.filter((item) => {
if (typeof item === 'object' && 'id' in (item as object)) {
return (item as Record<'id', string>).id.charAt(0) === '9'
}

return false
})
const { items } = await this.fsxaApi.fetchByFilter({
filters: params,
locale: this.locale
locale: this.locale,
customFilter
})
this.setStoredItem(this.storedKey, items)
}
Expand Down

0 comments on commit f0e97ed

Please sign in to comment.