buscar productos por nombre en la tienda

This commit is contained in:
2025-09-02 14:49:51 -04:00
parent 997314b3a5
commit 5ed7f20b24
3 changed files with 27 additions and 14 deletions

View File

@@ -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;