
import { getIsGuest } from "@utils/cookie-tools";
import { useRouter } from "next/navigation";

export const ReviewButton = ({ setShowForm, className }: { setShowForm: (show: boolean) => void, className?: string }) => {
    const IsGuest = getIsGuest();
    const router = useRouter();
    const handleAddReview = () => {
        if (IsGuest) {
            router.push("/customer/login");
        } else {
            setShowForm(true);
        }
    };

    return (
        <button
            onClick={handleAddReview}
            className={`relative flex w-full min-w-[18rem] max-w-[20rem] cursor-pointer h-fit items-center justify-center rounded-full bg-blue-600 p-4 tracking-wide text-white mt-6 ${className}`}
        > 
            Write a review
        </button>
    )

}