location.js 1.05 KB
export const initialState = {
    startLocation: null,
    finishLocation: null,

    settingLocation: false,

    info: '',
};

export const SET_LOC_REQUEST = 'SET_LOC_REQUEST';
export const SET_LOC_SUCCESS = 'SET_LOC_SUCCESS';
export const SET_LOC_FAILURE = 'SET_LOC_FAILURE';

export default (state = initialState, action) => {
    switch (action.type) {

        case SET_LOC_REQUEST: {
            return {
                ...state,
                settingLocation: true,
            }
        }

        case SET_LOC_SUCCESS: {
            const {startLocation, finishLocation} = action.data;
            return {
                ...state,
                startLocation,
                finishLocation,
                isLoggingIn: false,
            };
        }

        case SET_LOC_FAILURE: {
            const {info} = action.data;
            return {
                ...state,
                settingLocation: false,
                info,
            }
        }

        default: {
            return {
                ...state,
            };
        }
    }
};