revert: restore grid to pre-infinite-scroll state

Remove infinite grid loading, useInfiniteGrid hook, and server-side
pagination API route. Revert grid components to the simpler version
that avoids 2MB+ cache failures from unstable_cache.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Sonnet 4.6 committed 2026-04-03 11:26:13 +02:00
1 parent bd21f07c8e
commit 2aa9cbecaa
8 files changed
+40 -422

No files matched your search

+5 -25
View File
@@ -7,8 +7,6 @@ import type { GammeCode, GridFilters, GridSummary, ProductRow } from "@/types/gr
interface GridState {
/** Source data from server */
rows: ProductRow[];
/** Index O(1) pour les lookups par codein (Map<codein, ProductRow>) */
rowsIndex: Map<string, ProductRow>;
/** Draft edits: codein → new GammeCode */
draftChanges: Record<string, GammeCode>;
filters: GridFilters;
@@ -27,7 +25,6 @@ interface GridState {
// Actions
setRows: (rows: ProductRow[]) => void;
appendRows: (newRows: ProductRow[]) => void;
setDraftGamme: (codein: string, gamme: GammeCode) => void;
resetDrafts: () => void;
/** Clear specific draft changes by codein */
@@ -67,7 +64,6 @@ export const useGridStore = create<GridState>()(
persist(
(set, get) => ({
rows: [],
rowsIndex: new Map(),
activeMagasin: "TOTAL",
draftChanges: {},
filters: {
@@ -98,27 +94,12 @@ export const useGridStore = create<GridState>()(
},
setRows: (rows) => {
// Construire l'index en O(n) une seule fois au lieu de O(n) à chaque lookup.
const rowsIndex = new Map<string, ProductRow>(rows.map(r => [r.codein, r]));
set({ rows, rowsIndex, summary: computeSummary(rows, get().draftChanges, get().activeMagasin) });
},
appendRows: (newRows) => {
const { rows, rowsIndex, draftChanges, activeMagasin } = get();
// O(n) uniquement sur les nouveaux éléments, au lieu de re-calculer les 130k existants
const mergedRows = [...rows, ...newRows];
newRows.forEach(r => rowsIndex.set(r.codein, r));
set({
rows: mergedRows,
rowsIndex,
summary: computeSummary(mergedRows, draftChanges, activeMagasin)
});
set({ rows, summary: computeSummary(rows, get().draftChanges, get().activeMagasin) });
},
setDraftGamme: (codein, gamme) => {
const { rows, rowsIndex, draftChanges: oldDrafts } = get();
// Lookup O(1) via l'index au lieu de O(n) via .find()
const originalRow = rowsIndex.get(codein);
const { rows, draftChanges: oldDrafts } = get();
const originalRow = rows.find(r => r.codein === codein);
const originalGamme = originalRow?.codeGamme;
const draftChanges = { ...oldDrafts };
@@ -163,12 +144,11 @@ export const useGridStore = create<GridState>()(
},
batchSetDraftGamme: (newChanges) => {
const { rows, rowsIndex, draftChanges: oldDrafts } = get();
const { rows, draftChanges: oldDrafts } = get();
const updatedDrafts = { ...oldDrafts };
Object.entries(newChanges).forEach(([codein, gamme]) => {
// Lookup O(1) via l'index au lieu de O(n) via .find()
const originalRow = rowsIndex.get(codein);
const originalRow = rows.find(r => r.codein === codein);
const originalGamme = originalRow?.codeGamme;
if (gamme === originalGamme) {