import { Card, Checkbox, Divider, Space } 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 } = 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")}
)}
{t("cart.discount")}
{t("cart.tax")}
{splitBillAmount > 0 && (
{t("splitBill.splitBillAmount")}
)}
{t("cart.totalAmount")}
{isHasLoyaltyGift && restaurant?.is_loyalty_enabled === 1 && ( <> { dispatch(updateUseLoyaltyPoints(value.target.checked)); }} style={{ marginTop: 8 }} > {t("cart.useLoyaltyPoints")} )} {isHasLoyaltyGift && loyaltyValidation.errorMessage && (
{t(loyaltyValidation.errorMessage)}
)} {isHasLoyaltyGift && useLoyaltyPoints && highestLoyaltyItem && restaurant?.is_loyalty_enabled === 1 && (
{t("cart.loyaltyDiscountApplied", { itemName: highestLoyaltyItem.name, amount: Math.round(highestLoyaltyItem.price || 0).toFixed(2), })}
)}
); }