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 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Opus 4.7 committed 2026-04-23 10:25:45 +02:00
1 parent 42e39a1c2b
commit 64da878abb
2 files changed
+23 -20

No files matched your search

+23 -17
View File
@@ -601,23 +601,29 @@ export async function pgGetDashboardData(): Promise<DashboardData> {
];
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<string, string>();
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<string, { stock292: number; stock579: number; stockTotal: number }>();
let fouMap = new Map<string, string>();
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();