29 lines
773 B
JavaScript
29 lines
773 B
JavaScript
import { WALLET_LIST_PENDING, WALLET_LIST_SUCCESS, WALLET_LIST_ERROR } from "../types/WalletType";
|
|
|
|
const initialState = {
|
|
loading: false,
|
|
result: null,
|
|
error: null,
|
|
};
|
|
|
|
export const walletReducer = (state = initialState, action) => {
|
|
switch (action.type) {
|
|
case WALLET_LIST_PENDING: return {
|
|
...state,
|
|
loading: true
|
|
}
|
|
case WALLET_LIST_SUCCESS: return {
|
|
...state,
|
|
loading: true,
|
|
result: action.result,
|
|
error: null
|
|
}
|
|
case WALLET_LIST_ERROR: return {
|
|
...state,
|
|
loading: false,
|
|
result: action.result,
|
|
error: action.result.statusText,
|
|
}
|
|
|
|
}
|
|
}; |