"use client";

import { useEffect } from "react";
import { useSearchParams } from "next/navigation";

export default function ScrollOnParam({
  sectionRef,
}: {
  sectionRef: React.RefObject<HTMLDivElement | null>;
}) {
  const searchParams = useSearchParams();

  useEffect(() => {
    const shouldScroll = searchParams.get("scroll") === "designHouse";
    if (shouldScroll && sectionRef.current) {
      sectionRef.current.scrollIntoView({ behavior: "smooth" });
    }
  }, [searchParams, sectionRef]);

  return null;
}
