"use client";

import { useState, useEffect, type ComponentPropsWithoutRef } from "react";
import { CookieConsentBanner } from "./cookie-consent-banner";

export type CookieConsentBannerLoaderProps = ComponentPropsWithoutRef<
  typeof CookieConsentBanner
>;

/**
 * SSR-safe wrapper that renders null on the server and mounts
 * <CookieConsentBanner> client-side only (after hydration).
 */
export function CookieConsentBannerLoader(
  props: CookieConsentBannerLoaderProps,
) {
  const [mounted, setMounted] = useState(false);

  useEffect(() => {
    setMounted(true);
  }, []);

  if (!mounted) return null;

  return <CookieConsentBanner {...props} />;
}
