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

const initialState = {
    data: {},
    isFetching: false,
    error: null
};

export default function (state = initialState, action) {

    switch (action.type) {
        case ACTION.PERSONAL_DATA_REQUEST: {
            return {
                ...state,
                isFetching: true,
                error: null
            }
        }
        case ACTION.PERSONAL_DATA_RESPONSE: {
            return {
                ...state,
                data: action.data,
                isFetching: false,
                error: null
            }
        }
        case ACTION.PERSONAL_DATA_ERROR: {
            return {
                ...state,
                error: action.error.response.data,
                isFetching: false
            }
        }
        default: {
            return state
        }
    }
}

