From 64da878abb0e4012a3c5145d27c2df45ec3fbe35 Mon Sep 17 00:00:00 2001 From: R0m1k3 Date: Thu, 23 Apr 2026 10:25:45 +0200 Subject: [PATCH] fix: remove deprecated eslint config and make dashboard DB enrichment optional - Remove unsupported `eslint` key from next.config.ts (Next.js 16) - Wrap dashboard DB enrichment in try/catch so the dashboard renders even when PostgreSQL is unavailable, preventing the "Impossible de charger le tableau de bord" error Co-Authored-By: Claude Opus 4.7 --- next.config.ts | 3 --- src/lib/pg-ff-client.ts | 40 +++++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/next.config.ts b/next.config.ts index 4422251..703bf8b 100644 --- a/next.config.ts +++ b/next.config.ts @@ -10,9 +10,6 @@ const nextConfig = { typescript: { ignoreBuildErrors: true, }, - eslint: { - ignoreDuringBuilds: true, - }, }; export default nextConfig; diff --git a/src/lib/pg-ff-client.ts b/src/lib/pg-ff-client.ts index 037cd81..bff6749 100644 --- a/src/lib/pg-ff-client.ts +++ b/src/lib/pg-ff-client.ts @@ -601,23 +601,29 @@ export async function pgGetDashboardData(): Promise { ]; const allCodeins = [...new Set(allItems.map(i => i.codein).filter(Boolean))]; - // Enrichissement : stock et fournisseur via PostgreSQL - const [stockMap, fouResult] = await Promise.all([ - pgGetStockForCodeins(allCodeins), - pgNoParallel(sql` - SELECT - a.codein, - COALESCE(fi.nom, af.code, 'Sans fournisseur')::text AS fournisseur - FROM articles a - LEFT JOIN artfou1 af ON af.art_no_id = a.no_id AND af.preference = 1 - LEFT JOIN fouident fi ON fi.code = af.code - WHERE a.codein = ANY(string_to_array(${allCodeins.join(",")}, ',')) - `), - ]); - - const fouMap = new Map(); - for (const row of fouResult.rows as unknown as { codein: string; fournisseur: string }[]) { - if (row.codein) fouMap.set(row.codein, row.fournisseur); + // Enrichissement : stock et fournisseur via PostgreSQL (optionnel — le dashboard + // s'affiche même si la DB n'est pas configurée). + let stockMap = new Map(); + let fouMap = new Map(); + try { + const [sm, fouResult] = await Promise.all([ + pgGetStockForCodeins(allCodeins), + pgNoParallel(sql` + SELECT + a.codein, + COALESCE(fi.nom, af.code, 'Sans fournisseur')::text AS fournisseur + FROM articles a + LEFT JOIN artfou1 af ON af.art_no_id = a.no_id AND af.preference = 1 + LEFT JOIN fouident fi ON fi.code = af.code + WHERE a.codein = ANY(string_to_array(${allCodeins.join(",")}, ',')) + `), + ]); + stockMap = sm; + for (const row of fouResult.rows as unknown as { codein: string; fournisseur: string }[]) { + if (row.codein) fouMap.set(row.codein, row.fournisseur); + } + } catch (enrichErr) { + console.warn("[Dashboard] DB enrichment unavailable, continuing with API data only:", enrichErr); } const siteSet = [...new Set(allItems.map(i => i.site).filter(Boolean))].sort();