This repository has been archived by the owner on Sep 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathapplication.js
55 lines (50 loc) · 1.69 KB
/
application.js
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
51
52
53
54
55
import { combineReducers } from 'redux'
import relationshipsReducer from './relationships'
import historyReducer from './history'
import errorReducer from './error'
// Defines the authentication sub-state for the application.
export const reducer = (sectionName, defaultState) => (
(state = defaultState, action) => {
// Check that section matches intended section reducer. This is to prevent
// merging of everything every time an action is dispatched. We only
// perform for the relevant section
if (action.section === sectionName) {
// copy current state
const updated = { ...state }
// Override all values for the particular reducer key
updated[action.property] = action.values
return updated
}
return state
}
)
// High level pre-defined sub-state tree
export default combineReducers({
Settings: reducer('Settings', {
formType: 'SF86',
}),
Identification: reducer('Identification', {}),
Financial: reducer('Financial', {}),
Relationships: relationshipsReducer,
Citizenship: reducer('Citizenship', {}),
Military: reducer('Military', {}),
History: historyReducer,
Foreign: reducer('Foreign', {}),
TBD: reducer('Tbd', {}),
Legal: reducer('Legal', {}),
Psychological: reducer('Psychological', {}),
Substance: reducer('Substance', {}),
Package: reducer('Package', {}),
Submission: reducer('Submission', {}),
Completed: errorReducer('Completed', {}),
Errors: errorReducer('Errors', {}),
AddressBooks: reducer('AddressBooks', {}),
})
// Or alternative...
// export const appReducer = function (state = defaultState, action) {
// return merge(state, {
// [action.section]: {
// [action.property]: action.values
// }
// })
// }