From eb6ca34162669c5d46a373c8b3710c3b73824792 Mon Sep 17 00:00:00 2001 From: Mohammed Al-yaseen Date: Wed, 14 Jan 2026 00:00:53 +0300 Subject: [PATCH] loyalty: enhance card texts --- src/assets/locals/ar.json | 5 +- src/assets/locals/en.json | 5 +- src/components/LoyaltyCard/LoyaltyCard.tsx | 104 +++++++++++++-------- 3 files changed, 73 insertions(+), 41 deletions(-) diff --git a/src/assets/locals/ar.json b/src/assets/locals/ar.json index 4c9e88f..d74d771 100644 --- a/src/assets/locals/ar.json +++ b/src/assets/locals/ar.json @@ -130,7 +130,7 @@ "payDescription": "الدفع", "rating": "التقييم ", "loyaltyPoints": "نقاط الولاء", - "loyaltyDescription": "اشترى {{value}} وجبات واحصل على وجبة مجانية", + "loyaltyDescription": "اشترى {{value}} وجبات واحصل على وجبة مجانية!", "youMightAlsoLike": "قد تعجبك أيضاً..", "choose1": "اختر 1", "specialRequest": "طلب خاص", @@ -165,7 +165,8 @@ "restaurantIsClosed": "المطعم مغلق", "address": "العنوان", "openingTimes": "ساعات العمل", - "customizable": "قابل للتخصيص" + "customizable": "قابل للتخصيص", + "youHaveXEarnedRewardsReadyToRedeem": "🎉 لديك {{rewards}} مكافأة مستحقة للاستخدام!" }, "cart": { "addSpecialRequestOptional": "إضافة طلب خاص (اختياري)", diff --git a/src/assets/locals/en.json b/src/assets/locals/en.json index 307b1ad..50361f4 100644 --- a/src/assets/locals/en.json +++ b/src/assets/locals/en.json @@ -144,7 +144,7 @@ "close": "Close", "rating": "Rating ", "loyaltyPoints": "Loyalty Points", - "loyaltyDescription": "Buy {{value}} meals and get 1 FREE", + "loyaltyDescription": "Buy {{value}} meals and get 1 FREE!", "choose1": "Choose 1", "youMightAlsoLike": "You might also like..", "specialRequest": "Special Request", @@ -177,7 +177,8 @@ "payDescription": "Pay for your order", "address": "Address", "openingTimes": "Opening Times", - "customizable": "Customizable" + "customizable": "Customizable", + "youHaveXEarnedRewardsReadyToRedeem": "🎉 You have {{rewards}} rewards ready to redeem!" }, "cart": { "remainingToPay": "Remaining to Pay", diff --git a/src/components/LoyaltyCard/LoyaltyCard.tsx b/src/components/LoyaltyCard/LoyaltyCard.tsx index 6fdd636..cf2ec50 100644 --- a/src/components/LoyaltyCard/LoyaltyCard.tsx +++ b/src/components/LoyaltyCard/LoyaltyCard.tsx @@ -15,10 +15,10 @@ const LoyaltyCard = () => { const { data: restaurant } = useGetRestaurantDetailsQuery(subdomain); const { isRTL } = useAppSelector((state) => state.locale); const token = localStorage.getItem(ACCESS_TOKEN); - const isHasLoyaltyGift = - (restaurant?.loyalty_stamps || 0) - - (restaurant?.customer_loyalty_points || 0) <= - 0; + const loyaltyStamps = restaurant?.loyalty_stamps ?? 0; + const customerLoyaltyPoints = restaurant?.customer_loyalty_points ?? 0; + const remainingToNextReward = + loyaltyStamps - (customerLoyaltyPoints % loyaltyStamps); return (
@@ -62,8 +62,14 @@ const LoyaltyCard = () => { }} > {token && + customerLoyaltyPoints < loyaltyStamps && t("menu.loyaltyDescription", { - value: restaurant?.loyalty_stamps ?? 0, + value: loyaltyStamps, + })} + {token && + customerLoyaltyPoints >= loyaltyStamps && + t("menu.youHaveXEarnedRewardsReadyToRedeem", { + rewards: Math.floor(customerLoyaltyPoints / loyaltyStamps), })} {!token && (
@@ -95,40 +101,64 @@ const LoyaltyCard = () => { )} - {isHasLoyaltyGift && } + {/* {isHasLoyaltyGift && } */} {token && ( -
- {Array.from({ length: restaurant?.loyalty_stamps || 0 }).map( - (_, index) => { - const currentPoints = restaurant?.customer_loyalty_points || 0; - const isCollected = index < currentPoints; - return ( - - - - ); - }, - )} -
+ <> +
+ {Array.from({ length: loyaltyStamps }).map( + (_, index) => { + const currentPoints = customerLoyaltyPoints % loyaltyStamps; + const isCollected = index < currentPoints; + return ( + + + + ); + }, + )} +
+ + {customerLoyaltyPoints < loyaltyStamps && + t("rewardsAndLoyalty.youreJustXCupsAwayFromYourNextReward", { + cups: remainingToNextReward, + })} + {customerLoyaltyPoints >= loyaltyStamps && + t("rewardsAndLoyalty.youreJustXCupsAwayFromYourNextReward", { + cups: remainingToNextReward, + })} + + )}