import { Card, Col, Image, Row } from "antd"; import PresentIcon from "components/Icons/cart/PresentIcon"; import { useTranslation } from "react-i18next"; import { Link, useParams } from "react-router-dom"; import { useGetRestaurantDetailsQuery } from "redux/api/others"; import { ACCESS_TOKEN } from "utils/constants"; import { colors } from "ThemeConstants.ts"; import ProText from "../ProText"; import styles from "./LoyaltyCard.module.css"; import { useAppSelector } from "redux/hooks"; const LoyaltyCard = () => { const { t } = useTranslation(); const { subdomain } = useParams(); const { data: restaurant } = useGetRestaurantDetailsQuery(subdomain); const { isRTL } = useAppSelector((state) => state.locale); const token = localStorage.getItem(ACCESS_TOKEN); const loyaltyStamps = restaurant?.loyalty_stamps ?? 0; const customerLoyaltyPoints = restaurant?.customer_loyalty_points ?? 0; const remainingToNextReward = loyaltyStamps - (customerLoyaltyPoints % loyaltyStamps); return (
{/* */} {t("menu.loyaltyPoints")} {token && customerLoyaltyPoints < loyaltyStamps && t("menu.loyaltyDescription", { value: loyaltyStamps, })} {token && customerLoyaltyPoints >= loyaltyStamps && t("menu.youHaveXEarnedRewardsReadyToRedeem", { rewards: Math.floor(customerLoyaltyPoints / loyaltyStamps), })} {!token && (
{t("menu.joinUs")} {t("menu.joinUsDescription")}
)}
{/* {isHasLoyaltyGift && } */}
{token && ( <>
{Array.from({ length: loyaltyStamps }).map((_, index) => { const currentPoints = customerLoyaltyPoints % loyaltyStamps; const isCollected = index < currentPoints; return ( ); })}
{customerLoyaltyPoints < loyaltyStamps && t("menu.justXMorePurchasesToUnlockYourFREEItem", { cups: remainingToNextReward, })} {customerLoyaltyPoints >= loyaltyStamps && t("menu.youreJustXCupsAwayFromYourNextReward", { cups: remainingToNextReward, })} )}
); }; export default LoyaltyCard;