2020-03-10 13:39:21 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { TYPES } from './constants';
|
|
|
|
|
|
|
|
const {
|
|
|
|
SET_PRISTINE,
|
|
|
|
SET_PROCESSING,
|
|
|
|
SET_REDIRECT_URL,
|
|
|
|
SET_COMPLETE,
|
|
|
|
SET_HAS_ERROR,
|
|
|
|
SET_NO_ERROR,
|
|
|
|
INCREMENT_CALCULATING,
|
|
|
|
DECREMENT_CALCULATING,
|
2020-03-30 14:32:23 +00:00
|
|
|
SET_ORDER_ID,
|
2020-03-10 13:39:21 +00:00
|
|
|
} = TYPES;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* All the actions that can be dispatched for the checkout.
|
|
|
|
*/
|
|
|
|
export const actions = {
|
|
|
|
setPristine: () => ( {
|
|
|
|
type: SET_PRISTINE,
|
|
|
|
} ),
|
|
|
|
setProcessing: () => ( {
|
|
|
|
type: SET_PROCESSING,
|
|
|
|
} ),
|
|
|
|
setRedirectUrl: ( url ) => ( {
|
|
|
|
type: SET_REDIRECT_URL,
|
|
|
|
url,
|
|
|
|
} ),
|
|
|
|
setComplete: () => ( {
|
|
|
|
type: SET_COMPLETE,
|
|
|
|
} ),
|
2020-03-31 19:28:36 +00:00
|
|
|
setHasError: ( hasError = true ) => {
|
|
|
|
const type = hasError ? SET_HAS_ERROR : SET_NO_ERROR;
|
|
|
|
return { type };
|
|
|
|
},
|
2020-03-10 13:39:21 +00:00
|
|
|
incrementCalculating: () => ( {
|
|
|
|
type: INCREMENT_CALCULATING,
|
|
|
|
} ),
|
|
|
|
decrementCalculating: () => ( {
|
|
|
|
type: DECREMENT_CALCULATING,
|
|
|
|
} ),
|
2020-03-30 14:32:23 +00:00
|
|
|
setOrderId: ( orderId ) => ( {
|
|
|
|
type: SET_ORDER_ID,
|
|
|
|
orderId,
|
|
|
|
} ),
|
2020-03-10 13:39:21 +00:00
|
|
|
};
|