34 lines
849 B
JavaScript
Executable File
34 lines
849 B
JavaScript
Executable File
import { DEPOSIT_PENDING, DEPOSIT_SUCCESS, DEPOSIT_ERROR, DEPOSIT_RESET } from "../types/DepositType";
|
|
|
|
const initialState = {
|
|
loading: false,
|
|
result: null,
|
|
error: null
|
|
};
|
|
|
|
export default (state = initialState, action) => {
|
|
switch (action.type) {
|
|
case DEPOSIT_PENDING: return {
|
|
...state,
|
|
loading: true
|
|
}
|
|
case DEPOSIT_SUCCESS: return {
|
|
...state,
|
|
loading: false,
|
|
result: action.result.data,
|
|
error: null
|
|
}
|
|
case DEPOSIT_ERROR: return {
|
|
...state,
|
|
loading: false,
|
|
result: null,
|
|
error: action.result
|
|
}
|
|
case DEPOSIT_RESET: return initialState;
|
|
|
|
default: {
|
|
return state;
|
|
}
|
|
}
|
|
};
|