"use client";
import Link from "next/link";
import React, {useEffect, useState} from "react";

export default function ReservationButton({isSticky}: {isSticky: boolean}) {
  const [show, setShow] = useState(false);
  useEffect(() => {
    const handleScroll = () => {
      if (window.scrollY > 1000) {
        setShow(true);
      } else {
        setShow(false);
      }
    };
    window.addEventListener("scroll", handleScroll);

    return () => window.removeEventListener("scroll", handleScroll);
  }, []);
  return (
    <>
      {show && (
        <Link
          href={"/contact-us#request_accept"}
          dir="ltr"
          className={`bg-secondary text-white rounded-full ${
            isSticky ? "py-4 px-4" : "py-4 px-6"
          }  font-extrabold shadow-lg flex items-center whitespace-nowrap  shadow-neutral-300 hover:shadow-none transition-all duration-200`}
        >

            دریافت
             نوبت آنلاین

        </Link>
      )}
    </>
  );
}
