Skip to content

Commit

Permalink
feat: added logic to handle dont fetch cactegories on useFacet
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMunizOdoo committed Mar 21, 2022
1 parent 568175d commit 13ffcbf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/composables/src/composables/useFacet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 13ffcbf

Please sign in to comment.