From 13ffcbfce0887961773bbb6b90fa861360d53634 Mon Sep 17 00:00:00 2001 From: Leonardo Muniz Date: Mon, 21 Mar 2022 13:31:55 -0300 Subject: [PATCH] feat: added logic to handle dont fetch cactegories on useFacet --- packages/composables/src/composables/useFacet/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/composables/src/composables/useFacet/index.ts b/packages/composables/src/composables/useFacet/index.ts index 1bd7f126..05bce331 100644 --- a/packages/composables/src/composables/useFacet/index.ts +++ b/packages/composables/src/composables/useFacet/index.ts @@ -21,17 +21,21 @@ const factoryParams = { filter: { categoryId: params?.input?.filter?.categoryId, attributeValueId: params.input?.filter?.attributeValueId?.map(id => parseInt(id)), + attribValues: params.input?.filter?.attribValues?.map(id => id), minPrice: parseInt(params?.input?.minPrice), maxPrice: parseInt(params?.input?.maxPrice) } }; - const { data } = await context.$odoo.api.getCategory(categoryParams, customQueryCategories); + let categoryResponse = null; + if (params.input.fetchCategory) { + categoryResponse = await context.$odoo.api.getCategory(categoryParams, customQueryCategories); + } const { data: productData } = await context.$odoo.api.getProductTemplatesList(productParams, customQueryProducts); return { - categories: data.categories.categories, + categories: categoryResponse?.data?.categories?.categories || null, products: productData.products.products, attributes: productData.products.attributeValues, itemsPerPage: 1,