Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { AUTH_FAILURE, AUTH_REQ, AUTH_SUCCESS } from "types/authTypes";
- import { combineReducers } from "redux";
- import auth from './auth';
- const initialState = {
- users: {},
- error: "",
- loading: false,
- };
- export const auth = (state = initialState, action: any) => {
- switch (action.type) {
- case AUTH_REQ:
- return { ...state, error: "", loading: true };
- case AUTH_SUCCESS:
- const data = action.payload;
- return { ...state, error:'', loading:false, user: data };
- case AUTH_FAILURE:
- const error = action.payload;
- return { ...state, loading: false, error: error };
- default:
- return state;
- }
- };
- //Combine Reducers
- export default combineReducers({
- auth
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement