import type { URLSearchParamsInit } from "react-router-dom";

export default function removeQueryParameter(
  setSearchParams: (
    nextInit: URLSearchParamsInit,
    navigateOptions?:
      | {
          replace?: boolean | undefined;
          state?: Record<string, unknown> | null | undefined;
        }
      | undefined,
  ) => void,
  ...parametersToRemove: string[]
): void {
  const queryParams = new URLSearchParams(window.location.search);
  parametersToRemove.forEach((parameterKey) => {
    if (queryParams.has(parameterKey)) {
      queryParams.delete(parameterKey);
      setSearchParams(queryParams);
    }
  });
}
