41 lines
1001 B
JavaScript
41 lines
1001 B
JavaScript
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
|
|
}
|
|
|
|
case REHYDRATE: return {
|
|
...state,
|
|
loading: false,
|
|
authKey: action.payload.authKeyReducer.authKey,
|
|
error: null
|
|
}
|
|
|
|
default: {
|
|
return state;
|
|
}
|
|
|
|
}
|
|
};
|