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

const initialState = {
    reviews: [],
    reloadPage: false
}

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

        case types.GET_REQUEST_SUCCESS_REVIEWS: {
            //console.log('reviews', action.payload.results);
            return {
                ...state,
                reviews: action.payload.results
            };
        }

        case types.GET_REQUEST_ERROR_REVIEWS: {
            console.log('error reviews', action.payload.message);
            return state;
        }

        case types.POST_REQUEST_REVIEW: {
            return state;
        }

        case types.POST_REQUEST_SUCCESS_REVIEW: {
            //console.log('review', action.payload);
            return state;
            /*return {
                ...state,
                reloadPage: !state.reloadPage
            };*/
        }

        case types.POST_REQUEST_ERROR_REVIEW: {
            console.log('error reviews', action.payload.message);
            return state;
        }

        default:
            return state;
    }
}