send pick up type
This commit is contained in:
@@ -65,8 +65,9 @@ interface CartState {
|
||||
scheduledDate: string;
|
||||
discount: DiscountData;
|
||||
plateCar: string;
|
||||
pickupDate: string,
|
||||
pickupTime: string
|
||||
pickupDate: string;
|
||||
pickupTime: string;
|
||||
pickupType: string;
|
||||
}
|
||||
|
||||
// localStorage keys
|
||||
@@ -95,7 +96,8 @@ export const CART_STORAGE_KEYS = {
|
||||
PLATE: "fascano_plate_car",
|
||||
PICKUP_DATE: "fascano_pickup_date",
|
||||
PICKUP_TIME: "fascano_pickup_time",
|
||||
} as const;
|
||||
PICKUP_TYPE: "fascano_pickup_type",
|
||||
} as const;
|
||||
|
||||
// Utility functions for localStorage
|
||||
const getFromLocalStorage = <T>(key: string, defaultValue: T): T => {
|
||||
@@ -179,6 +181,7 @@ const initialState: CartState = {
|
||||
plateCar: getFromLocalStorage(CART_STORAGE_KEYS.PLATE, ""),
|
||||
pickupDate: getFromLocalStorage(CART_STORAGE_KEYS.PICKUP_DATE, ""),
|
||||
pickupTime: getFromLocalStorage(CART_STORAGE_KEYS.PICKUP_TIME, ""),
|
||||
pickupType: getFromLocalStorage(CART_STORAGE_KEYS.PICKUP_TYPE, ""),
|
||||
};
|
||||
|
||||
const orderSlice = createSlice({
|
||||
@@ -610,7 +613,16 @@ const orderSlice = createSlice({
|
||||
JSON.stringify(state.pickupTime),
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
updatePickUpType(state, action: PayloadAction<string>) {
|
||||
state.pickupType = action.payload;
|
||||
if (typeof window !== "undefined") {
|
||||
localStorage.setItem(
|
||||
CART_STORAGE_KEYS.PICKUP_TYPE,
|
||||
JSON.stringify(state.pickupType),
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -646,6 +658,7 @@ export const {
|
||||
updateDiscount,
|
||||
updatePickupDate,
|
||||
updatePickupTime,
|
||||
updatePickUpType,
|
||||
} = orderSlice.actions;
|
||||
|
||||
// Tax calculation helper functions
|
||||
@@ -690,9 +703,8 @@ export const selectCartItemsQuantityById =
|
||||
// Loyalty selectors
|
||||
const selectOrderItems = (state: RootState) => state.order.items;
|
||||
|
||||
export const selectLoyaltyItems = createSelector(
|
||||
[selectOrderItems],
|
||||
(items) => items.filter((item) => item.isHasLoyalty),
|
||||
export const selectLoyaltyItems = createSelector([selectOrderItems], (items) =>
|
||||
items.filter((item) => item.isHasLoyalty),
|
||||
);
|
||||
|
||||
export const selectHighestPricedLoyaltyItem = (state: RootState) => {
|
||||
|
||||
Reference in New Issue
Block a user