refactor the use of plain string order types

This commit is contained in:
2025-10-28 13:29:52 +03:00
parent 7aa686166b
commit 1abb63e8bd
16 changed files with 73 additions and 58 deletions

View File

@@ -53,7 +53,7 @@ interface CartState {
collectionMethod: string;
phone: string;
paymentMethod: string;
orderType: string;
orderType: OrderType | "";
useLoyaltyPoints: boolean;
loyaltyValidationError: string | null;
}
@@ -127,7 +127,7 @@ const initialState: CartState = {
),
phone: getFromLocalStorage(CART_STORAGE_KEYS.PHONE, ""),
paymentMethod: getFromLocalStorage(CART_STORAGE_KEYS.PAYMENT_METHOD, ""),
orderType: getFromLocalStorage(CART_STORAGE_KEYS.ORDER_TYPE, ""),
orderType: getFromLocalStorage(CART_STORAGE_KEYS.ORDER_TYPE, "" as OrderType | ""),
useLoyaltyPoints: getFromLocalStorage(
CART_STORAGE_KEYS.USE_LOYALTY_POINTS,
false,
@@ -435,7 +435,7 @@ const orderSlice = createSlice({
);
}
},
updateOrderType(state, action: PayloadAction<string>) {
updateOrderType(state, action: PayloadAction<OrderType>) {
state.orderType = action.payload;
// Sync to localStorage
@@ -604,7 +604,7 @@ export const selectGrandTotal = (state: RootState) => {
const taxAmount = selectTaxAmount(state);
const subtotal = selectCartTotal(state);
const deliveryFee =
state.order.orderType != OrderType.DineIn
state.order.orderType !== OrderType.DineIn
? Number(state.order.restaurant?.delivery_fees) || 0
: 0;