working on gift flow

This commit is contained in:
2025-10-20 00:57:07 +03:00
parent 6214e2c0f5
commit a131c9147a
19 changed files with 137 additions and 62 deletions

View File

@@ -30,6 +30,7 @@ export interface GiftDetailsType {
message: string;
senderName: string;
senderPhone: string;
senderEmail: string;
isSecret: boolean;
}
@@ -50,6 +51,7 @@ interface CartState {
collectionMethod: string;
phone: string;
paymentMethod: string;
orderType: string;
}
// localStorage keys
@@ -69,6 +71,7 @@ export const CART_STORAGE_KEYS = {
COLLECTION_METHOD: 'fascano_collection_method',
PHONE: 'fascano_phone',
PAYMENT_METHOD: 'fascano_payment_method',
ORDER_TYPE: 'fascano_order_type',
} as const;
// Utility functions for localStorage
@@ -101,6 +104,7 @@ const initialState: CartState = {
collectionMethod: getFromLocalStorage(CART_STORAGE_KEYS.COLLECTION_METHOD, ""),
phone: getFromLocalStorage(CART_STORAGE_KEYS.PHONE, ""),
paymentMethod: getFromLocalStorage(CART_STORAGE_KEYS.PAYMENT_METHOD, ""),
orderType: getFromLocalStorage(CART_STORAGE_KEYS.ORDER_TYPE, ""),
};
const orderSlice = createSlice({
@@ -164,7 +168,7 @@ const orderSlice = createSlice({
state.paymentMethod = "";
// Clear all cart data from localStorage
if (typeof window !== 'undefined') {
Object.values(CART_STORAGE_KEYS).forEach(key => {
Object.values(CART_STORAGE_KEYS).filter(key => key !== CART_STORAGE_KEYS.ORDER_TYPE).forEach(key => {
localStorage.removeItem(key);
});
}
@@ -296,6 +300,14 @@ const orderSlice = createSlice({
localStorage.setItem(CART_STORAGE_KEYS.PAYMENT_METHOD, JSON.stringify(state.paymentMethod));
}
},
updateOrderType(state, action: PayloadAction<string>) {
state.orderType = action.payload;
// Sync to localStorage
if (typeof window !== 'undefined') {
localStorage.setItem(CART_STORAGE_KEYS.ORDER_TYPE, JSON.stringify(state.orderType));
}
},
},
});
@@ -320,6 +332,7 @@ export const {
updateCollectionMethod,
updatePhone,
updatePaymentMethod,
updateOrderType,
reset,
} = orderSlice.actions;