enhance loyalty card

This commit is contained in:
2025-11-05 19:05:10 +03:00
parent 27f522e75c
commit d7a56ba929
3 changed files with 80 additions and 68 deletions

View File

@@ -11,6 +11,7 @@ import {
} from "features/order/orderSlice";
import { OrderType } from "pages/checkout/hooks/types";
import { useTranslation } from "react-i18next";
import { useParams } from "react-router-dom";
import { useGetRestaurantDetailsQuery } from "redux/api/others";
import { useAppDispatch, useAppSelector } from "redux/hooks";
import ProText from "../ProText";
@@ -20,7 +21,8 @@ import styles from "./OrderSummary.module.css";
export default function OrderSummary() {
const { t } = useTranslation();
const { useLoyaltyPoints } = useAppSelector(selectCart);
const { data: restaurant } = useGetRestaurantDetailsQuery("595");
const { subdomain } = useParams();
const { data: restaurant } = useGetRestaurantDetailsQuery(subdomain);
const { orderType } = useAppSelector(selectCart);
const dispatch = useAppDispatch();
const subtotal = useAppSelector(selectCartTotal);
@@ -53,7 +55,11 @@ export default function OrderSummary() {
<div className={styles.summaryRow}>
<ProText type="secondary">{t("cart.discount")}</ProText>
<ArabicPrice
price={useLoyaltyPoints ? highestLoyaltyItem?.price || 0 : 0}
price={
useLoyaltyPoints && restaurant?.is_loyalty_enabled === 1
? highestLoyaltyItem?.price || 0
: 0
}
/>
</div>
<div className={styles.summaryRow}>
@@ -69,7 +75,7 @@ export default function OrderSummary() {
</div>
</Space>
{isHasLoyaltyGift && (
{isHasLoyaltyGift && restaurant?.is_loyalty_enabled === 1 && (
<>
<br />
<br />
@@ -90,14 +96,17 @@ export default function OrderSummary() {
</div>
)}
{isHasLoyaltyGift && useLoyaltyPoints && highestLoyaltyItem && (
<div style={{ marginTop: 8, color: "green", fontSize: "12px" }}>
{t("cart.loyaltyDiscountApplied", {
itemName: highestLoyaltyItem.name,
amount: Math.round(highestLoyaltyItem.price || 0).toFixed(2),
})}
</div>
)}
{isHasLoyaltyGift &&
useLoyaltyPoints &&
highestLoyaltyItem &&
restaurant?.is_loyalty_enabled === 1 && (
<div style={{ marginTop: 8, color: "green", fontSize: "12px" }}>
{t("cart.loyaltyDiscountApplied", {
itemName: highestLoyaltyItem.name,
amount: Math.round(highestLoyaltyItem.price || 0).toFixed(2),
})}
</div>
)}
</Card>
</>
);