import * as types from "../actionTypes/actionTypes";

const initialState = {
    user: {},
	showProfile: false
}

export default (state = initialState, action) => {
    switch (action.type) {
        case types.POST_REQUEST_LOGIN: {
            return state;
        }

        case types.POST_REQUEST_SUCCESS_LOGIN: {
            //action.payload.message
            console.log('user:', action.payload.user);
            //localStorage.setItem('userName', `${action.payload.user.name}`);
            localStorage.setItem('showProfile', "true");
            localStorage.setItem(
                "user",
                JSON.stringify(action.payload.user)
            )
            return {
                ...state,
                user: action.payload.user,
				showProfile: true
            };
        }

        case types.POST_REQUEST_ERROR_LOGIN: {
            console.log('error');
            return state;
        }

        default:
            return state;
    }
}