mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-11 17:26:32 +02:00
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:
1 parent
c9df9feccd
commit
7e8b50e143
2 files changed
+11
-23
No files matched your search
@@ -1,7 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { BarChart2 } from "lucide-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
interface AnalyticsClientProps {
|
||||
mode: string;
|
||||
@@ -30,7 +29,14 @@ interface AnalyticsClientProps {
|
||||
evolutionTotal292: number | null;
|
||||
evolutionTotal579: 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 }) {
|
||||
@@ -58,23 +64,15 @@ export function AnalyticsClient({
|
||||
evolutionTotal292,
|
||||
evolutionTotal579,
|
||||
evolutionTotalReseau,
|
||||
formatCA,
|
||||
}: AnalyticsClientProps) {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const handleModeChange = (newMode: string) => {
|
||||
const params = new URLSearchParams(searchParams);
|
||||
params.set("mode", newMode);
|
||||
params.set("mois", mois);
|
||||
router.push(`/analytics?${params.toString()}`);
|
||||
router.push(`/analytics?mode=${newMode}&mois=${mois}`);
|
||||
};
|
||||
|
||||
const handleMonthChange = (newMois: string) => {
|
||||
const params = new URLSearchParams(searchParams);
|
||||
params.set("mode", mode);
|
||||
params.set("mois", newMois);
|
||||
router.push(`/analytics?${params.toString()}`);
|
||||
router.push(`/analytics?mode=${mode}&mois=${newMois}`);
|
||||
};
|
||||
|
||||
// Générer liste des 24 derniers mois
|
||||
|
||||
@@ -8,15 +8,6 @@ function getMoisN1(mois: string): string {
|
||||
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
|
||||
function pivotData(
|
||||
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}
|
||||
evolutionTotal579={evolutionTotal579}
|
||||
evolutionTotalReseau={evolutionTotalReseau}
|
||||
formatCA={formatCA}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user