/* like mutation */
import ACTION from '../actions/actiontsTypes';

const initialState = {
    settings: {
        city: '',
        cityId: '',
        street: ''
    },
    data: [],
    isFetching: false,
    error: null
};

export default function (state = initialState, action) {
    switch (action.type) {
        case ACTION.DYNAMIC_SEARCH_LOCATION_REQUEST: {
            return {
                ...state,
                settings: action.settings,
                isFetching: true,
                error: null
            }
        }
        case ACTION.DYNAMIC_SEARCH_LOCATION_RESPONSE: {
            return {
                ...state,
                data: action.data,
                isFetching: false,
                error: null
            }
        }
        case ACTION.DYNAMIC_SEARCH_LOCATION_ERROR: {
            return {
                ...state,
                error: action.error,
                isFetching: false
            }
        }
        default: {
            return state
        }
    }
}

