update tax in summaries

This commit is contained in:
2026-01-14 23:21:02 +03:00
parent 6f1f4441f1
commit 2c676eb153
3 changed files with 24 additions and 8 deletions

View File

@@ -6,15 +6,13 @@ import {
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 { useAppSelector } from "redux/hooks";
import ProText from "../ProText";
import ProTitle from "../ProTitle";
import styles from "./OrderSummary.module.css";
@@ -25,7 +23,7 @@ export default function OrderSummary() {
const { useLoyaltyPoints, splitBillAmount } = useAppSelector(selectCart);
const { subdomain } = useParams();
const { data: restaurant } = useGetRestaurantDetailsQuery(subdomain);
const { orderType, tip } = useAppSelector(selectCart);
const { orderType } = useAppSelector(selectCart);
const subtotal = useAppSelector(selectCartTotal);
const highestLoyaltyItem = useAppSelector(selectHighestPricedLoyaltyItem);
const taxAmount = useAppSelector(selectTaxAmount);
@@ -46,6 +44,8 @@ export default function OrderSummary() {
textAlign: "center",
};
const vat = (restaurant?.vat ?? 0) / 100 * subtotal || 0
return (
<>
<Card className={`${styles.orderSummary}`}>
@@ -159,10 +159,21 @@ export default function OrderSummary() {
{orderType !== OrderType.Redeem && (
<div className={styles.summaryRow}>
<ProText type="secondary" style={titlesStyle}>
{t("cart.tax")}
{t("cart.vatTax")}
</ProText>
<ArabicPrice
price={taxAmount || 0}
price={vat}
textStyle={{ ...titlesStyle, color: "#434E5C" }}
/>
</div>
)}
{orderType !== OrderType.Redeem && (
<div className={styles.summaryRow}>
<ProText type="secondary" style={titlesStyle}>
{t("cart.otherTaxes")}
</ProText>
<ArabicPrice
price={taxAmount - vat || 0}
textStyle={{ ...titlesStyle, color: "#434E5C" }}
/>
</div>