buscar productos por nombre en la tienda
This commit is contained in:
@@ -20,11 +20,11 @@ export function useAllProductQuery(params: Params = {}) {
|
||||
return useSafeQuery(['product',params], () => getAllProducts(params))
|
||||
}
|
||||
|
||||
export function useAllProductInfiniteQuery() {
|
||||
export function useAllProductInfiniteQuery(search: string = '') {
|
||||
return useSafeInfiniteQuery(
|
||||
['product'],
|
||||
['product', search],
|
||||
// pageParam + 1 para evitar duplicación de datos
|
||||
({ pageParam = 0 }) => getAllProducts({ page: pageParam + 1, limit: 10 }),
|
||||
({ pageParam = 0 }) => getAllProducts({ page: pageParam + 1, limit: 10, search }),
|
||||
(lastPage, allPages) => {
|
||||
// Esta lógica determina el 'pageParam' para la siguiente página
|
||||
const nextPage = allPages.length;
|
||||
|
||||
Reference in New Issue
Block a user