OrderSummary: add use loyalty points checkbox
This commit is contained in:
@@ -52,6 +52,7 @@ interface CartState {
|
||||
phone: string;
|
||||
paymentMethod: string;
|
||||
orderType: string;
|
||||
useLoyaltyPoints: boolean;
|
||||
}
|
||||
|
||||
// localStorage keys
|
||||
@@ -72,6 +73,7 @@ export const CART_STORAGE_KEYS = {
|
||||
PHONE: 'fascano_phone',
|
||||
PAYMENT_METHOD: 'fascano_payment_method',
|
||||
ORDER_TYPE: 'fascano_order_type',
|
||||
USE_LOYALTY_POINTS: 'fascano_use_loyalty_points',
|
||||
} as const;
|
||||
|
||||
// Utility functions for localStorage
|
||||
@@ -105,6 +107,7 @@ const initialState: CartState = {
|
||||
phone: getFromLocalStorage(CART_STORAGE_KEYS.PHONE, ""),
|
||||
paymentMethod: getFromLocalStorage(CART_STORAGE_KEYS.PAYMENT_METHOD, ""),
|
||||
orderType: getFromLocalStorage(CART_STORAGE_KEYS.ORDER_TYPE, ""),
|
||||
useLoyaltyPoints: getFromLocalStorage(CART_STORAGE_KEYS.USE_LOYALTY_POINTS, false),
|
||||
};
|
||||
|
||||
const orderSlice = createSlice({
|
||||
@@ -308,6 +311,14 @@ const orderSlice = createSlice({
|
||||
localStorage.setItem(CART_STORAGE_KEYS.ORDER_TYPE, JSON.stringify(state.orderType));
|
||||
}
|
||||
},
|
||||
updateUseLoyaltyPoints(state, action: PayloadAction<boolean>) {
|
||||
state.useLoyaltyPoints = action.payload;
|
||||
|
||||
// Sync to localStorage
|
||||
if (typeof window !== 'undefined') {
|
||||
localStorage.setItem(CART_STORAGE_KEYS.USE_LOYALTY_POINTS, JSON.stringify(state.useLoyaltyPoints));
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -333,6 +344,7 @@ export const {
|
||||
updatePhone,
|
||||
updatePaymentMethod,
|
||||
updateOrderType,
|
||||
updateUseLoyaltyPoints,
|
||||
reset,
|
||||
} = orderSlice.actions;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user