From c09c7b21dbe59b09a5ac5fdf5b2006002b0b6ee8 Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Wed, 29 Jan 2025 23:47:20 +0330 Subject: [PATCH] updated --- .../api/products/useGetProducts.ts | 29 +++---------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/frontend/composables/api/products/useGetProducts.ts b/frontend/composables/api/products/useGetProducts.ts index ead844f..c31171d 100644 --- a/frontend/composables/api/products/useGetProducts.ts +++ b/frontend/composables/api/products/useGetProducts.ts @@ -20,22 +20,11 @@ export type GetProductsFilters = { // composable -const useGetProducts = (params?: GetProductsFilters) => { +const useGetProducts = (params?: ComputedRef) => { // state const { $axios: axios } = useNuxtApp(); - const { - search, - sort, - in_stock, - has_discount, - category, - price_gte, - price_lte, - page, - } = toRefs(params as GetProductsFilters); - // methods const handleGetProducts = async (params?: GetProductsFilters) => { @@ -50,7 +39,7 @@ const useGetProducts = (params?: GetProductsFilters) => { category: params?.category, price_gte: params?.price_gte, price_lte: params?.price_lte, - offset: params?.page ? Number(params.page) * 9 - 9 : 0, + offset: Number(params?.page) * 9 - 9, limit: 9, }, } @@ -61,18 +50,8 @@ const useGetProducts = (params?: GetProductsFilters) => { return useQuery({ staleTime: 60 * 1000, - queryKey: [ - QUERY_KEYS.products, - search, - sort, - in_stock, - has_discount, - category, - price_gte, - price_lte, - page, - ], - queryFn: () => handleGetProducts(params), + queryKey: [QUERY_KEYS.products, params], + queryFn: () => handleGetProducts(params?.value), }); };