UNPKG

@empathyco/x-components

Version:
111 lines (77 loc) 2.09 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@empathyco/x-adapter-platform](./x-adapter-platform.md) &gt; [mapFilters](./x-adapter-platform.mapfilters.md) ## mapFilters() function Converts the filters to the shape the Platform's API is expecting. **Signature:** ```typescript export declare function mapFilters(filters?: Record<string, Filter[]>): string[]; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> filters </td><td> Record&lt;string, Filter\[\]&gt; </td><td> _(Optional)_ The filters from our internal request. </td></tr> </tbody></table> **Returns:** string\[\] The filters ready to be consumed for the API. ## Example ```ts const filters = { offer: [ { facetId: 'offer', modelName: 'SimpleFilter', id: 'price:[0 TO 10]', selected: true, label: 'In Offer' } as SimpleFilter ], categoryPaths: [ { facetId: 'categoryPaths', id: 'categoryIds:ffc61e1e9__be257cb26', label: 'Fragrance', modelName: 'HierarchicalFilter', parentId: 'categoryIds:ffc61e1e9', selected: true, totalResults: 1 }, { facetId: 'categoryPaths', id: 'categoryIds:ffc61e1e9__fa5ef54f2', label: 'Fragrance', modelName: 'HierarchicalFilter', parentId: 'categoryIds:ffc61e1e9', selected: true, totalResults: 1 }, { children: ['categoryIds:ffc61e1e9__be257cb26', 'categoryIds:ffc61e1e9__fa5ef54f2'], facetId: 'categoryPaths', id: 'categoryIds:ffc61e1e9', label: 'Personal Care', modelName: 'HierarchicalFilter', parentId: null, selected: true, totalResults: 1 } ] }; const mappedFilters = mapFilters({ filters }); mappedFilters is [ 'price:[0 TO 10]', 'categoryIds:ffc61e1e9__be257cb26', 'categoryIds:ffc61e1e9__fa5ef54f2' ]; ```