@zeniai/client-epic-state 4.10.0 → 4.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/lib/commonPayloadTypes/commonPayload.d.ts +0 -8
  2. package/lib/commonPayloadTypes/commonPayload.js +0 -18
  3. package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
  4. package/lib/commonStateTypes/viewAndReport/viewAndReport.js +0 -1
  5. package/lib/entity/account/accountState.d.ts +1 -1
  6. package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
  7. package/lib/entity/class/classReducer.d.ts +4 -4
  8. package/lib/entity/class/classState.d.ts +1 -1
  9. package/lib/entity/forecast/forecastState.d.ts +1 -1
  10. package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
  11. package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
  12. package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
  13. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  14. package/lib/entity/snackbar/snackbarTypes.js +0 -1
  15. package/lib/entity/tenant/clearAllEpic.d.ts +2 -4
  16. package/lib/entity/tenant/clearAllEpic.js +1 -5
  17. package/lib/epic.d.ts +3 -7
  18. package/lib/epic.js +1 -5
  19. package/lib/index.d.ts +2 -10
  20. package/lib/index.js +8 -29
  21. package/lib/reducer.d.ts +0 -6
  22. package/lib/reducer.js +0 -6
  23. package/lib/view/auditReportView/auditReportViewState.d.ts +2 -2
  24. package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
  25. package/lib/view/cardBalance/cardBalanceSelector.d.ts +1 -1
  26. package/lib/view/cashBalance/cashBalanceSelector.d.ts +1 -1
  27. package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
  28. package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
  29. package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
  30. package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
  31. package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
  32. package/lib/view/people/changeZeniPersonRolesEpic.d.ts +1 -1
  33. package/lib/view/people/deletePersonEpic.d.ts +1 -1
  34. package/lib/view/people/invitePeopleEpic.d.ts +1 -1
  35. package/lib/view/people/inviteZeniPeopleEpic.d.ts +1 -1
  36. package/lib/view/people/resendInviteEpic.d.ts +1 -1
  37. package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
  38. package/lib/view/settingsView/epic/fetchNotificationSettingsViewEpic.d.ts +2 -1
  39. package/lib/view/settingsView/epic/fetchNotificationSettingsViewEpic.js +8 -6
  40. package/lib/view/settingsView/epic/saveNotificationSettingsEpic.d.ts +1 -1
  41. package/lib/view/settingsView/settingsViewReducer.d.ts +4 -1
  42. package/lib/view/settingsView/settingsViewReducer.js +11 -2
  43. package/lib/view/settingsView/settingsViewSelector.js +18 -7
  44. package/lib/view/settingsView/types/settingsViewSelectorTypes.d.ts +1 -0
  45. package/lib/view/taskManager/taskDetailView/epics/fetchTaskDetailEpic.d.ts +1 -2
  46. package/lib/view/taskManager/taskDetailView/epics/fetchTaskDetailEpic.js +5 -37
  47. package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
  48. package/lib/view/topEx/topExSelector.d.ts +1 -1
  49. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.d.ts +1 -1
  50. package/lib/zeniAPI.d.ts +0 -2
  51. package/lib/zeniAPI.js +0 -8
  52. package/package.json +1 -2
  53. package/lib/entity/notification/notificationPayload.d.ts +0 -46
  54. package/lib/entity/notification/notificationPayload.js +0 -124
  55. package/lib/entity/notification/notificationReducer.d.ts +0 -20
  56. package/lib/entity/notification/notificationReducer.js +0 -118
  57. package/lib/entity/notification/notificationSelector.d.ts +0 -9
  58. package/lib/entity/notification/notificationSelector.js +0 -36
  59. package/lib/entity/notification/notificationState.d.ts +0 -7
  60. package/lib/entity/notification/notificationState.js +0 -2
  61. package/lib/entity/notification/types/notificationSelectorTypes.d.ts +0 -8
  62. package/lib/entity/notification/types/notificationSelectorTypes.js +0 -2
  63. package/lib/entity/notification/types/notificationStateTypes.d.ts +0 -50
  64. package/lib/entity/notification/types/notificationStateTypes.js +0 -2
  65. package/lib/entity/notification/types/notificationTypes.d.ts +0 -24
  66. package/lib/entity/notification/types/notificationTypes.js +0 -58
  67. package/lib/view/notificationView/epics/fetchNotificationUnreadCountEpic.d.ts +0 -10
  68. package/lib/view/notificationView/epics/fetchNotificationUnreadCountEpic.js +0 -39
  69. package/lib/view/notificationView/epics/fetchNotificationViewEpic.d.ts +0 -9
  70. package/lib/view/notificationView/epics/fetchNotificationViewEpic.js +0 -56
  71. package/lib/view/notificationView/epics/updateNotificationViewAllNotificationsStatusEpic.d.ts +0 -9
  72. package/lib/view/notificationView/epics/updateNotificationViewAllNotificationsStatusEpic.js +0 -50
  73. package/lib/view/notificationView/epics/updateNotificationViewNotificationStatusEpic.d.ts +0 -9
  74. package/lib/view/notificationView/epics/updateNotificationViewNotificationStatusEpic.js +0 -86
  75. package/lib/view/notificationView/notificationView.helpers.d.ts +0 -2
  76. package/lib/view/notificationView/notificationView.helpers.js +0 -11
  77. package/lib/view/notificationView/notificationViewPayload.d.ts +0 -48
  78. package/lib/view/notificationView/notificationViewPayload.js +0 -2
  79. package/lib/view/notificationView/notificationViewReducer.d.ts +0 -64
  80. package/lib/view/notificationView/notificationViewReducer.js +0 -372
  81. package/lib/view/notificationView/notificationViewSelector.d.ts +0 -29
  82. package/lib/view/notificationView/notificationViewSelector.js +0 -89
  83. package/lib/view/notificationView/notificationViewState.d.ts +0 -31
  84. package/lib/view/notificationView/notificationViewState.js +0 -19
