@zeniai/client-epic-state 4.10.2 → 4.10.3
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.
- package/lib/commonPayloadTypes/commonPayload.d.ts +8 -0
- package/lib/commonPayloadTypes/commonPayload.js +18 -0
- package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
- package/lib/commonStateTypes/viewAndReport/viewAndReport.js +1 -0
- package/lib/entity/account/accountSelector.d.ts +3 -3
- package/lib/entity/account/accountState.d.ts +2 -2
- package/lib/entity/account/accountState.js +1 -1
- package/lib/entity/account/pickAndMergeForecastAccountReport.d.ts +1 -1
- package/lib/entity/accountGroup/accountGroupSelector.d.ts +22 -22
- package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
- package/lib/entity/class/classReducer.d.ts +4 -4
- package/lib/entity/class/classState.d.ts +1 -1
- package/lib/entity/forecast/forecastState.d.ts +1 -1
- package/lib/entity/notification/notificationPayload.d.ts +46 -0
- package/lib/entity/notification/notificationPayload.js +124 -0
- package/lib/entity/notification/notificationReducer.d.ts +20 -0
- package/lib/entity/notification/notificationReducer.js +118 -0
- package/lib/entity/notification/notificationSelector.d.ts +9 -0
- package/lib/entity/notification/notificationSelector.js +36 -0
- package/lib/entity/notification/notificationState.d.ts +7 -0
- package/lib/entity/notification/notificationState.js +2 -0
- package/lib/entity/notification/types/notificationSelectorTypes.d.ts +8 -0
- package/lib/entity/notification/types/notificationSelectorTypes.js +2 -0
- package/lib/entity/notification/types/notificationStateTypes.d.ts +50 -0
- package/lib/entity/notification/types/notificationStateTypes.js +2 -0
- package/lib/entity/notification/types/notificationTypes.d.ts +24 -0
- package/lib/entity/notification/types/notificationTypes.js +58 -0
- package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
- package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
- package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +2 -0
- package/lib/entity/tenant/clearAllEpic.d.ts +4 -2
- package/lib/entity/tenant/clearAllEpic.js +5 -1
- package/lib/epic.d.ts +7 -3
- package/lib/epic.js +5 -1
- package/lib/index.d.ts +12 -4
- package/lib/index.js +49 -27
- package/lib/reducer.d.ts +6 -0
- package/lib/reducer.js +6 -0
- package/lib/view/accountList/accountListReducer.js +1 -1
- package/lib/view/accountMappingView/accountMappingPayload.js +14 -37
- package/lib/view/accountMappingView/accountMappingReducer.js +3 -3
- package/lib/view/accountMappingView/accountMappingState.d.ts +3 -3
- package/lib/view/accountMappingView/accountTypeRecommendation/accountTypeRecommendationPayload.d.ts +1 -1
- package/lib/view/accountMappingView/accountTypeRecommendation/accountTypeRecommendationPayload.js +1 -1
- package/lib/view/accountMappingView/saveAccountMappingViewEpic.d.ts +2 -1
- package/lib/view/accountMappingView/saveAccountMappingViewEpic.js +14 -5
- package/lib/view/auditReportView/auditReportViewState.d.ts +2 -2
- package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
- package/lib/view/cardBalance/cardBalanceSelector.d.ts +2 -2
- package/lib/view/cashBalance/cashBalanceSelector.d.ts +2 -2
- package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
- package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
- package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
- package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
- package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
- package/lib/view/notificationView/epics/fetchNotificationUnreadCountEpic.d.ts +10 -0
- package/lib/view/notificationView/epics/fetchNotificationUnreadCountEpic.js +39 -0
- package/lib/view/notificationView/epics/fetchNotificationViewEpic.d.ts +9 -0
- package/lib/view/notificationView/epics/fetchNotificationViewEpic.js +56 -0
- package/lib/view/notificationView/epics/updateNotificationViewAllNotificationsStatusEpic.d.ts +9 -0
- package/lib/view/notificationView/epics/updateNotificationViewAllNotificationsStatusEpic.js +50 -0
- package/lib/view/notificationView/epics/updateNotificationViewNotificationStatusEpic.d.ts +9 -0
- package/lib/view/notificationView/epics/updateNotificationViewNotificationStatusEpic.js +86 -0
- package/lib/view/notificationView/notificationView.helpers.d.ts +2 -0
- package/lib/view/notificationView/notificationView.helpers.js +11 -0
- package/lib/view/notificationView/notificationViewPayload.d.ts +48 -0
- package/lib/view/notificationView/notificationViewPayload.js +2 -0
- package/lib/view/notificationView/notificationViewReducer.d.ts +64 -0
- package/lib/view/notificationView/notificationViewReducer.js +372 -0
- package/lib/view/notificationView/notificationViewSelector.d.ts +29 -0
- package/lib/view/notificationView/notificationViewSelector.js +89 -0
- package/lib/view/notificationView/notificationViewState.d.ts +31 -0
- package/lib/view/notificationView/notificationViewState.js +19 -0
- package/lib/view/people/changeZeniPersonRolesEpic.d.ts +1 -1
- package/lib/view/people/deletePersonEpic.d.ts +1 -1
- package/lib/view/people/invitePeopleEpic.d.ts +1 -1
- package/lib/view/people/inviteZeniPeopleEpic.d.ts +1 -1
- package/lib/view/people/resendInviteEpic.d.ts +1 -1
- package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
- package/lib/view/settingsView/epic/saveNotificationSettingsEpic.d.ts +1 -1
- package/lib/view/taskManager/taskDetailView/epics/fetchTaskDetailEpic.d.ts +2 -1
- package/lib/view/taskManager/taskDetailView/epics/fetchTaskDetailEpic.js +37 -5
- package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
- package/lib/view/topEx/topExSelector.d.ts +1 -1
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.d.ts +1 -1
- package/lib/zeniAPI.d.ts +2 -0
- package/lib/zeniAPI.js +8 -0
- package/package.json +2 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateNotificationViewNotificationStatusEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const responsePayload_1 = require("../../../responsePayload");
|
|
7
|
+
const notificationViewReducer_1 = require("../notificationViewReducer");
|
|
8
|
+
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
9
|
+
const notificationReducer_1 = require("../../../entity/notification/notificationReducer");
|
|
10
|
+
const updateNotificationViewNotificationStatusEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(notificationViewReducer_1.updateNotificationViewNotificationStatus.match), (0, operators_1.switchMap)((action) => {
|
|
11
|
+
const { notificationGroup, status, notificationIds, showSnackBarOnSuccess, } = action.payload;
|
|
12
|
+
const { notificationViewState, notificationState } = state$.value;
|
|
13
|
+
const { stateByTab } = notificationViewState;
|
|
14
|
+
const notificationTab = (0, notificationViewReducer_1.toNotificationTab)(notificationGroup);
|
|
15
|
+
const notificationTabState = stateByTab[notificationTab];
|
|
16
|
+
const { selectedNotificationIds } = notificationTabState;
|
|
17
|
+
const payload = {
|
|
18
|
+
notifications: [],
|
|
19
|
+
};
|
|
20
|
+
let reduceUnreadCountBy = 0;
|
|
21
|
+
if (notificationIds.length > 0) {
|
|
22
|
+
notificationIds.forEach((notificationId) => {
|
|
23
|
+
payload.notifications.push({
|
|
24
|
+
user_notification_id: notificationId,
|
|
25
|
+
status,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
reduceUnreadCountBy = notificationIds.length;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
selectedNotificationIds.forEach((notificationId) => {
|
|
32
|
+
payload.notifications.push({
|
|
33
|
+
user_notification_id: notificationId,
|
|
34
|
+
status,
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
if (notificationTab !== 'comments') {
|
|
38
|
+
selectedNotificationIds.forEach((selectedNotificationId) => {
|
|
39
|
+
if (notificationState.notificationById[selectedNotificationId] != null) {
|
|
40
|
+
if (notificationState.notificationById[selectedNotificationId]
|
|
41
|
+
.status !== status) {
|
|
42
|
+
reduceUnreadCountBy = reduceUnreadCountBy + 1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return zeniAPI
|
|
49
|
+
.putAndGetJSON(`${zeniAPI.apiEndPoints.notificationMicroServiceBaseUrl}/1.0/user-notification`, { notifications: payload.notifications })
|
|
50
|
+
.pipe((0, operators_1.switchMap)((response) => {
|
|
51
|
+
if ((0, responsePayload_1.isSuccessStatus)(response)) {
|
|
52
|
+
const updateNotificationIds = payload.notifications.map((notification) => notification.user_notification_id);
|
|
53
|
+
const actions = [];
|
|
54
|
+
if (showSnackBarOnSuccess === true) {
|
|
55
|
+
actions.push((0, snackbarReducer_1.openSnackbar)({
|
|
56
|
+
messageSection: 'notification_mark_as_read',
|
|
57
|
+
messageText: 'success',
|
|
58
|
+
type: 'success',
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
actions.push((0, notificationReducer_1.updateNotificationsStatuses)(updateNotificationIds, status), (0, notificationViewReducer_1.updateNotificationViewNotificationStatusSuccess)(notificationGroup, reduceUnreadCountBy));
|
|
62
|
+
return (0, rxjs_1.from)(actions);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return (0, rxjs_1.of)((0, notificationViewReducer_1.updateNotificationViewNotificationStatusFailure)({
|
|
66
|
+
status: response.status,
|
|
67
|
+
notificationGroup,
|
|
68
|
+
}), (0, snackbarReducer_1.openSnackbar)({
|
|
69
|
+
messageSection: 'notification_mark_as_read',
|
|
70
|
+
messageText: 'failed',
|
|
71
|
+
type: 'error',
|
|
72
|
+
variables: [
|
|
73
|
+
{
|
|
74
|
+
variableName: '_api-error_',
|
|
75
|
+
variableValue: response.status.message,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, notificationViewReducer_1.updateNotificationViewNotificationStatusFailure)({
|
|
81
|
+
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Update Notification Status API call errored out' +
|
|
82
|
+
JSON.stringify(error)),
|
|
83
|
+
notificationGroup,
|
|
84
|
+
}))));
|
|
85
|
+
}));
|
|
86
|
+
exports.updateNotificationViewNotificationStatusEpic = updateNotificationViewNotificationStatusEpic;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSubTabsForATab = void 0;
|
|
4
|
+
const getSubTabsForATab = (notificationTab) => {
|
|
5
|
+
const subTabs = ['all', 'read', 'unread'];
|
|
6
|
+
if (notificationTab === 'comments') {
|
|
7
|
+
return [...subTabs, 'mentions'];
|
|
8
|
+
}
|
|
9
|
+
return subTabs;
|
|
10
|
+
};
|
|
11
|
+
exports.getSubTabsForATab = getSubTabsForATab;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ZeniAPIResponse } from '../../responsePayload';
|
|
2
|
+
import { NotificationPayload } from '../../entity/notification/notificationPayload';
|
|
3
|
+
export interface NotificationViewQueryPayload {
|
|
4
|
+
notification_group: string;
|
|
5
|
+
mode: string;
|
|
6
|
+
is_paginated: boolean;
|
|
7
|
+
status: string[];
|
|
8
|
+
page_token: string | null;
|
|
9
|
+
limit: number;
|
|
10
|
+
}
|
|
11
|
+
export interface NotificationViewPayload {
|
|
12
|
+
notifications: NotificationPayload[];
|
|
13
|
+
query: NotificationViewQueryPayload;
|
|
14
|
+
total_count: number;
|
|
15
|
+
next_page_token: string | null;
|
|
16
|
+
}
|
|
17
|
+
export declare type NotificationViewResponse = ZeniAPIResponse<NotificationViewPayload>;
|
|
18
|
+
export interface UpdateNotificationStatusQueryPayload {
|
|
19
|
+
notification_group: string;
|
|
20
|
+
is_paginated: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface UpdateAllNotificationStatusQueryPayload {
|
|
23
|
+
mark_all_as_read: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface FetchNotificationCountQueryPayload {
|
|
26
|
+
fetch_unread_notification_count: boolean;
|
|
27
|
+
notification_group: string;
|
|
28
|
+
mode: string;
|
|
29
|
+
}
|
|
30
|
+
export interface FetchNotificationCountPayload {
|
|
31
|
+
notification_group: string;
|
|
32
|
+
mode: string;
|
|
33
|
+
query: FetchNotificationCountQueryPayload;
|
|
34
|
+
count: {
|
|
35
|
+
unread: number;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export declare type UpdateNotificationStatusResponse = ZeniAPIResponse;
|
|
39
|
+
export declare type UpdateAllNotificationsStatusResponse = ZeniAPIResponse;
|
|
40
|
+
export declare type FetchNotificationCountResponse = ZeniAPIResponse<FetchNotificationCountPayload>;
|
|
41
|
+
export interface PushNotificationPayload {
|
|
42
|
+
notification_group: string;
|
|
43
|
+
mode: string;
|
|
44
|
+
data: {
|
|
45
|
+
unread: number;
|
|
46
|
+
};
|
|
47
|
+
timestamp: string;
|
|
48
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ZeniAPIStatus } from '../../responsePayload';
|
|
2
|
+
import { NotificationPayload } from '../../entity/notification/notificationPayload';
|
|
3
|
+
import { NotificationTabState, NotificationTabType, NotificationViewState, NotificationViewUIState } from './notificationViewState';
|
|
4
|
+
import { NotificationGroup } from '../../entity/notification/types/notificationTypes';
|
|
5
|
+
import { PageToken } from '../../commonStateTypes/viewAndReport/viewAndReport';
|
|
6
|
+
export declare const initialState: NotificationViewState;
|
|
7
|
+
export declare const fetchNotificationView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[notificationGroup: "task_manager", mode?: "dashboard" | "email" | undefined, status?: ("unread" | "read")[] | undefined], {
|
|
8
|
+
notificationGroup: "task_manager";
|
|
9
|
+
mode: "dashboard" | "email";
|
|
10
|
+
status: ("unread" | "read")[];
|
|
11
|
+
}, string, never, never>, fetchNotificationViewSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[notifications: NotificationPayload[], totalCount: number, notificationGroup: "task_manager", pageToken: PageToken], {
|
|
12
|
+
notifications: NotificationPayload[];
|
|
13
|
+
totalCount: number;
|
|
14
|
+
notificationGroup: "task_manager";
|
|
15
|
+
pageToken: PageToken;
|
|
16
|
+
}, string, never, never>, fetchNotificationViewFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
17
|
+
status: ZeniAPIStatus;
|
|
18
|
+
notificationGroup: NotificationGroup;
|
|
19
|
+
}, string>, fetchNotificationUnreadCount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[notificationGroup: "task_manager", mode?: "dashboard" | "email" | undefined], {
|
|
20
|
+
notificationGroup: "task_manager";
|
|
21
|
+
mode: "dashboard" | "email";
|
|
22
|
+
}, string, never, never>, fetchNotificationUnreadCountSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[unreadCount: number, notificationGroup: "task_manager"], {
|
|
23
|
+
unreadCount: number;
|
|
24
|
+
notificationGroup: "task_manager";
|
|
25
|
+
}, string, never, never>, fetchNotificationUnreadCountFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
26
|
+
status: ZeniAPIStatus;
|
|
27
|
+
notificationGroup: NotificationGroup;
|
|
28
|
+
}, string>, updateNotificationViewNotificationStatus: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[notificationGroup: "task_manager", status: "unread" | "read", notificationIds?: string[] | undefined, showSnackBarOnSuccess?: any], {
|
|
29
|
+
notificationGroup: "task_manager";
|
|
30
|
+
status: "unread" | "read";
|
|
31
|
+
notificationIds: string[];
|
|
32
|
+
showSnackBarOnSuccess: any;
|
|
33
|
+
}, string, never, never>, updateNotificationViewNotificationStatusSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[notificationGroup: "task_manager", reduceUnreadCountBy: number], {
|
|
34
|
+
notificationGroup: "task_manager";
|
|
35
|
+
reduceUnreadCountBy: number;
|
|
36
|
+
}, string, never, never>, updateNotificationViewNotificationStatusFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
37
|
+
status: ZeniAPIStatus;
|
|
38
|
+
notificationGroup: NotificationGroup;
|
|
39
|
+
}, string>, updateNotificationViewAllNotificationsStatus: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[notificationGroup: "task_manager", status: "unread" | "read"], {
|
|
40
|
+
notificationGroup: "task_manager";
|
|
41
|
+
status: "unread" | "read";
|
|
42
|
+
}, string, never, never>, updateNotificationViewAllNotificationsStatusSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[notificationGroup: "task_manager"], {
|
|
43
|
+
notificationGroup: "task_manager";
|
|
44
|
+
}, string, never, never>, updateNotificationViewAllNotificationsStatusFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
45
|
+
status: ZeniAPIStatus;
|
|
46
|
+
notificationGroup: NotificationGroup;
|
|
47
|
+
}, string>, updateNotificationViewTabState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[notificationTabState: Partial<NotificationTabState>, tab: "tasks" | "comments"], {
|
|
48
|
+
notificationTabState: Partial<NotificationTabState>;
|
|
49
|
+
tab: "tasks" | "comments";
|
|
50
|
+
}, string, never, never>, updateNotificationViewCurrentTabAndSubTab: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[newTab: "tasks" | "comments", newSubTab?: "all" | "unread" | "read" | "mentions" | undefined], {
|
|
51
|
+
newTab: "tasks" | "comments";
|
|
52
|
+
newSubTab: "all" | "unread" | "read" | "mentions" | undefined;
|
|
53
|
+
}, string, never, never>, updateNotificationViewSubTab: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[newSubTab: "all" | "unread" | "read" | "mentions"], {
|
|
54
|
+
newSubTab: "all" | "unread" | "read" | "mentions";
|
|
55
|
+
}, string, never, never>, updateNotificationViewUIState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[uiState: Partial<NotificationViewUIState>, tab: "tasks" | "comments"], {
|
|
56
|
+
uiState: Partial<NotificationViewUIState>;
|
|
57
|
+
tab: "tasks" | "comments";
|
|
58
|
+
}, string, never, never>, clearNotificationView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
59
|
+
declare const _default: import("@reduxjs/toolkit").Reducer<NotificationViewState, import("@reduxjs/toolkit").AnyAction>;
|
|
60
|
+
export default _default;
|
|
61
|
+
/**
|
|
62
|
+
* Helpers
|
|
63
|
+
*/
|
|
64
|
+
export declare const toNotificationTab: (notificationGroup: NotificationGroup) => NotificationTabType;
|
|
@@ -0,0 +1,372 @@
|
|
|
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;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 {};
|