import { Card, Checkbox, Divider, Space, Tag } from "antd"; import ArabicPrice from "components/ArabicPrice"; import { selectCart, selectCartTotal, selectDiscountTotal, selectGrandTotal, selectHighestPricedLoyaltyItem, selectLoyaltyValidation, selectTaxAmount, updateUseLoyaltyPoints, } 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"; import ProTitle from "../ProTitle"; import styles from "./OrderSummary.module.css"; import { CSSProperties } from "react"; export default function OrderSummary() { const { t } = useTranslation(); const { useLoyaltyPoints, splitBillAmount } = useAppSelector(selectCart); const { subdomain } = useParams(); const { data: restaurant } = useGetRestaurantDetailsQuery(subdomain); const { orderType, tip } = useAppSelector(selectCart); const dispatch = useAppDispatch(); const subtotal = useAppSelector(selectCartTotal); const loyaltyValidation = useAppSelector(selectLoyaltyValidation); const highestLoyaltyItem = useAppSelector(selectHighestPricedLoyaltyItem); const taxAmount = useAppSelector(selectTaxAmount); const grandTotal = useAppSelector(selectGrandTotal); const discountAmount = useAppSelector(selectDiscountTotal); const isHasLoyaltyGift = (restaurant?.loyalty_stamps ?? 0) - (restaurant?.customer_loyalty_points ?? 0) <= 0; const titlesStyle: CSSProperties = { fontWeight: 400, fontStyle: "Regular", fontSize: 16, lineHeight: "140%", letterSpacing: "0%", textAlign: "center", }; return ( <> {t("cart.orderSummary")}
{t("cart.basketTotal")}
{orderType === OrderType.Delivery && (
{t("cart.deliveryFee")}
)} {orderType !== OrderType.Redeem && (
{t("cart.discount")}
{isHasLoyaltyGift && useLoyaltyPoints && highestLoyaltyItem && restaurant?.is_loyalty_enabled === 1 ? ( {t("cart.loyalty")} ) : null}
)} {orderType !== OrderType.Redeem && (
{t("cart.tip")}
)} {orderType === OrderType.Redeem && (
{t("cart.giftedItems")}
)} {orderType === OrderType.Redeem && (
{t("cart.voucherApplied")}
)} {orderType !== OrderType.Redeem && (
{t("cart.tax")}
)} {orderType !== OrderType.Redeem && splitBillAmount > 0 && (
{t("splitBill.splitBillAmount")}
)}
{orderType === OrderType.Redeem ? t("cart.remainingToPay") : t("cart.totalAmount")}
); }