@@ -1,372 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.toNotificationTab = exports.clearNotificationView = exports.updateNotificationViewUIState = exports.updateNotificationViewSubTab = exports.updateNotificationViewCurrentTabAndSubTab = exports.updateNotificationViewTabState = exports.updateNotificationViewAllNotificationsStatusFailure = exports.updateNotificationViewAllNotificationsStatusSuccess = exports.updateNotificationViewAllNotificationsStatus = exports.updateNotificationViewNotificationStatusFailure = exports.updateNotificationViewNotificationStatusSuccess = exports.updateNotificationViewNotificationStatus = exports.fetchNotificationUnreadCountFailure = exports.fetchNotificationUnreadCountSuccess = exports.fetchNotificationUnreadCount = exports.fetchNotificationViewFailure = exports.fetchNotificationViewSuccess = exports.fetchNotificationView = exports.initialState = void 0;
5
- const toolkit_1 = require("@reduxjs/toolkit");
6
- const notificationView_helpers_1 = require("./notificationView.helpers");
7
- exports.initialState = {
8
- currentTab: 'tasks',
9
- currentSubTab: 'all',
10
- stateByTab: {
11
- tasks: {
12
- fetchCountState: {
13
- fetchState: 'Not-Started',
14
- error: undefined,
15
- },
16
- allNotificationsIds: [],
17
- selectedNotificationIds: [],
18
- uiState: {
19
- pageToken: null,
20
- scrollYOffset: { all: 0, mentions: 0, read: 0, unread: 0 },
21
- limit: 10,
22
- totalCount: 0,
23
- unreadCount: 0,
24
- hasMore: true,
25
- },
26
- markAsReadState: {
27
- fetchState: 'Not-Started',
28
- error: undefined,
29
- },
30
- markAsAllReadState: {
31
- fetchState: 'Not-Started',
32
- error: undefined,
33
- },
34
- hasValidState() {
35
- return this.fetchState == 'Completed';
36
- },
37
- fetchState: 'Not-Started',
38
- error: undefined,
39
- },
40
- comments: {
41
- fetchCountState: {
42
- fetchState: 'Not-Started',
43
- error: undefined,
44
- },
45
- allNotificationsIds: [],
46
- selectedNotificationIds: [],
47
- uiState: {
48
- pageToken: null,
49
- scrollYOffset: { all: 0, mentions: 0, read: 0, unread: 0 },
50
- limit: 10,
51
- totalCount: 0,
52
- unreadCount: 0,
53
- hasMore: true,
54
- },
55
- markAsReadState: {
56
- fetchState: 'Not-Started',
57
- error: undefined,
58
- },
59
- markAsAllReadState: {
60
- fetchState: 'Not-Started',
61
- error: undefined,
62
- },
63
- hasValidState() {
64
- return this.fetchState == 'Completed';
65
- },
66
- fetchState: 'Not-Started',
67
- error: undefined,
68
- },
69
- },
70
- };
71
- const notificationView = (0, toolkit_1.createSlice)({
72
- name: 'notificationView',
73
- initialState: exports.initialState,
74
- reducers: {
75
- fetchNotificationView: {
76
- reducer(draft, action) {
77
- const { notificationGroup } = action.payload;
78
- const notificationTab = (0, exports.toNotificationTab)(notificationGroup);
79
- draft.stateByTab[notificationTab].fetchState = 'In-Progress';
80
- draft.stateByTab[notificationTab].error = undefined;
81
- },
82
- prepare(notificationGroup, mode = 'dashboard', status = ['read', 'unread']) {
83
- return {
84
- payload: {
85
- notificationGroup,
86
- mode,
87
- status,
88
- },
89
- };
90
- },
91
- },
92
- fetchNotificationViewSuccess: {
93
- reducer(draft, action) {
94
- const { notifications, pageToken, notificationGroup, totalCount } = action.payload;
95
- const notificationTab = (0, exports.toNotificationTab)(notificationGroup);
96
- draft.stateByTab[notificationTab].fetchState = 'In-Progress';
97
- draft.stateByTab[notificationTab].error = undefined;
98
- draft.stateByTab[notificationTab].allNotificationsIds = [
99
- ...new Set(draft.stateByTab[notificationTab].allNotificationsIds.concat(notifications.map((notification) => notification.user_notification_id))),
100
- ];
101
- if (totalCount -
102
- draft.stateByTab[notificationTab].allNotificationsIds.length >
103
- 0) {
104
- draft.stateByTab[notificationTab].uiState.hasMore = true;
105
- }
106
- else {
107
- draft.stateByTab[notificationTab].uiState.hasMore = false;
108
- }
109
- draft.stateByTab[notificationTab].uiState.totalCount = totalCount;
110
- draft.stateByTab[notificationTab].uiState.pageToken = pageToken;
111
- draft.stateByTab[notificationTab].fetchState = 'Completed';
112
- draft.stateByTab[notificationTab].error = undefined;
113
- },
114
- prepare(notifications, totalCount, notificationGroup, pageToken) {
115
- return {
116
- payload: {
117
- notifications,
118
- totalCount,
119
- notificationGroup,
120
- pageToken,
121
- },
122
- };
123
- },
124
- },
125
- fetchNotificationViewFailure(draft, action) {
126
- const { notificationGroup } = action.payload;
127
- const notificationTab = (0, exports.toNotificationTab)(notificationGroup);
128
- draft.stateByTab[notificationTab].fetchState = 'Error';
129
- draft.stateByTab[notificationTab].error = action.payload.status;
130
- },
131
- fetchNotificationUnreadCount: {
132
- reducer(draft, action) {
133
- const { notificationGroup } = action.payload;
134
- const notificationTab = (0, exports.toNotificationTab)(notificationGroup);
135
- draft.stateByTab[notificationTab].fetchCountState.fetchState =
136
- 'In-Progress';
137
- draft.stateByTab[notificationTab].fetchCountState.error = undefined;
138
- },
139
- prepare(notificationGroup, mode = 'dashboard') {
140
- return {
141
- payload: {
142
- notificationGroup,
143
- mode,
144
- },
145
- };
146
- },
147
- },
148
- fetchNotificationUnreadCountSuccess: {
149
- reducer(draft, action) {
150
- const { unreadCount, notificationGroup } = action.payload;
151
- const notificationTab = (0, exports.toNotificationTab)(notificationGroup);
152
- draft.stateByTab[notificationTab].uiState.unreadCount = unreadCount;
153
- draft.stateByTab[notificationTab].fetchCountState.fetchState =
154
- 'Completed';
155
- draft.stateByTab[notificationTab].fetchCountState.error = undefined;
156
- },
157
- prepare(unreadCount, notificationGroup) {
158
- return {
159
- payload: {
160
- unreadCount,
161
- notificationGroup,
162
- },
163
- };
164
- },
165
- },
166
- fetchNotificationUnreadCountFailure(draft, action) {
167
- const { notificationGroup } = action.payload;
168
- const notificationTab = (0, exports.toNotificationTab)(notificationGroup);
169
- draft.stateByTab[notificationTab].fetchCountState.fetchState = 'Error';
170
- draft.stateByTab[notificationTab].fetchCountState.error =
171
- action.payload.status;
172
- },
173
- updateNotificationViewNotificationStatus: {
174
- reducer(draft, action) {
175
- const { notificationGroup } = action.payload;
176
- const notificationTab = (0, exports.toNotificationTab)(notificationGroup);
177
- draft.stateByTab[notificationTab].markAsReadState.fetchState =
178
- 'In-Progress';
179
- draft.stateByTab[notificationTab].markAsReadState.error = undefined;
180
- },
181
- prepare(notificationGroup, status, notificationIds = [], showSnackBarOnSuccess = true) {
182
- return {
183
- payload: {
184
- notificationGroup,
185
- status,
186
- notificationIds,
187
- showSnackBarOnSuccess,
188
- },
189
- };
190
- },
191
- },
192
- updateNotificationViewNotificationStatusSuccess: {
193
- reducer(draft, action) {
194
- const { notificationGroup, reduceUnreadCountBy } = action.payload;
195
- const notificationTab = (0, exports.toNotificationTab)(notificationGroup);
196
- draft.stateByTab[notificationTab].markAsReadState.fetchState =
197
- 'Completed';
198
- draft.stateByTab[notificationTab].markAsReadState.error = undefined;
199
- draft.stateByTab[notificationTab].uiState.unreadCount =
200
- draft.stateByTab[notificationTab].uiState.unreadCount -
201
- reduceUnreadCountBy >
202
- 0
203
- ? draft.stateByTab[notificationTab].uiState.unreadCount -
204
- reduceUnreadCountBy
205
- : 0;
206
- draft.stateByTab[notificationTab].selectedNotificationIds = [];
207
- },
208
- prepare(notificationGroup, reduceUnreadCountBy) {
209
- return {
210
- payload: {
211
- notificationGroup,
212
- reduceUnreadCountBy,
213
- },
214
- };
215
- },
216
- },
217
- updateNotificationViewNotificationStatusFailure(draft, action) {
218
- const { notificationGroup } = action.payload;
219
- const notificationTab = (0, exports.toNotificationTab)(notificationGroup);
220
- draft.stateByTab[notificationTab].markAsReadState.fetchState = 'Error';
221
- draft.stateByTab[notificationTab].markAsReadState.error =
222
- action.payload.status;
223
- },
224
- updateNotificationViewAllNotificationsStatus: {
225
- reducer(draft, action) {
226
- const { notificationGroup } = action.payload;
227
- const notificationTab = (0, exports.toNotificationTab)(notificationGroup);
228
- draft.stateByTab[notificationTab].markAsAllReadState.fetchState =
229
- 'In-Progress';
230
- draft.stateByTab[notificationTab].markAsAllReadState.error = undefined;
231
- },
232
- prepare(notificationGroup, status) {
233
- return {
234
- payload: {
235
- notificationGroup,
236
- status,
237
- },
238
- };
239
- },
240
- },
241
- updateNotificationViewAllNotificationsStatusSuccess: {
242
- reducer(draft, action) {
243
- const { notificationGroup } = action.payload;
244
- const notificationTab = (0, exports.toNotificationTab)(notificationGroup);
245
- draft.stateByTab[notificationTab].markAsAllReadState.fetchState =
246
- 'Completed';
247
- draft.stateByTab[notificationTab].markAsAllReadState.error = undefined;
248
- draft.stateByTab[notificationTab].uiState.unreadCount = 0;
249
- draft.stateByTab[notificationTab].selectedNotificationIds = [];
250
- },
251
- prepare(notificationGroup) {
252
- return {
253
- payload: {
254
- notificationGroup,
255
- },
256
- };
257
- },
258
- },
259
- updateNotificationViewAllNotificationsStatusFailure(draft, action) {
260
- const { notificationGroup } = action.payload;
261
- const notificationTab = (0, exports.toNotificationTab)(notificationGroup);
262
- draft.stateByTab[notificationTab].markAsAllReadState.fetchState = 'Error';
263
- draft.stateByTab[notificationTab].markAsAllReadState.error =
264
- action.payload.status;
265
- },
266
- updateNotificationViewCurrentTabAndSubTab: {
267
- reducer(draft, action) {
268
- const { newTab, newSubTab } = action.payload;
269
- draft.currentTab = newTab;
270
- if (newSubTab != null) {
271
- draft.currentSubTab = newSubTab;
272
- }
273
- else if (newSubTab == null &&
274
- (0, notificationView_helpers_1.getSubTabsForATab)(newTab).includes(draft.currentSubTab) === false) {
275
- draft.currentSubTab = (0, notificationView_helpers_1.getSubTabsForATab)(newTab)[0];
276
- }
277
- },
278
- prepare(newTab, newSubTab) {
279
- return {
280
- payload: {
281
- newTab,
282
- newSubTab,
283
- },
284
- };
285
- },
286
- },
287
- updateNotificationViewSubTab: {
288
- reducer(draft, action) {
289
- const { newSubTab } = action.payload;
290
- draft.currentSubTab = newSubTab;
291
- },
292
- prepare(newSubTab) {
293
- return {
294
- payload: {
295
- newSubTab,
296
- },
297
- };
298
- },
299
- },
300
- updateNotificationViewUIState: {
301
- reducer(draft, action) {
302
- const { uiState, tab } = action.payload;
303
- const { scrollYOffset, totalCount, hasMore, unreadCount } = uiState;
304
- if (scrollYOffset != null) {
305
- draft.stateByTab[tab].uiState.scrollYOffset = scrollYOffset;
306
- }
307
- if (totalCount != null) {
308
- draft.stateByTab[tab].uiState.totalCount = totalCount;
309
- }
310
- if (unreadCount != null) {
311
- draft.stateByTab[tab].uiState.unreadCount = unreadCount;
312
- }
313
- if (hasMore != null) {
314
- draft.stateByTab[tab].uiState.hasMore = hasMore;
315
- }
316
- },
317
- prepare(uiState, tab) {
318
- return {
319
- payload: {
320
- uiState,
321
- tab,
322
- },
323
- };
324
- },
325
- },
326
- updateNotificationViewTabState: {
327
- reducer(draft, action) {
328
- const { notificationTabState, tab } = action.payload;
329
- const { allNotificationsIds, selectedNotificationIds, fetchCountState, markAsReadState, markAsAllReadState, } = notificationTabState;
330
- if (allNotificationsIds != null) {
331
- draft.stateByTab[tab].allNotificationsIds = allNotificationsIds;
332
- }
333
- if (selectedNotificationIds != null) {
334
- draft.stateByTab[tab].selectedNotificationIds =
335
- selectedNotificationIds;
336
- }
337
- if (fetchCountState != null) {
338
- draft.stateByTab[tab].fetchCountState = fetchCountState;
339
- }
340
- if (markAsReadState != null) {
341
- draft.stateByTab[tab].markAsReadState = markAsReadState;
342
- }
343
- if (markAsAllReadState != null) {
344
- draft.stateByTab[tab].markAsAllReadState = markAsAllReadState;
345
- }
346
- },
347
- prepare(notificationTabState, tab) {
348
- return {
349
- payload: {
350
- notificationTabState,
351
- tab,
352
- },
353
- };
354
- },
355
- },
356
- clearNotificationView(draft) {
357
- Object.assign(draft, exports.initialState);
358
- },
359
- },
360
- });
361
- _a = notificationView.actions, exports.fetchNotificationView = _a.fetchNotificationView, exports.fetchNotificationViewSuccess = _a.fetchNotificationViewSuccess, exports.fetchNotificationViewFailure = _a.fetchNotificationViewFailure, exports.fetchNotificationUnreadCount = _a.fetchNotificationUnreadCount, exports.fetchNotificationUnreadCountSuccess = _a.fetchNotificationUnreadCountSuccess, exports.fetchNotificationUnreadCountFailure = _a.fetchNotificationUnreadCountFailure, exports.updateNotificationViewNotificationStatus = _a.updateNotificationViewNotificationStatus, exports.updateNotificationViewNotificationStatusSuccess = _a.updateNotificationViewNotificationStatusSuccess, exports.updateNotificationViewNotificationStatusFailure = _a.updateNotificationViewNotificationStatusFailure, exports.updateNotificationViewAllNotificationsStatus = _a.updateNotificationViewAllNotificationsStatus, exports.updateNotificationViewAllNotificationsStatusSuccess = _a.updateNotificationViewAllNotificationsStatusSuccess, exports.updateNotificationViewAllNotificationsStatusFailure = _a.updateNotificationViewAllNotificationsStatusFailure, exports.updateNotificationViewTabState = _a.updateNotificationViewTabState, exports.updateNotificationViewCurrentTabAndSubTab = _a.updateNotificationViewCurrentTabAndSubTab, exports.updateNotificationViewSubTab = _a.updateNotificationViewSubTab, exports.updateNotificationViewUIState = _a.updateNotificationViewUIState, exports.clearNotificationView = _a.clearNotificationView;
362
- exports.default = notificationView.reducer;
363
- /**
364
- * Helpers
365
- */
366
- const toNotificationTab = (notificationGroup) => {
367
- if (notificationGroup === 'task_manager') {
368
- return 'tasks';
369
- }
370
- return 'tasks'; // For now notificationGroup will be task_manager, in future we will be adding switch case here
371
- };
372
- exports.toNotificationTab = toNotificationTab;
@@ -1,29 +0,0 @@
1
- import { CoreNotificationData } from '@cord-sdk/types';
2
- import { RootState } from '../../reducer';
3
- import { NotificationSubTabType, NotificationTabType, NotificationTabState } from './notificationViewState';
4
- import { NotificationWithAuthors } from '../../entity/notification/types/notificationSelectorTypes';
5
- import { View } from '../../commonStateTypes/viewAndReport/viewAndReport';
6
- import { FetchStateAndError, ID } from '../../commonStateTypes/common';
7
- interface NotificationDetails extends NotificationTabState {
8
- allNotificationsIdsForSubTab: ID[];
9
- selectedNotificationIdsForSubTab: ID[];
10
- }
11
- export interface NotificationView extends View {
12
- currentTab: NotificationTabType;
13
- currentSubTab: NotificationSubTabType;
14
- allSubTabs: NotificationSubTabType[];
15
- notificationDetailsByTab: Record<NotificationTabType, NotificationDetails>;
16
- allNotifications: NotificationWithAuthors[];
17
- allExternalNotifications: CoreNotificationData[];
18
- notificationsForCurrentTabAndSubTab: NotificationWithAuthors[];
19
- externalNotificationsForCurrentTabAndSubTab: CoreNotificationData[];
20
- reducedFetchCountState: FetchStateAndError;
21
- totalUnreadCount: number;
22
- }
23
- export declare const getNotificationView: (state: RootState) => NotificationView;
24
- /**
25
- * Helpers
26
- */
27
- export declare const getNotificationsForSelectedSubTab: (notifications: NotificationWithAuthors[], currentSubTab: NotificationSubTabType) => NotificationWithAuthors[];
28
- export declare const getExternalNotificationsForSelectedSubTab: (externalNotifications: CoreNotificationData[], currentSubTab: NotificationSubTabType) => CoreNotificationData[];
29
- export {};
@@ -1,89 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getExternalNotificationsForSelectedSubTab = exports.getNotificationsForSelectedSubTab = exports.getNotificationView = void 0;
4
- const toolkit_1 = require("@reduxjs/toolkit");
5
- const notificationSelector_1 = require("../../entity/notification/notificationSelector");
6
- const notificationView_helpers_1 = require("./notificationView.helpers");
7
- const reduceFetchState_1 = require("../../commonStateTypes/reduceFetchState");
8
- exports.getNotificationView = (0, toolkit_1.createSelector)((state) => state.notificationViewState, (state) => state.notificationState, (state) => state.userState, (notificationViewState, notificationState, userState) => {
9
- const { currentTab, currentSubTab, stateByTab } = notificationViewState;
10
- const notificationDetails = {
11
- tasks: Object.assign(Object.assign({}, stateByTab.tasks), { allNotificationsIdsForSubTab: [], selectedNotificationIdsForSubTab: [] }),
12
- comments: Object.assign(Object.assign({}, stateByTab.comments), { allNotificationsIdsForSubTab: [], selectedNotificationIdsForSubTab: [] }),
13
- };
14
- const reducedFetchCountState = (0, reduceFetchState_1.reduceAllFetchState)(Object.values(stateByTab).map((tabDetails) => tabDetails.fetchCountState));
15
- const { selectedNotificationIds } = notificationDetails[currentTab];
16
- const notificationsForCurrentTabAndSubTab = [];
17
- const externalNotificationsForCurrentTabAndSubTab = [];
18
- const allNotifications = (0, notificationSelector_1.getNotificationsByNotificationIds)(notificationState, userState, notificationDetails['tasks'].allNotificationsIds);
19
- const allExternalNotifications = (0, notificationSelector_1.getCommentsNotificationsByNotificationIds)(notificationState, notificationDetails['comments'].allNotificationsIds);
20
- if (currentTab === 'tasks') {
21
- const filteredNotifications = (0, exports.getNotificationsForSelectedSubTab)(allNotifications, currentSubTab);
22
- const notificationIdsForCurrentTabAndSubTab = filteredNotifications.map((notification) => notification.notificationId);
23
- notificationsForCurrentTabAndSubTab.push(...filteredNotifications);
24
- notificationDetails[currentTab].allNotificationsIdsForSubTab.push(...notificationIdsForCurrentTabAndSubTab);
25
- notificationDetails[currentTab].selectedNotificationIdsForSubTab.push(...selectedNotificationIds.filter((notificationId) => notificationIdsForCurrentTabAndSubTab.includes(notificationId)));
26
- }
27
- else {
28
- const filteredExternalNotifications = (0, exports.getExternalNotificationsForSelectedSubTab)(allExternalNotifications, currentSubTab);
29
- const notificationIdsForCurrentTabAndSubTab = filteredExternalNotifications.map((notification) => notification.id);
30
- notificationDetails[currentTab].allNotificationsIdsForSubTab.push(...notificationIdsForCurrentTabAndSubTab);
31
- notificationDetails[currentTab].selectedNotificationIdsForSubTab.push(...selectedNotificationIds.filter((notificationId) => notificationIdsForCurrentTabAndSubTab.includes(notificationId)));
32
- externalNotificationsForCurrentTabAndSubTab.push(...filteredExternalNotifications);
33
- }
34
- const totalUnreadCount = Object.values(stateByTab)
35
- .map((tabDetails) => tabDetails.uiState.unreadCount)
36
- .reduce((sum, unreadCount) => {
37
- return sum + unreadCount;
38
- }, 0);
39
- return {
40
- currentTab,
41
- currentSubTab,
42
- notificationDetailsByTab: notificationDetails,
43
- notificationsForCurrentTabAndSubTab,
44
- externalNotificationsForCurrentTabAndSubTab,
45
- allNotifications,
46
- allExternalNotifications,
47
- allSubTabs: (0, notificationView_helpers_1.getSubTabsForATab)(currentTab),
48
- reducedFetchCountState,
49
- totalUnreadCount,
50
- version: 1,
51
- reportId: 'notification',
52
- };
53
- });
54
- /**
55
- * Helpers
56
- */
57
- const getNotificationsForSelectedSubTab = (notifications, currentSubTab) => {
58
- return notifications.filter((notification) => {
59
- switch (currentSubTab) {
60
- case 'all':
61
- return true;
62
- case 'read':
63
- return notification.status === 'read';
64
- case 'unread':
65
- return notification.status === 'unread';
66
- default:
67
- return false;
68
- }
69
- });
70
- };
71
- exports.getNotificationsForSelectedSubTab = getNotificationsForSelectedSubTab;
72
- const getExternalNotificationsForSelectedSubTab = (externalNotifications, currentSubTab) => {
73
- return externalNotifications.filter((externalNotification) => {
74
- var _a;
75
- switch (currentSubTab) {
76
- case 'all':
77
- return true;
78
- case 'read':
79
- return externalNotification.readStatus === 'read';
80
- case 'unread':
81
- return externalNotification.readStatus === 'unread';
82
- case 'mentions':
83
- return (_a = externalNotification.headerTranslation) === null || _a === void 0 ? void 0 : _a.key.includes('mention');
84
- default:
85
- return false;
86
- }
87
- });
88
- };
89
- exports.getExternalNotificationsForSelectedSubTab = getExternalNotificationsForSelectedSubTab;
@@ -1,31 +0,0 @@
1
- import { FetchedState, FetchStateAndError, ID } from '../../commonStateTypes/common';
2
- import { PageToken } from '../../commonStateTypes/viewAndReport/viewAndReport';
3
- export declare const ALL_NOTIFICATION_TABS: readonly ["tasks", "comments"];
4
- export declare const toNotificationTabType: (v: string) => "tasks" | "comments";
5
- export declare const toNotificationTabTypeStrict: (v: string) => "tasks" | "comments" | undefined;
6
- export declare type NotificationTabType = ReturnType<typeof toNotificationTabType>;
7
- export declare const ALL_NOTIFICATION_SUB_TABS: readonly ["all", "read", "unread", "mentions"];
8
- export declare const toNotificationSubTabType: (v: string) => "all" | "unread" | "read" | "mentions";
9
- export declare const toNotificationSubTabTypeStrict: (v: string) => "all" | "unread" | "read" | "mentions" | undefined;
10
- export declare type NotificationSubTabType = ReturnType<typeof toNotificationSubTabType>;
11
- export interface NotificationViewUIState {
12
- pageToken: PageToken;
13
- scrollYOffset: Record<NotificationSubTabType, number>;
14
- limit: number;
15
- totalCount: number;
16
- unreadCount: number;
17
- hasMore: boolean;
18
- }
19
- export interface NotificationTabState extends FetchedState {
20
- allNotificationsIds: ID[];
21
- selectedNotificationIds: ID[];
22
- uiState: NotificationViewUIState;
23
- fetchCountState: FetchStateAndError;
24
- markAsReadState: FetchStateAndError;
25
- markAsAllReadState: FetchStateAndError;
26
- }
27
- export interface NotificationViewState {
28
- currentTab: NotificationTabType;
29
- currentSubTab: NotificationSubTabType;
30
- stateByTab: Record<NotificationTabType, NotificationTabState>;
31
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toNotificationSubTabTypeStrict = exports.toNotificationSubTabType = exports.ALL_NOTIFICATION_SUB_TABS = exports.toNotificationTabTypeStrict = exports.toNotificationTabType = exports.ALL_NOTIFICATION_TABS = void 0;
4
- const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
5
- exports.ALL_NOTIFICATION_TABS = ['tasks', 'comments'];
6
- const toNotificationTabType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_NOTIFICATION_TABS);
7
- exports.toNotificationTabType = toNotificationTabType;
8
- const toNotificationTabTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_NOTIFICATION_TABS);
9
- exports.toNotificationTabTypeStrict = toNotificationTabTypeStrict;
10
- exports.ALL_NOTIFICATION_SUB_TABS = [
11
- 'all',
12
- 'read',
13
- 'unread',
14
- 'mentions',
15
- ];
16
- const toNotificationSubTabType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_NOTIFICATION_SUB_TABS);
17
- exports.toNotificationSubTabType = toNotificationSubTabType;
18
- const toNotificationSubTabTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_NOTIFICATION_SUB_TABS);
19
- exports.toNotificationSubTabTypeStrict = toNotificationSubTabTypeStrict;