mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-23 15:08:12 +02:00
feat: implement infinite grid pagination with server-side data fetching and custom hook
This commit is contained in:
1 parent
4db7faa41f
commit
2893114fca
6 files changed
+302
-27
No files matched your search
@@ -33,16 +33,16 @@ export default async function GridPage({ searchParams }: GridPageProps) {
|
||||
return <SupplierSelectionLanding fournisseurs={fournisseurs} />;
|
||||
}
|
||||
|
||||
// 3. Load product data — résultat mis en cache 5 min par fournisseur (unstable_cache).
|
||||
// La première requête est lente mais les suivantes (refresh, navigation) sont instantanées.
|
||||
console.log(`\n>>> [GridPage] Fetching data for: ${codeFournisseur}, shop: ${magasin}`);
|
||||
const rows = await getGridData(codeFournisseur, magasin, filters);
|
||||
console.log(`>>> [GridPage] Received ${rows.length} rows from getGridData`);
|
||||
// 3. Load product data — pagination pour ne pas crasher le JS client
|
||||
console.log(`\n>>> [GridPage] Fetching page 0 for: ${codeFournisseur}, shop: ${magasin}`);
|
||||
const { rows: initialRows, total } = await getGridData(codeFournisseur, magasin, filters, 0, 200);
|
||||
console.log(`>>> [GridPage] Received ${initialRows.length}/${total} rows from getGridData`);
|
||||
const selectedFournisseur = fournisseurs.find((f: { code: string; nom: string }) => f.code === codeFournisseur);
|
||||
|
||||
return (
|
||||
<GridClient
|
||||
initialRows={rows}
|
||||
initialRows={initialRows}
|
||||
initialTotal={total}
|
||||
codeFournisseur={codeFournisseur}
|
||||
nomFournisseur={selectedFournisseur?.nom || "Fournisseur inconnu"}
|
||||
fournisseurs={fournisseurs}
|
||||
|
||||
Reference in new issue
Block a user