actions.js
2 years ago
constants.js
2 years ago
default.state.js
2 years ago
dispatchers.js
2 years ago
functions.js
2 years ago
index.js
2 years ago
loading.state.js
2 years ago
reducer.js
2 years ago
selectors.js
2 years ago
selectors.js
63 lines
| 1 | import DEFAULT_LOADING_STATE from './loading.state'; |
| 2 | |
| 3 | const self = { |
| 4 | getLoadingIndex( state, actionId ) { |
| 5 | return state.loadingState.findIndex( action => action.id === actionId ); |
| 6 | }, |
| 7 | getLoading( state, actionId ) { |
| 8 | const actionIndex = self.getLoadingIndex( state, actionId ); |
| 9 | |
| 10 | return -1 !== actionIndex |
| 11 | ? state.loadingState[ actionIndex ] |
| 12 | : { ...DEFAULT_LOADING_STATE }; |
| 13 | }, |
| 14 | getCallback( state, actionType ) { |
| 15 | return state.callbacks[ actionType ]; |
| 16 | }, |
| 17 | getDetail( state, actionType ) { |
| 18 | return state.details[ actionType ]; |
| 19 | }, |
| 20 | getComputedFields( state ) { |
| 21 | return state.computedFields; |
| 22 | }, |
| 23 | }; |
| 24 | |
| 25 | export default { |
| 26 | ...self, |
| 27 | isSettingsModal( state ) { |
| 28 | return 'settings' === state.meta?.modalType; |
| 29 | }, |
| 30 | isConditionalModal( state ) { |
| 31 | return 'conditions' === state.meta?.modalType; |
| 32 | }, |
| 33 | getMetaIndex( state ) { |
| 34 | return state.meta?.index; |
| 35 | }, |
| 36 | getCurrentAction( state ) { |
| 37 | return state.currentAction; |
| 38 | }, |
| 39 | getCurrentCallback( state ) { |
| 40 | const type = state.currentAction?.type ?? false; |
| 41 | |
| 42 | return self.getCallback( state, type ); |
| 43 | }, |
| 44 | getCurrentDetail( state ) { |
| 45 | const type = state.currentAction?.type ?? false; |
| 46 | |
| 47 | return self.getDetail( state, type ); |
| 48 | }, |
| 49 | getCurrentSettings( state ) { |
| 50 | const settings = state.currentAction?.settings ?? {}; |
| 51 | const type = state.currentAction?.type ?? false; |
| 52 | |
| 53 | return settings[ type ] ?? {}; |
| 54 | }, |
| 55 | getCurrentLoading( state ) { |
| 56 | const actionId = state.currentAction?.id; |
| 57 | |
| 58 | return self.getLoading( state, actionId ); |
| 59 | }, |
| 60 | dangerGetAllLoading( state ) { |
| 61 | return state.loadingState; |
| 62 | }, |
| 63 | }; |