"use client";

import { useConsent } from "@/components/cookie-consent/ConsentProvider";
import { GoogleAnalytics } from "@next/third-parties/google";

export function Analytics() {
  const { hasAnalyticsConsent, isReady } = useConsent();
  const gaId = process.env.NEXT_PUBLIC_GA_ID;

  // Google Analytics : ne charger que si consentement
  if (!isReady || !hasAnalyticsConsent || !gaId) return null;

  return <GoogleAnalytics gaId={gaId} />;
}
