-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotification.ts
More file actions
62 lines (56 loc) · 1.59 KB
/
Copy pathNotification.ts
File metadata and controls
62 lines (56 loc) · 1.59 KB
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
56
57
58
59
60
61
62
import { NotificationActions } from 'app/actions';
import * as NotificationInterfaces from 'app/types/Notification';
const notificationInitialState: NotificationInterfaces.NotificationStoreState = {
loading: false,
notifications: [],
};
export const notificationReducer = (
state = notificationInitialState,
action: NotificationInterfaces.NotificationStoreAction,
) => {
switch (action.type) {
case NotificationActions.Type.INFO: {
return state;
}
case NotificationActions.Type.SUCCESS: {
return state;
}
case NotificationActions.Type.ERROR: {
return state;
}
case NotificationActions.Type.DELETE_NOTIFICATION_TYPE: {
const updatedNotifications =
action.payload.type === NotificationInterfaces.NotificationTabType.ALL
? []
: state.notifications.filter(
// @ts-ignore
(notification) => notification.type !== action.payload.type,
);
return {
...state,
notifications: updatedNotifications,
};
}
case NotificationActions.Type.DELETE_NOTIFICATION: {
return {
...state,
notifications: state.notifications.filter(
(notification) => notification.id !== action.payload.id,
),
};
}
case NotificationActions.Type.UPDATE_GLOBAL_NOTIFICATIONS: {
return {
...state,
notifications: action.payload.notifications,
};
}
case NotificationActions.Type.RESET_NOTIFICATION_STATE: {
return {
...notificationInitialState,
};
}
default:
return state;
}
};