feat(search): implement paginated API fetching for large page sizes

- Removed upper limit on page_size validation to support requests >100
- Added automatic pagination logic to fetch from Open Food Facts API in chunks of 1000
- Accumulates products across multiple API pages until desired count is reached
- Updated error messages and product data fields for consistency
This commit is contained in:
Evandro Fonseca Junior committed 2025-10-09 07:16:26 -03:00
1 parent c173fec668
commit bfb58ef16e
34 files changed
+18630 -7815

No files matched your search

+1 -1
View File
@@ -160,7 +160,7 @@ export async function fetchAllResults(
let currentPage = 1;
let hasMore = true;
let totalCount = 0;
const pageSize = 50; // Usar tamanho máximo permitido pela API
const pageSize = 1000; // Usar tamanho máximo permitido pela API Open Food Facts
console.log(`Iniciando busca completa para: "${query}"`);
+42
View File
@@ -387,3 +387,45 @@ export interface CacheFile {
lastSync: number;
};
}
// Tipos para otimização de carregamento de imagens
export interface OptimizedImageProps {
src: string;
alt: string;
priority?: number;
onPageChange?: number;
className?: string;
fill?: boolean;
width?: number;
height?: number;
sizes?: string;
placeholder?: "blur" | "empty";
blurDataURL?: string;
quality?: number;
loading?: "lazy" | "eager";
onLoad?: () => void;
onError?: (error: Error) => void;
}
export interface ImageLoadTask {
src: string;
priority: number;
load: () => void;
onComplete?: () => void;
onError?: (error: Error) => void;
}
export interface ImageLoadingState {
isVisible: boolean;
shouldLoad: boolean;
isLoading: boolean;
hasError: boolean;
error: Error | null;
}
export interface UseOptimizedImageLoadingOptions {
currentPage: number;
itemsPerPage: number;
rootMargin?: string;
threshold?: number;
}