mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-26 20:54:21 +01:00
(bug) product category filter
This commit is contained in:
parent
b2ddc48d51
commit
9eeef449ab
@ -56,7 +56,6 @@ const Products: React.FC<ProductsProps> = ({ onSuccess, onError, uiRouter }) =>
|
||||
const [filtersPanel, setFiltersPanel] = useState<boolean>(true);
|
||||
|
||||
useEffect(() => {
|
||||
fetchProducts();
|
||||
ProductLib.fetchInitialResources(setResources, onError);
|
||||
SettingAPI.get('machines_module').then(data => {
|
||||
setMachinesModule(data.value === 'true');
|
||||
|
@ -76,7 +76,6 @@ const Store: React.FC<StoreProps> = ({ onError, onSuccess, currentUser, uiRouter
|
||||
const [currentPage, setCurrentPage] = useState<number>(1);
|
||||
|
||||
useEffect(() => {
|
||||
fetchProducts();
|
||||
ProductLib.fetchInitialResources(setResources, onError, formatCategories);
|
||||
SettingAPI.get('machines_module').then(data => {
|
||||
setMachinesModule(data.value === 'true');
|
||||
|
@ -151,9 +151,9 @@ export default class ProductLib {
|
||||
const value = ParsingLib.parse(params[key]) || defaultFilters[key];
|
||||
switch (key) {
|
||||
case 'category': {
|
||||
const parents = categories?.filter(c => (value as Array<string>)?.includes(c.slug));
|
||||
// we may also add to the selection children categories
|
||||
res.categories = [...parents, ...categories?.filter(c => parents.map(c => c.id).includes(c.parent_id))];
|
||||
const category = categories?.find(c => c.slug === value);
|
||||
const subCategories = category ? categories?.filter(c => c.parent_id === category.id) : [];
|
||||
res.categories = category ? [category, ...subCategories] : [];
|
||||
break;
|
||||
}
|
||||
case 'categories':
|
||||
|
Loading…
x
Reference in New Issue
Block a user