import produce from 'immer';
import reducerRegistry from '~/Utils/reducerRegistry';

export const initialState = {
    download: {
      source: '',
      onStart: (event) => {},
      onComplete: (event) => {},
      onError: (event) => {},
      onHttpError: (event) => {},
    },
};

export default function reducer(state = initialState, action = {}) {
    return produce(state, draft => {
        switch (action.type) {
            case DOWNLOAD_FILE:
                draft.download = action.payload;
                break;
        }
    });
}

export const DOWNLOAD_FILE = 'GLOBAL_DOWNLOAD/DOWNLOAD_FILE';
export const downloadAction = payload => ({ type: DOWNLOAD_FILE, payload });
