39 lines
910 B
JavaScript
39 lines
910 B
JavaScript
import PaymentActions from "./payment.type";
|
|
|
|
|
|
const INITIAL_STATE = {
|
|
loading: false,
|
|
result: null,
|
|
error: null,
|
|
};
|
|
|
|
export const paymentMethodsReducer = (state = INITIAL_STATE, action) => {
|
|
switch (action.type) {
|
|
case PaymentActions.PAYMENT_METHOD_PENDING:
|
|
return {
|
|
...state,
|
|
loading: true
|
|
}
|
|
case PaymentActions.PAYMENT_METHOD_SUCCESS:
|
|
return {
|
|
loading: false,
|
|
result: action.payload,
|
|
error: null
|
|
}
|
|
case PaymentActions.PAYMENT_METHOD_ERROR:
|
|
return {
|
|
...state,
|
|
loading: false,
|
|
result: null,
|
|
error: action.payload
|
|
}
|
|
|
|
case PaymentActions.PAYMENT_METHOD_RESET:
|
|
return INITIAL_STATE;
|
|
|
|
default:
|
|
return state
|
|
|
|
}
|
|
};
|