@empathyco/x-components
Version:
Empathy X Components
81 lines (65 loc) • 1.96 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@empathyco/x-adapter-platform](./x-adapter-platform.md) > [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
| Parameter | Type | Description |
| --- | --- | --- |
| filters | Record<string, Filter\[\]> | _(Optional)_ The filters from our internal request. |
**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'
];
```