Untitled
unknown
javascript
a year ago
1.1 kB
11
Indexable
if (search && Object.keys(search).length) {
let context = '';
try {
//context = JSON.parse(search?.active_context ?? '{}');
context = search?.active_context ?? '{}';
} catch (e) {
console.error('Error parsing search context', e);
}
if (context) {
const filters = context.split(',').filter((f) =>
f.length > 0
&& f[0].includes('search_default')
&& f[1].trim().toLowerCase() === 'true');
// const filters = Object.entries(context).filter(([key, value]) =>
// key.includes('search_default'),
// );
if (filters.length > 0) {
window.localStorage.setItem(
`selected-filters-{"menuId":${menuId},"action":${action}}`,
JSON.stringify(
filters.reduce((acc: any, key) => {
const name = key.replace('search_default_', '');
return [
...acc,
{
columnLabel: undefined,
columnSlug: name,
columnType: undefined,
condition: '=',
label: `${name} = ${true}`,
type: 'text',
value: true,
},
];
}, []),
),
);
isFilterUsed = search.active_domain ? true : false;
}
}Editor is loading...
Leave a Comment