41 lines
1.0 KiB
JavaScript
Executable File
41 lines
1.0 KiB
JavaScript
Executable File
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: typeof action.payload !== 'undefined' ? action.payload.authKeyReducer.authKey : null,
|
|
error: null
|
|
}
|
|
|
|
default: {
|
|
return state;
|
|
}
|
|
|
|
}
|
|
};
|