simba-mobile-cud/app/redux/payment/payment.reducer.js

39 lines
910 B
JavaScript
Raw Permalink Normal View History

2025-01-07 09:47:45 +00:00
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
}
};