diff --git a/src/app/(dashboard)/dashboard/page.tsx b/src/app/(dashboard)/dashboard/page.tsx index 6291d0c..30dbc94 100644 --- a/src/app/(dashboard)/dashboard/page.tsx +++ b/src/app/(dashboard)/dashboard/page.tsx @@ -300,10 +300,12 @@ export default async function DashboardPage() { try { data = await pgGetDashboardData(); } catch (e) { + const msg = e instanceof Error ? e.message : String(e); + console.error("[Dashboard] pgGetDashboardData failed:", e); return (

- Impossible de charger le tableau de bord : {(e as Error).message?.slice(0, 200)} + Impossible de charger le tableau de bord : {msg.slice(0, 500)}

); diff --git a/src/lib/pg-ff-client.ts b/src/lib/pg-ff-client.ts index 7a82db5..5e310bf 100644 --- a/src/lib/pg-ff-client.ts +++ b/src/lib/pg-ff-client.ts @@ -532,7 +532,10 @@ export async function pgGetDashboardData(): Promise { AND s.site IN ('292', '579') GROUP BY s.site ORDER BY s.site - `), + `).catch((err) => { + console.error("[pg-ff] statopcajour query failed:", err.message); + return { rows: [] }; + }), // QTE + Marge + Lignes par site depuis mvtart (cumstat = 1) pgNoParallel(sql` SELECT @@ -547,7 +550,7 @@ export async function pgGetDashboardData(): Promise { AND m.site IN ('292', '579') GROUP BY m.site ORDER BY m.site - `), + `).catch((err) => { console.error("[pg-ff] mvtSites query failed:", err.message); return { rows: [] }; }), // Top 10 CA réseau hier (cumstat = 1) pgNoParallel(sql` SELECT @@ -565,7 +568,7 @@ export async function pgGetDashboardData(): Promise { GROUP BY a.codein, a.libelle1 ORDER BY ca DESC LIMIT 10 - `), + `).catch((err) => { console.error("[pg-ff] top10Ca query failed:", err.message); return { rows: [] }; }), // Top 10 QTE réseau hier (cumstat = 1) pgNoParallel(sql` SELECT @@ -583,7 +586,7 @@ export async function pgGetDashboardData(): Promise { GROUP BY a.codein, a.libelle1 ORDER BY qte DESC LIMIT 10 - `), + `).catch((err) => { console.error("[pg-ff] top10Qte query failed:", err.message); return { rows: [] }; }), // Top 10 Marge réseau hier (cumstat = 1) pgNoParallel(sql` SELECT @@ -601,7 +604,7 @@ export async function pgGetDashboardData(): Promise { GROUP BY a.codein, a.libelle1 ORDER BY marge DESC LIMIT 10 - `), + `).catch((err) => { console.error("[pg-ff] top10Marge query failed:", err.message); return { rows: [] }; }), // Évolution mensuelle sur 25 mois (cumstat = 1) pgNoParallel(sql` SELECT @@ -617,7 +620,7 @@ export async function pgGetDashboardData(): Promise { AND m.site IN ('292', '579') GROUP BY TO_CHAR(m.datmvt, 'YYYY-MM') ORDER BY mois - `), + `).catch((err) => { console.error("[pg-ff] evolution query failed:", err.message); return { rows: [] }; }), ]); // Fusionner CA+tickets (statopcajour) avec QTE+marge (mvtart) par site