Server IP : 104.21.14.103 / Your IP : 3.145.179.177 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/giankuin/thietke365.net/wp-content/plugins/woocommerce/packages/woocommerce-blocks/assets/js/data/checkout/ |
Upload File : |
/** * Internal dependencies */ import { ACTION_TYPES as types } from './action-types'; import { STATUS } from './constants'; import { defaultState } from './default-state'; import { CheckoutAction } from './actions'; const reducer = ( state = defaultState, action: CheckoutAction ) => { let newState = state; switch ( action.type ) { case types.SET_IDLE: newState = state.status !== STATUS.IDLE ? { ...state, status: STATUS.IDLE, } : state; break; case types.SET_REDIRECT_URL: newState = action.redirectUrl !== undefined && action.redirectUrl !== state.redirectUrl ? { ...state, redirectUrl: action.redirectUrl, } : state; break; case types.SET_COMPLETE: newState = { ...state, status: STATUS.COMPLETE, redirectUrl: typeof action.data?.redirectUrl === 'string' ? action.data.redirectUrl : state.redirectUrl, }; break; case types.SET_PROCESSING: newState = { ...state, status: STATUS.PROCESSING, hasError: false, }; break; case types.SET_BEFORE_PROCESSING: newState = { ...state, status: STATUS.BEFORE_PROCESSING, hasError: false, }; break; case types.SET_AFTER_PROCESSING: newState = { ...state, status: STATUS.AFTER_PROCESSING, }; break; case types.SET_HAS_ERROR: newState = { ...state, hasError: action.hasError, status: state.status === STATUS.PROCESSING || state.status === STATUS.BEFORE_PROCESSING ? STATUS.IDLE : state.status, }; break; case types.INCREMENT_CALCULATING: newState = { ...state, calculatingCount: state.calculatingCount + 1, }; break; case types.DECREMENT_CALCULATING: newState = { ...state, calculatingCount: Math.max( 0, state.calculatingCount - 1 ), }; break; case types.SET_CUSTOMER_ID: if ( action.customerId !== undefined ) { newState = { ...state, customerId: action.customerId, }; } break; case types.SET_USE_SHIPPING_AS_BILLING: if ( action.useShippingAsBilling !== undefined && action.useShippingAsBilling !== state.useShippingAsBilling ) { newState = { ...state, useShippingAsBilling: action.useShippingAsBilling, }; } break; case types.SET_SHOULD_CREATE_ACCOUNT: if ( action.shouldCreateAccount !== undefined && action.shouldCreateAccount !== state.shouldCreateAccount ) { newState = { ...state, shouldCreateAccount: action.shouldCreateAccount, }; } break; case types.SET_PREFERS_COLLECTION: if ( action.prefersCollection !== undefined && action.prefersCollection !== state.prefersCollection ) { newState = { ...state, prefersCollection: action.prefersCollection, }; } break; case types.SET_ORDER_NOTES: if ( action.orderNotes !== undefined && state.orderNotes !== action.orderNotes ) { newState = { ...state, orderNotes: action.orderNotes, }; } break; case types.SET_EXTENSION_DATA: if ( action.extensionData !== undefined && action.namespace !== undefined ) { newState = { ...state, extensionData: { ...state.extensionData, [ action.namespace ]: action.replace ? action.extensionData : { ...state.extensionData[ action.namespace ], ...action.extensionData, }, }, }; } break; } return newState; }; export default reducer;