"use client";

import * as React from "react";
import { usePathname, useSearchParams } from "next/navigation";

/**
 * Forces a full remount of the leads pipeline when the URL changes or this route segment mounts again
 * (fresh React state / effects — helps stale client state after navigation or bfcache).
 */
export function LeadsPageRemount({ children }: { children: React.ReactNode }) {
  const pathname = usePathname();
  const searchParams = useSearchParams();
  const instanceId = React.useId();
  const remountKey = `${instanceId}|${pathname}?${searchParams.toString()}`;

  return <React.Fragment key={remountKey}>{children}</React.Fragment>;
}
