apply loyalty discount logic
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import { message } from "antd";
|
||||
import { clearCart, selectCart } from "features/order/orderSlice";
|
||||
import {
|
||||
clearCart,
|
||||
selectCart,
|
||||
selectCartTotalWithLoyaltyDiscount,
|
||||
selectHighestPricedLoyaltyItem,
|
||||
} from "features/order/orderSlice";
|
||||
import { useCallback } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
@@ -29,6 +34,10 @@ export default function useOrder() {
|
||||
orderType,
|
||||
giftDetails,
|
||||
} = useAppSelector(selectCart);
|
||||
const highestLoyaltyItem = useAppSelector(selectHighestPricedLoyaltyItem);
|
||||
const { useLoyaltyPoints } = useAppSelector(selectCart);
|
||||
|
||||
const orderPrice = useAppSelector(selectCartTotalWithLoyaltyDiscount);
|
||||
|
||||
const [createOrder] = useCreateOrderMutation();
|
||||
|
||||
@@ -59,10 +68,8 @@ export default function useOrder() {
|
||||
pickup_comments: "",
|
||||
pickup_time: estimateTime,
|
||||
delivery_pickup_interval: "",
|
||||
orderPrice: items.reduce(
|
||||
(acc, item) => acc + item.price * item.quantity,
|
||||
0,
|
||||
),
|
||||
orderPrice: orderPrice,
|
||||
use_loylaty: useLoyaltyPoints && highestLoyaltyItem ? 1 : 0,
|
||||
useWallet: 0,
|
||||
tip,
|
||||
...(orderType === "gift"
|
||||
@@ -74,7 +81,7 @@ export default function useOrder() {
|
||||
senderEmail: giftDetails?.senderEmail,
|
||||
senderPhone: giftDetails?.senderPhone,
|
||||
senderName: giftDetails?.senderName,
|
||||
dineType: orderType
|
||||
dineType: orderType,
|
||||
}
|
||||
: {}),
|
||||
})
|
||||
@@ -120,6 +127,7 @@ export default function useOrder() {
|
||||
user_uuid,
|
||||
estimateTime,
|
||||
tip,
|
||||
orderPrice,
|
||||
t,
|
||||
navigate,
|
||||
dispatch,
|
||||
|
||||
Reference in New Issue
Block a user