ReviewButton.tsx 864 B

12345678910111213141516171819202122232425
  1. import { IS_GUEST } from "@utils/constants";
  2. import { getCookie } from "@utils/getCartToken";
  3. import { useRouter } from "next/navigation";
  4. export const ReviewButton = ({ setShowForm, className }: { setShowForm: (show: boolean) => void, className?: string }) => {
  5. const IsGuest = getCookie(IS_GUEST);
  6. const router = useRouter();
  7. const handleAddReview = () => {
  8. if (IsGuest === "true" || IsGuest === null) {
  9. router.push("/customer/login");
  10. } else {
  11. setShowForm(true);
  12. }
  13. };
  14. return (
  15. <button
  16. onClick={handleAddReview}
  17. 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}`}
  18. >
  19. Write a review
  20. </button>
  21. )
  22. }