simba-mobile-cud/app/redux/reducers/AuthKeyReducer.js

41 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

2025-01-07 09:47:45 +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
}
case REHYDRATE: return {
...state,
loading: false,
authKey: typeof action.payload !== 'undefined' ? action.payload.authKeyReducer.authKey : null,
error: null
}
default: {
return state;
}
}
};