-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvasagatanReducer.js
52 lines (49 loc) · 1.74 KB
/
vasagatanReducer.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
import moment from 'moment';
const defaultState = {
feats: [],
users: [],
user: null,
locations: [],
comments: [],
chosenYear: moment().year().toString(),
activeYear: moment().year().toString(),
startDate: null,
endDate: null,
realtimeCutoffTime: null,
info: {},
finished: false,
availableYears: [moment().year().toString()]
};
const vasagatanReducer = (state = defaultState, action) => {
switch (action.type) {
case 'UPDATE_CHOSEN_YEAR':
return { ...state, chosenYear: action.chosenYear };
case 'UPDATE_ACTIVE_YEAR':
return { ...state, activeYear: action.activeYear };
case 'UPDATE_START_DATE':
return { ...state, startDate: action.startDate };
case 'UPDATE_END_DATE':
return { ...state, endDate: action.endDate };
case 'UPDATE_CUTOFF_TIME':
return { ...state, realtimeCutoffTime: action.realtimeCutoffTime };
case 'UPDATE_YEAR_PROPERTIES':
return { ...state, realtimeCutoffTime: action.realtimeCutoffTime, startDate: action.startDate, endDate: action.endDate, info: action.info, finished: action.finished };
case 'UPDATE_AVAILABLE_YEARS':
return { ...state, availableYears: action.availableYears };
case 'UPDATE_USER':
return { ...state, user: action.user };
case 'UPDATE_FEATS':
return { ...state, feats: action.feats };
case 'UPDATE_USERS':
return { ...state, users: action.users };
case 'UPDATE_LOCATIONS':
return { ...state, locations: action.locations };
case 'UPDATE_COMMENTS':
return { ...state, comments: action.comments };
case 'LOGOUT':
return { ...defaultState, user: null };
default:
return state;
}
};
export default vasagatanReducer;