apply SplitBillChoiceBottomSheet logic

This commit is contained in:
2025-12-04 01:11:09 +03:00
parent 265fb4b983
commit 29423036cd
9 changed files with 770 additions and 26 deletions

View File

@@ -69,6 +69,7 @@ interface CartState {
pickupTime: string;
pickupType: string;
order: any;
splitBillAmount: number;
}
// localStorage keys
@@ -185,6 +186,7 @@ const initialState: CartState = {
pickupTime: getFromLocalStorage(CART_STORAGE_KEYS.PICKUP_TIME, ""),
pickupType: getFromLocalStorage(CART_STORAGE_KEYS.PICKUP_TYPE, ""),
order: getFromLocalStorage(CART_STORAGE_KEYS.ORDER, null),
splitBillAmount: 0,
};
const orderSlice = createSlice({
@@ -632,6 +634,9 @@ const orderSlice = createSlice({
localStorage.setItem(CART_STORAGE_KEYS.ORDER, JSON.stringify(state.order));
}
},
updateSplitBillAmount(state, action: PayloadAction<number>) {
state.splitBillAmount = action.payload;
},
},
});
@@ -669,6 +674,7 @@ export const {
updatePickupTime,
updatePickUpType,
updateOrder,
updateSplitBillAmount,
} = orderSlice.actions;
// Tax calculation helper functions
@@ -775,7 +781,7 @@ export const selectGrandTotal = (state: RootState) => {
? Number(state.order.restaurant?.delivery_fees) || 0
: 0;
return subtotal + taxAmount - totalDiscount + deliveryFee;
return subtotal + taxAmount - totalDiscount + deliveryFee - state.order.splitBillAmount;
};
export default orderSlice.reducer;