All files / @docs/producer/store reducers.js

100% Statements 14/14
100% Branches 5/5
100% Functions 5/5
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50      1x                               1x               1x 1x 1x 1x         1x               6x 4x     2x    
import { SET_LOADING, SET_FILE_URI, SET_PAGES, SET_PREVIEW_VISIBLE } from './constants';
 
const scanbotIosLicense =
  'AV1iIRwO11hbTlE2qjot18WsADk+r9' +
  'HrKg8UaW77RlE0ADSW+L/vL5EtZ0SN' +
  '8cASH5R1vrSyC/dMoj86qLJ5tVuZAT' +
  'xXOWzrdUChoe7JDQ4WqBAQZjjPBpLh' +
  'TH8amtO3mZbrI5LYHy9QJWXic9sZ1b' +
  'c1dEKvDYMMYY4XN+tCOb1gu74oX2KL' +
  'S9Z6jHzxpGtz+uHnhNzg6gWk2IZ1XB' +
  'DutJZHdf3pwCBdftCIx6OPMRG6784S' +
  'BpvVAF0cMZRdALKzhIYxvuireD+e2b' +
  'imgnJ3gciqojTMFDiOrFZ7bdANRCsl' +
  'Z8/Aa/f3NC28U4Pgjdp4tnS2/wz5QS' +
  '8+35w4ZjnPwQ==\nU2NhbmJvdFNESw' +
  'pjb20ua29uc3RydWt0b3IuR3JvdXBl' +
  'TXV0dWVsCjE2NjE1NTgzOTkKNTkwCj' +
  'E=\n';
 
const initialState = {
  loading: false,
  fileUri: null,
  pages: [],
  previewVisible: false,
  scanbotLicense: scanbotIosLicense,
};
 
const setLoading = (state, action) => ({ ...state, loading: action.payload.loading });
const setFileUri = (state, action) => ({ ...state, fileUri: action.payload.fileUri });
const setPages = (state, action) => ({ ...state, pages: action.payload.pages });
const setPreviewVisible = (state, action) => ({
  ...state,
  previewVisible: action.payload.previewVisible,
});
 
const FUNCTION_BY_ACTION = {
  [SET_LOADING]: setLoading,
  [SET_FILE_URI]: setFileUri,
  [SET_PAGES]: setPages,
  [SET_PREVIEW_VISIBLE]: setPreviewVisible,
};
 
export default (state = initialState, action) => {
  if (action && action.type in FUNCTION_BY_ACTION) {
    return FUNCTION_BY_ACTION[action.type](state, action);
  }
 
  return state;
};