fix: remove function prop, unused import and useSearchParams in analytics

- page.tsx: move formatCA into client component (functions not serializable
  across server→client boundary in Next.js — root cause of 500)
- client.tsx: remove unused BarChart2 import
- client.tsx: replace useSearchParams() with direct URL construction to
  avoid Suspense boundary requirement
- pg-ff-client: use OR conditions instead of IN() for Drizzle compatibility

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Sonnet 4.6 committed 2026-03-31 10:32:21 +02:00
1 parent c9df9feccd
commit 7e8b50e143
2 files changed
+11 -23

No files matched your search

+11 -13
View File
@@ -1,7 +1,6 @@
"use client"; "use client";
import { useRouter, useSearchParams } from "next/navigation"; import { useRouter } from "next/navigation";
import { BarChart2 } from "lucide-react";
interface AnalyticsClientProps { interface AnalyticsClientProps {
mode: string; mode: string;
@@ -30,7 +29,14 @@ interface AnalyticsClientProps {
evolutionTotal292: number | null; evolutionTotal292: number | null;
evolutionTotal579: number | null; evolutionTotal579: number | null;
evolutionTotalReseau: number | null; evolutionTotalReseau: number | null;
formatCA: (value: number) => string; }
function formatCA(value: number): string {
return new Intl.NumberFormat("fr-FR", {
style: "currency",
currency: "EUR",
maximumFractionDigits: 0,
}).format(value);
} }
function EvolutionBadge({ value }: { value: number | null }) { function EvolutionBadge({ value }: { value: number | null }) {
@@ -58,23 +64,15 @@ export function AnalyticsClient({
evolutionTotal292, evolutionTotal292,
evolutionTotal579, evolutionTotal579,
evolutionTotalReseau, evolutionTotalReseau,
formatCA,
}: AnalyticsClientProps) { }: AnalyticsClientProps) {
const router = useRouter(); const router = useRouter();
const searchParams = useSearchParams();
const handleModeChange = (newMode: string) => { const handleModeChange = (newMode: string) => {
const params = new URLSearchParams(searchParams); router.push(`/analytics?mode=${newMode}&mois=${mois}`);
params.set("mode", newMode);
params.set("mois", mois);
router.push(`/analytics?${params.toString()}`);
}; };
const handleMonthChange = (newMois: string) => { const handleMonthChange = (newMois: string) => {
const params = new URLSearchParams(searchParams); router.push(`/analytics?mode=${mode}&mois=${newMois}`);
params.set("mode", mode);
params.set("mois", newMois);
router.push(`/analytics?${params.toString()}`);
}; };
// Générer liste des 24 derniers mois // Générer liste des 24 derniers mois
-10
View File
@@ -8,15 +8,6 @@ function getMoisN1(mois: string): string {
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}`; return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}`;
} }
// Formatage courant français
function formatCA(value: number): string {
return new Intl.NumberFormat("fr-FR", {
style: "currency",
currency: "EUR",
maximumFractionDigits: 0,
}).format(value);
}
// Helper pivot : transformer les lignes de requête en tableau pivotté par site // Helper pivot : transformer les lignes de requête en tableau pivotté par site
function pivotData( function pivotData(
rows: Array<{ code: string; label: string; site: string; mois: string; ca_ttc: number }>, rows: Array<{ code: string; label: string; site: string; mois: string; ca_ttc: number }>,
@@ -145,7 +136,6 @@ export default async function AnalyticsPage(props: {
evolutionTotal292={evolutionTotal292} evolutionTotal292={evolutionTotal292}
evolutionTotal579={evolutionTotal579} evolutionTotal579={evolutionTotal579}
evolutionTotalReseau={evolutionTotalReseau} evolutionTotalReseau={evolutionTotalReseau}
formatCA={formatCA}
/> />
</div> </div>
</div> </div>