Merge remote-tracking branch 'origin/main'

This commit is contained in:
2025-11-05 19:15:09 +03:00
3 changed files with 93 additions and 73 deletions

View File

@@ -19,6 +19,7 @@ const LoyaltyCard = () => {
(restaurant?.customer_loyalty_points || 0) <= (restaurant?.customer_loyalty_points || 0) <=
0; 0;
return ( return (
<div className={styles.loyaltyContainer}> <div className={styles.loyaltyContainer}>
<Card className={styles.loyaltyCard}> <Card className={styles.loyaltyCard}>
@@ -35,62 +36,64 @@ const LoyaltyCard = () => {
</div> </div>
</div> </div>
)} )}
<Row {!isHasLoyaltyGift && (
justify="space-between" <Row
align="middle" justify="space-between"
style={{ marginBottom: "0.5rem" }} align="middle"
> style={{ marginBottom: "0.5rem" }}
<Col> >
<Row align="middle" gutter={[8, 8]}> <Col>
<Col> <Row align="middle" gutter={[8, 8]}>
<LoyaltyIcon className={styles.loyaltyIcon} /> <Col>
</Col> <LoyaltyIcon className={styles.loyaltyIcon} />
<Col> </Col>
<ProText style={{ fontSize: "1rem", fontWeight: 400 }}> <Col>
{t("menu.loyaltyPoints")} <ProText style={{ fontSize: "1rem", fontWeight: 400 }}>
</ProText> {t("menu.loyaltyPoints")}
</Col> </ProText>
</Row> </Col>
<ProText </Row>
type="secondary" <ProText
strong type="secondary"
style={{ strong
fontSize: "14px", style={{
fontWeight: 700, fontSize: "14px",
position: "relative", fontWeight: 700,
top: -2, position: "relative",
}} top: -2,
> }}
{token && >
t("menu.loyaltyDescription", { {token &&
value: restaurant?.loyalty_stamps ?? 0, t("menu.loyaltyDescription", {
})} value: restaurant?.loyalty_stamps ?? 0,
{!token && ( })}
<div style={{ paddingTop: 4 }}> {!token && (
<Link <div style={{ paddingTop: 4 }}>
to={`/${subdomain}/login`} <Link
style={{ to={`/${subdomain}/login`}
color: colors.primary, style={{
textDecoration: "underline", color: colors.primary,
fontSize: "14px", textDecoration: "underline",
fontWeight: 400, fontSize: "14px",
padding: "0 4px", fontWeight: 400,
}} padding: "0 4px",
> }}
{t("menu.joinUs")} >
</Link> {t("menu.joinUs")}
<span style={{ fontSize: "14px", color: colors.secondary }}> </Link>
{t("menu.joinUsDescription")} <span style={{ fontSize: "14px", color: colors.secondary }}>
</span> {t("menu.joinUsDescription")}
</div> </span>
)} </div>
</ProText> )}
</Col> </ProText>
<Col> </Col>
<PresentIcon /> <Col>
</Col> <PresentIcon />
</Row> </Col>
{token && ( </Row>
)}
{token && !isHasLoyaltyGift && (
<Row justify="space-between" align="middle"> <Row justify="space-between" align="middle">
<Col> <Col>
<div className={styles.presentIcon}> <div className={styles.presentIcon}>

View File

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

View File

@@ -650,7 +650,11 @@ export const selectGrandTotal = (state: RootState) => {
? Number(state.order.restaurant?.delivery_fees) || 0 ? Number(state.order.restaurant?.delivery_fees) || 0
: 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; export default orderSlice.reducer;