diff --git a/src/components/LoyaltyCard/LoyaltyCard.tsx b/src/components/LoyaltyCard/LoyaltyCard.tsx
index 7744481..aca8b14 100644
--- a/src/components/LoyaltyCard/LoyaltyCard.tsx
+++ b/src/components/LoyaltyCard/LoyaltyCard.tsx
@@ -19,6 +19,7 @@ const LoyaltyCard = () => {
(restaurant?.customer_loyalty_points || 0) <=
0;
+
return (
@@ -35,62 +36,64 @@ const LoyaltyCard = () => {
)}
-
-
-
-
-
-
-
-
- {t("menu.loyaltyPoints")}
-
-
-
-
- {token &&
- t("menu.loyaltyDescription", {
- value: restaurant?.loyalty_stamps ?? 0,
- })}
- {!token && (
-
-
- {t("menu.joinUs")}
-
-
- {t("menu.joinUsDescription")}
-
-
- )}
-
-
-
-
-
-
- {token && (
+ {!isHasLoyaltyGift && (
+
+
+
+
+
+
+
+
+ {t("menu.loyaltyPoints")}
+
+
+
+
+ {token &&
+ t("menu.loyaltyDescription", {
+ value: restaurant?.loyalty_stamps ?? 0,
+ })}
+ {!token && (
+
+
+ {t("menu.joinUs")}
+
+
+ {t("menu.joinUsDescription")}
+
+
+ )}
+
+
+
+
+
+
+ )}
+ {token && !isHasLoyaltyGift && (
diff --git a/src/components/OrderSummary/OrderSummary.tsx b/src/components/OrderSummary/OrderSummary.tsx
index b8fb973..5896860 100644
--- a/src/components/OrderSummary/OrderSummary.tsx
+++ b/src/components/OrderSummary/OrderSummary.tsx
@@ -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);
@@ -44,13 +46,21 @@ export default function OrderSummary() {
{t("cart.basketTotal")}
- {orderType != OrderType.DineIn &&
-
{t("cart.deliveryFee")}
-
-
}
+ {orderType != OrderType.DineIn && (
+
+
{t("cart.deliveryFee")}
+
+
+ )}
{t("cart.tax")}
@@ -65,7 +75,7 @@ export default function OrderSummary() {
- {isHasLoyaltyGift && (
+ {isHasLoyaltyGift && restaurant?.is_loyalty_enabled === 1 && (
<>
@@ -86,14 +96,17 @@ export default function OrderSummary() {
)}
- {isHasLoyaltyGift && useLoyaltyPoints && highestLoyaltyItem && (
-
- {t("cart.loyaltyDiscountApplied", {
- itemName: highestLoyaltyItem.name,
- amount: Math.round(highestLoyaltyItem.price || 0).toFixed(2),
- })}
-
- )}
+ {isHasLoyaltyGift &&
+ useLoyaltyPoints &&
+ highestLoyaltyItem &&
+ restaurant?.is_loyalty_enabled === 1 && (
+
+ {t("cart.loyaltyDiscountApplied", {
+ itemName: highestLoyaltyItem.name,
+ amount: Math.round(highestLoyaltyItem.price || 0).toFixed(2),
+ })}
+
+ )}
>
);
diff --git a/src/features/order/orderSlice.ts b/src/features/order/orderSlice.ts
index 6fb7cff..f2506a7 100644
--- a/src/features/order/orderSlice.ts
+++ b/src/features/order/orderSlice.ts
@@ -650,7 +650,11 @@ export const selectGrandTotal = (state: RootState) => {
? Number(state.order.restaurant?.delivery_fees) || 0
: 0;
- return subtotal + taxAmount - loyaltyDiscount + deliveryFee;
-};
+ return (
+ subtotal +
+ taxAmount -
+ (state.order.useLoyaltyPoints && state.order.restaurant?.is_loyalty_enabled === 1 ? loyaltyDiscount : 0) +
+ deliveryFee
+ );};
export default orderSlice.reducer;