ilink-world/redux/reducers/AuthKeyReducer.js

41 lines
1001 B
JavaScript
Raw Normal View History

2020-04-18 19:59:05 +00:00
import { AUTH_KEY_PENDING, AUTH_KEY_SUCCESS, AUTH_KEY_ERROR } from "../types/AuthKeyType";
import { REHYDRATE } from "redux-persist";
const initialState = {
loading: false,
authKey: null,
error: null,
};
export default (state = initialState, action) => {
switch (action.type) {
case AUTH_KEY_PENDING: return {
...state,
loading: true
}
case AUTH_KEY_SUCCESS: return {
...state,
loading: false,
authKey: action.result.data,
error: null
}
case AUTH_KEY_ERROR: return {
...state,
loading: false,
error: action.result
}
2020-04-18 23:19:11 +00:00
case REHYDRATE: return {
...state,
loading: false,
authKey: action.payload.authKeyReducer.authKey,
error: null
}
2020-04-18 19:59:05 +00:00
default: {
return state;
}
}
};