Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed May 24, 2021
1 parent 747d125 commit 7697ce2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 498 deletions.
29 changes: 26 additions & 3 deletions src/components/manage/Blocks/FiltersBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,10 @@ const View = ({ content, ...props }) => {
metadata.push(dynamicRequests.meta[index]);
}
});
setLoadingData(true);
}

if (!promises?.length) return;
setLoadingData(true);
Promise.all(promises)
.then((response) => {
if (mounted.current) {
Expand Down Expand Up @@ -760,13 +761,35 @@ const View = ({ content, ...props }) => {

const clearFilters = () => {
const newFilters = { ...state.filters };
Object.keys(newFilters).forEach((filter) => {
newFilters[filter] = newFilters[filter].map((value) => null);
const newFiltersMeta = { ...state.filtersMeta };

Object.keys(state.filters).forEach((key) => {
newFilters[key] = [null];
});

Object.keys(state.filtersMeta).forEach((key) => {
if (
['regions', 'river_basins', 'provinces', 'pollutants'].includes(key)
) {
delete newFiltersMeta[key];
} else {
newFiltersMeta[key].filteringInputs = [
{
id: _uniqueId('select_'),
type: 'select',
position: 0,
},
];
}
});


setState({
...state,
filters: newFilters,
filtersMeta: newFiltersMeta,
});

setSitesResults([]);
setLocationResults([]);
setSearchTerm('');
Expand Down
Loading

0 comments on commit 7697ce2

Please sign in to comment.