-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (37 loc) · 997 Bytes
/
index.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
import { combineReducers } from 'redux';
import * as actions from '../actions';
const initialState = {
decks: {},
notification: {
message: '',
color: 'black'
}
};
const reducer = (state = initialState, action) => {
switch (action.type) {
case actions.RECEIVED_DECKS:
return {
...state,
decks: action.decks
};
case actions.SAVE_NEW_DECK_FAILED:
return {
...state,
notification: {
message: action.error.toString(),
color: 'red'
}
};
case actions.INVALID_TITLE_NOTIFICATION:
case actions.HIDE_ALERTS:
case actions.INVALID_CARD:
case actions.ADDED_CARD_SUCCESS:
return {
...state,
notification: action.notification
};
default:
return state;
}
};
export default reducer;