@zeniai/client-epic-state 5.2.52-betaRD1 → 5.2.53-beta0ND
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/entity/jeSchedules/jeSchedulesReducer.d.ts +1 -4
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +5 -47
- package/lib/entity/notificationRegistry/notificationRegistryReducer.d.ts +2 -1
- package/lib/entity/notificationRegistry/notificationRegistryReducer.js +20 -9
- package/lib/entity/notificationRegistry/notificationRegistrySelector.d.ts +2 -1
- package/lib/entity/notificationRegistry/notificationRegistrySelector.js +7 -1
- package/lib/entity/notificationRegistry/notificationRegistryState.d.ts +5 -0
- package/lib/entity/notificationRegistry/notificationRegistryState.js +7 -1
- package/lib/entity/sectionProjectView/sectionProjectViewReducer.js +3 -1
- package/lib/epic.d.ts +1 -2
- package/lib/epic.js +0 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +4 -46
- package/lib/esm/entity/notificationRegistry/notificationRegistryReducer.js +20 -9
- package/lib/esm/entity/notificationRegistry/notificationRegistrySelector.js +5 -0
- package/lib/esm/entity/notificationRegistry/notificationRegistryState.js +5 -0
- package/lib/esm/entity/sectionProjectView/sectionProjectViewReducer.js +3 -1
- package/lib/esm/epic.js +0 -2
- package/lib/esm/index.js +7 -7
- package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +4 -2
- package/lib/esm/view/aiCfoView/epics/fetchRoutineRunsEpic.js +3 -1
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +1 -9
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +13 -10
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +15 -34
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +1 -12
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +15 -4
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +1 -60
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +10 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +12 -20
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +28 -11
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +45 -21
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +4 -1
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +19 -3
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +16 -3
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +6 -2
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +4 -1
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +21 -21
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +6 -2
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +10 -2
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +33 -0
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.js +43 -17
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +6 -2
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +10 -2
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +34 -0
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.js +44 -18
- package/lib/esm/view/invoicing/invoicingFormDraft.js +13 -0
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +57 -9
- package/lib/esm/view/notificationPreferencesView/epics/saveNotificationPreferencesEpic.js +20 -7
- package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewReducer.js +43 -17
- package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewSelector.js +24 -4
- package/lib/esm/view/settingsView/epic/fetchNotificationSettingsEpic.js +12 -2
- package/lib/index.d.ts +7 -7
- package/lib/index.js +56 -50
- package/lib/view/aiCfoView/aiCfoViewReducer.js +4 -2
- package/lib/view/aiCfoView/aiCfoViewSelector.d.ts +1 -1
- package/lib/view/aiCfoView/epics/fetchRoutineRunsEpic.js +3 -1
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +0 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +11 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +15 -34
- package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +1 -12
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +15 -4
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +0 -18
- package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +18 -7
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +2 -8
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +3 -62
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +10 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +0 -2
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +8 -4
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +12 -20
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +27 -10
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +0 -15
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +8 -5
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +22 -6
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +47 -22
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +3 -0
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +7 -0
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +18 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +14 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +6 -2
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +3 -0
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.d.ts +3 -2
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +19 -19
- package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +6 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +10 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +7 -7
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +33 -0
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState.d.ts +6 -0
- package/lib/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.d.ts +15 -10
- package/lib/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.js +42 -16
- package/lib/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +6 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +10 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +7 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +34 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewState.d.ts +6 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.d.ts +15 -11
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.js +42 -16
- package/lib/view/invoicing/invoicingFormDraft.d.ts +10 -1
- package/lib/view/invoicing/invoicingFormDraft.js +14 -0
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +49 -0
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +59 -10
- package/lib/view/notificationPreferencesView/epics/saveNotificationPreferencesEpic.js +19 -6
- package/lib/view/notificationPreferencesView/notificationPreferencesViewReducer.d.ts +8 -5
- package/lib/view/notificationPreferencesView/notificationPreferencesViewReducer.js +43 -17
- package/lib/view/notificationPreferencesView/notificationPreferencesViewSelector.d.ts +4 -0
- package/lib/view/notificationPreferencesView/notificationPreferencesViewSelector.js +30 -5
- package/lib/view/notificationPreferencesView/notificationPreferencesViewState.d.ts +4 -3
- package/lib/view/settingsView/epic/fetchNotificationSettingsEpic.js +12 -2
- package/lib/view/settingsView/settingsViewPayload.d.ts +2 -0
- package/package.json +1 -1
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +0 -40
- package/lib/tsconfig.mocks.tsbuildinfo +0 -1
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.d.ts +0 -20
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +0 -44
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInvoicingQboView = exports.invoicingAccountsForQboAccountTypes = exports.getInvoicingCatalogAccountingLookup = exports.invoicingQboClassByQboId = exports.invoicingQboAccountByQboId = exports.getInvoicingQboConnectionFetchState = exports.isInvoicingAccountingPickerDataLoading = exports.isInvoicingQboConnected = exports.INVOICING_ACCOUNT_LIST_KEY = void 0;
|
|
3
|
+
exports.getInvoicingQboView = exports.NO_INVOICING_ACCOUNT_IDS = exports.NO_INVOICING_CLASS_HIERARCHY = exports.NO_INVOICING_ACCOUNT_HIERARCHY = exports.invoicingQboAccountIdsForMappingSlot = exports.INVOICING_DEFAULT_INCOME_ACCOUNT_TYPES = exports.INVOICING_DISCOUNTS_ACCOUNT_MAPPING_SLOT = exports.INVOICING_INCOME_ACCOUNT_MAPPING_SLOT = exports.invoicingAccountsForQboAccountTypes = exports.getInvoicingQboAccountOptions = exports.getInvoicingCatalogAccountingLookup = exports.invoicingQboClassByQboId = exports.invoicingQboAccountByQboId = exports.getInvoicingQboConnectionFetchState = exports.isInvoicingAccountingPickerDataLoading = exports.isInvoicingQboConnected = exports.INVOICING_ACCOUNT_LIST_KEY = void 0;
|
|
4
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
5
|
+
const invoicingCommonPayload_1 = require("../../../entity/invoicing/invoicingCommonPayload");
|
|
4
6
|
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
5
7
|
const classListSelector_1 = require("../../classList/classListSelector");
|
|
6
8
|
// The shared bucket, fetched with the same arguments as the other consumers so
|
|
@@ -91,14 +93,20 @@ const getInvoicingCatalogAccountingLookup = (state) => ({
|
|
|
91
93
|
});
|
|
92
94
|
exports.getInvoicingCatalogAccountingLookup = getInvoicingCatalogAccountingLookup;
|
|
93
95
|
/**
|
|
94
|
-
* Accounts
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
96
|
+
* Accounts as the invoicing pickers need them, from the shared
|
|
97
|
+
* accounting-service list, so whatever another screen already loaded is reused.
|
|
98
|
+
* `qboId` is the submitted value because that is what the invoicing API stores;
|
|
99
|
+
* an account without one cannot be posted, so it is dropped rather than offered.
|
|
100
|
+
*
|
|
101
|
+
* Memoized on the two slices it reads: the pickers and the lists derived from
|
|
102
|
+
* them are handed straight to forms, and a fresh array on every store change
|
|
103
|
+
* re-seeds a form the user is editing.
|
|
99
104
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
exports.getInvoicingQboAccountOptions = (0, toolkit_1.createSelector)([
|
|
106
|
+
(state) => state.accountState,
|
|
107
|
+
(state) => state.accountListState,
|
|
108
|
+
], (accountState, accountListState) => {
|
|
109
|
+
const { accounts } = (0, accountListSelector_1.getAccountList)(accountState, accountListState, exports.INVOICING_ACCOUNT_LIST_KEY);
|
|
102
110
|
return accounts.flatMap((account) => {
|
|
103
111
|
if (account.qboId == null || account.isDeleted === true) {
|
|
104
112
|
return [];
|
|
@@ -111,7 +119,7 @@ const invoicingAccountingOptions = (state) => {
|
|
|
111
119
|
},
|
|
112
120
|
];
|
|
113
121
|
});
|
|
114
|
-
};
|
|
122
|
+
});
|
|
115
123
|
/**
|
|
116
124
|
* Normalises an account-type name for comparison. The config's mapping kinds
|
|
117
125
|
* name QuickBooks types the way QuickBooks displays them ("Other Current
|
|
@@ -148,6 +156,47 @@ const invoicingAccountsForQboAccountTypes = (accounts, accountTypes) => {
|
|
|
148
156
|
wanted.has(normalizeAccountTypeName(account.accountType)));
|
|
149
157
|
};
|
|
150
158
|
exports.invoicingAccountsForQboAccountTypes = invoicingAccountsForQboAccountTypes;
|
|
159
|
+
/**
|
|
160
|
+
* The account-mapping slot a catalog price point's income account shares with
|
|
161
|
+
* the settings page, and the one a discount's account shares with it.
|
|
162
|
+
*/
|
|
163
|
+
exports.INVOICING_INCOME_ACCOUNT_MAPPING_SLOT = 'default_income_account';
|
|
164
|
+
exports.INVOICING_DISCOUNTS_ACCOUNT_MAPPING_SLOT = 'discounts_account';
|
|
165
|
+
/**
|
|
166
|
+
* The account types a slot falls back to when the config carries no kind for
|
|
167
|
+
* it. QuickBooks posts a product, a price and a discount line to an income
|
|
168
|
+
* account; offering every account instead would let a save be rejected.
|
|
169
|
+
*/
|
|
170
|
+
exports.INVOICING_DEFAULT_INCOME_ACCOUNT_TYPES = 'Income';
|
|
171
|
+
/**
|
|
172
|
+
* The QuickBooks ids a mapping slot's picker may offer, from the account types
|
|
173
|
+
* the config gives that slot — so every picker filling the same slot offers the
|
|
174
|
+
* same accounts, and widening one stays a config change.
|
|
175
|
+
*
|
|
176
|
+
* Ids rather than a filtered tree: the pickers flatten the tree into options by
|
|
177
|
+
* walking each node's children, so dropping a parent that is not itself of the
|
|
178
|
+
* wanted type would drop its matching descendants with it.
|
|
179
|
+
*
|
|
180
|
+
* Matched on the slot rather than the code as written, since a config naming
|
|
181
|
+
* the kind `discounts_account_id` means the same slot. A slot the config does
|
|
182
|
+
* not carry falls back to `defaultAccountTypes` rather than to every account.
|
|
183
|
+
*/
|
|
184
|
+
const invoicingQboAccountIdsForMappingSlot = (accounts, accountMappingKindOptions, mappingSlot, defaultAccountTypes) => {
|
|
185
|
+
const accountTypes = accountMappingKindOptions.find((kindOption) => (0, invoicingCommonPayload_1.toInvoicingQboAccountMappingSlot)(kindOption.code) === mappingSlot)?.accountTypes ?? defaultAccountTypes;
|
|
186
|
+
return (0, exports.invoicingAccountsForQboAccountTypes)(accounts, accountTypes).map((account) => account.id);
|
|
187
|
+
};
|
|
188
|
+
exports.invoicingQboAccountIdsForMappingSlot = invoicingQboAccountIdsForMappingSlot;
|
|
189
|
+
/**
|
|
190
|
+
* Stable empties for a tenant with no QBO connection.
|
|
191
|
+
*
|
|
192
|
+
* `?? []` builds a fresh array per call, and the invoicing forms re-seed their
|
|
193
|
+
* fields whenever their option lists change identity — so a form open against a
|
|
194
|
+
* disconnected tenant would reset itself on every unrelated store change, until
|
|
195
|
+
* the first edit disarms the re-seed.
|
|
196
|
+
*/
|
|
197
|
+
exports.NO_INVOICING_ACCOUNT_HIERARCHY = [];
|
|
198
|
+
exports.NO_INVOICING_CLASS_HIERARCHY = [];
|
|
199
|
+
exports.NO_INVOICING_ACCOUNT_IDS = [];
|
|
151
200
|
/** Classes as the invoicing pickers need them, from the shared class list. */
|
|
152
201
|
const invoicingAccountingClassOptions = (state) => {
|
|
153
202
|
const { classes } = (0, classListSelector_1.getClassList)(state.classState, state.classListState);
|
|
@@ -169,7 +218,7 @@ const getInvoicingQboView = (state) => {
|
|
|
169
218
|
const qboState = state.invoicingQboViewState;
|
|
170
219
|
const accountList = state.accountListState.byReportId[exports.INVOICING_ACCOUNT_LIST_KEY];
|
|
171
220
|
return {
|
|
172
|
-
accounts:
|
|
221
|
+
accounts: (0, exports.getInvoicingQboAccountOptions)(state),
|
|
173
222
|
accountsFetchState: {
|
|
174
223
|
fetchState: accountList.fetchState,
|
|
175
224
|
error: accountList.error,
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.saveNotificationPreferencesEpic = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const notificationRegistryState_1 = require("../../../entity/notificationRegistry/notificationRegistryState");
|
|
6
7
|
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
7
8
|
const responsePayload_1 = require("../../../responsePayload");
|
|
8
9
|
const notificationPreferencesEndpoint_1 = require("../notificationPreferencesEndpoint");
|
|
@@ -16,9 +17,19 @@ const saveNotificationPreferencesEpic = (actions$, state$, zeniAPI) => actions$.
|
|
|
16
17
|
// ignored, so stale success/failure actions cannot clobber the newer
|
|
17
18
|
// batch's state. Server-side ordering is arrival-order LWW.
|
|
18
19
|
(0, operators_1.switchMap)(([, state]) => {
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
// A clean domain is omitted entirely: an empty patch is still a write against it.
|
|
21
|
+
const overridesByDomain = {};
|
|
22
|
+
const body = {};
|
|
23
|
+
notificationRegistryState_1.NOTIFICATION_DOMAINS.forEach((domain) => {
|
|
24
|
+
const overrides = (0, notificationPreferencesViewSelector_1.getNotificationLocalOverridesForDomain)(state, domain);
|
|
25
|
+
const preferencesPatch = (0, notificationPreferencesViewPayload_1.mapPreferencesToPayload)(overrides);
|
|
26
|
+
if (Object.keys(preferencesPatch).length === 0) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
overridesByDomain[domain] = overrides;
|
|
30
|
+
body[`${domain}_preferences`] = preferencesPatch;
|
|
31
|
+
});
|
|
32
|
+
if (Object.keys(body).length === 0) {
|
|
22
33
|
// No diff → do not dispatch a synthetic success (that would wipe
|
|
23
34
|
// stored preferences via the reducer). Simply no-op.
|
|
24
35
|
return rxjs_1.EMPTY;
|
|
@@ -31,7 +42,6 @@ const saveNotificationPreferencesEpic = (actions$, state$, zeniAPI) => actions$.
|
|
|
31
42
|
// in-flight save's response (Success/Failure never dispatched, so
|
|
32
43
|
// the counter never drained and future saves got their merge dropped).
|
|
33
44
|
const cancelEpochAtDispatch = state.notificationPreferencesViewState.cancelEpoch;
|
|
34
|
-
const body = { task_checklist_preferences: preferencesPatch };
|
|
35
45
|
// Suppress the error snackbar when the response lands AFTER the user
|
|
36
46
|
// pressed Cancel — the Failure reducer already swallows the state
|
|
37
47
|
// update, so the toast would be a stale error for a save the user
|
|
@@ -60,8 +70,11 @@ const saveNotificationPreferencesEpic = (actions$, state$, zeniAPI) => actions$.
|
|
|
60
70
|
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
61
71
|
return (0, rxjs_1.of)((0, notificationPreferencesViewReducer_1.saveNotificationPreferencesSuccess)({
|
|
62
72
|
cancelEpochAtDispatch,
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
savedOverridesByDomain: overridesByDomain,
|
|
74
|
+
serverEchoByDomain: {
|
|
75
|
+
task_checklist: response.data?.task_checklist_preferences,
|
|
76
|
+
commenting: response.data?.commenting_preferences,
|
|
77
|
+
},
|
|
65
78
|
}));
|
|
66
79
|
}
|
|
67
80
|
const actions = [
|
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
import { NotificationChannel, NotificationFrequency } from '../../entity/notificationRegistry/notificationRegistryState';
|
|
1
|
+
import { NotificationChannel, NotificationDomain, NotificationFrequency } from '../../entity/notificationRegistry/notificationRegistryState';
|
|
2
2
|
import { ZeniAPIStatus } from '../../responsePayload';
|
|
3
3
|
import { NotificationPreferencesPayload } from './notificationPreferencesViewPayload';
|
|
4
|
-
import {
|
|
4
|
+
import { NotificationPreferencesByDomain, NotificationPreferencesViewState } from './notificationPreferencesViewState';
|
|
5
5
|
export declare const initialState: NotificationPreferencesViewState;
|
|
6
6
|
export interface SetFrequencyPayload {
|
|
7
7
|
frequency: NotificationFrequency;
|
|
8
8
|
groupId: string;
|
|
9
|
+
domain?: NotificationDomain;
|
|
9
10
|
}
|
|
10
11
|
export interface TogglePreferencePayload {
|
|
11
12
|
channel: NotificationChannel;
|
|
12
13
|
enabled: boolean;
|
|
13
14
|
eventId: string;
|
|
15
|
+
domain?: NotificationDomain;
|
|
14
16
|
}
|
|
15
17
|
export interface SetGroupChannelMasterPayload {
|
|
16
18
|
channel: NotificationChannel;
|
|
17
19
|
enabled: boolean;
|
|
18
20
|
groupId: string;
|
|
21
|
+
domain?: NotificationDomain;
|
|
19
22
|
}
|
|
20
23
|
export interface FetchNotificationPreferencesSuccessPayload {
|
|
21
|
-
|
|
24
|
+
preferencesByDomain: Partial<Record<NotificationDomain, NotificationPreferencesPayload | undefined>>;
|
|
22
25
|
saveEpochAtDispatch: number;
|
|
23
26
|
}
|
|
24
27
|
export interface SaveNotificationPreferencesSuccessPayload {
|
|
25
28
|
cancelEpochAtDispatch: number;
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
savedOverridesByDomain: NotificationPreferencesByDomain;
|
|
30
|
+
serverEchoByDomain: Partial<Record<NotificationDomain, NotificationPreferencesPayload | undefined>>;
|
|
28
31
|
}
|
|
29
32
|
export interface SaveNotificationPreferencesFailurePayload {
|
|
30
33
|
cancelEpochAtDispatch: number;
|
|
@@ -3,16 +3,27 @@ var _a;
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.toggleEventChannel = exports.setGroupFrequency = exports.setGroupChannelMaster = exports.saveNotificationPreferencesSuccess = exports.saveNotificationPreferencesFailure = exports.saveNotificationPreferences = exports.fetchNotificationPreferencesSuccess = exports.clearNotificationPreferencesLocalOverrides = exports.clearAllNotificationPreferencesView = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
+
const notificationRegistryState_1 = require("../../entity/notificationRegistry/notificationRegistryState");
|
|
6
7
|
const rootActions_1 = require("../../rootActions");
|
|
7
8
|
const notificationPreferencesViewPayload_1 = require("./notificationPreferencesViewPayload");
|
|
8
9
|
const notificationPreferencesViewState_1 = require("./notificationPreferencesViewState");
|
|
9
10
|
exports.initialState = {
|
|
10
11
|
cancelEpoch: 0,
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
localOverridesByDomain: {},
|
|
13
|
+
preferencesByDomain: {},
|
|
13
14
|
saveEpoch: 0,
|
|
14
15
|
savePreferencesState: { fetchState: 'Not-Started' },
|
|
15
16
|
};
|
|
17
|
+
// Lazy: a gate-off tenant never receives that domain's key at all.
|
|
18
|
+
const overridesFor = (byDomain, domain) => {
|
|
19
|
+
const existing = byDomain[domain];
|
|
20
|
+
if (existing != null) {
|
|
21
|
+
return existing;
|
|
22
|
+
}
|
|
23
|
+
const created = (0, notificationPreferencesViewState_1.emptyNotificationPreferences)();
|
|
24
|
+
byDomain[domain] = created;
|
|
25
|
+
return created;
|
|
26
|
+
};
|
|
16
27
|
const mergePreferences = (base, patch) => {
|
|
17
28
|
const eventEnabledByChannel = {
|
|
18
29
|
...base.eventEnabledByChannel,
|
|
@@ -150,7 +161,8 @@ const notificationPreferencesView = (0, toolkit_1.createSlice)({
|
|
|
150
161
|
// Success/Failure never dispatches, subsequent legitimate saves
|
|
151
162
|
// still work because their captured epoch matches the current one.
|
|
152
163
|
draft.cancelEpoch += 1;
|
|
153
|
-
|
|
164
|
+
// One shared Save/Cancel footer, so Cancel discards every domain.
|
|
165
|
+
draft.localOverridesByDomain = {};
|
|
154
166
|
// Also drop `savePreferencesState` back to Not-Started so any
|
|
155
167
|
// "Saving…" affordance bound to `getNotificationPreferencesSaveState`
|
|
156
168
|
// clears on Cancel. Without this, a Cancel-during-save whose stale
|
|
@@ -167,9 +179,6 @@ const notificationPreferencesView = (0, toolkit_1.createSlice)({
|
|
|
167
179
|
// them; the save-success path is the only clearer.
|
|
168
180
|
// A `null`/`undefined` payload isn't a snapshot at all (e.g. the
|
|
169
181
|
// envelope key was omitted); no-op instead of wiping preferences.
|
|
170
|
-
if (action.payload.preferences == null) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
182
|
// Stale-GET guard (Cursor Bugbot 3632510237): if the fetch epic
|
|
174
183
|
// captured a `saveEpoch` lower than the current one, a save has
|
|
175
184
|
// succeeded since this GET dispatched — the response is carrying
|
|
@@ -179,7 +188,13 @@ const notificationPreferencesView = (0, toolkit_1.createSlice)({
|
|
|
179
188
|
if (action.payload.saveEpochAtDispatch < draft.saveEpoch) {
|
|
180
189
|
return;
|
|
181
190
|
}
|
|
182
|
-
|
|
191
|
+
Object.entries(action.payload.preferencesByDomain).forEach(([domain, payload]) => {
|
|
192
|
+
if (payload == null) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
draft.preferencesByDomain[domain] =
|
|
196
|
+
(0, notificationPreferencesViewPayload_1.mapPayloadToPreferences)(payload);
|
|
197
|
+
});
|
|
183
198
|
},
|
|
184
199
|
saveNotificationPreferences(draft) {
|
|
185
200
|
draft.savePreferencesState = { fetchState: 'In-Progress' };
|
|
@@ -238,33 +253,44 @@ const notificationPreferencesView = (0, toolkit_1.createSlice)({
|
|
|
238
253
|
// skip the `preferences` replace. Cursor Bugbot 3632510237.
|
|
239
254
|
draft.saveEpoch += 1;
|
|
240
255
|
draft.savePreferencesState = { fetchState: 'Completed' };
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
256
|
+
Object.entries(action.payload.savedOverridesByDomain).forEach(([rawDomain, savedOverrides]) => {
|
|
257
|
+
if (savedOverrides == null) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const domain = rawDomain;
|
|
261
|
+
const serverEcho = action.payload.serverEchoByDomain[domain];
|
|
262
|
+
const patch = serverEcho == null
|
|
263
|
+
? savedOverrides
|
|
264
|
+
: (0, notificationPreferencesViewPayload_1.mapPayloadToPreferences)(serverEcho);
|
|
265
|
+
draft.preferencesByDomain[domain] = mergePreferences(draft.preferencesByDomain[domain] ?? (0, notificationPreferencesViewState_1.emptyNotificationPreferences)(), patch);
|
|
266
|
+
draft.localOverridesByDomain[domain] = subtractSavedOverrides(draft.localOverridesByDomain[domain] ??
|
|
267
|
+
(0, notificationPreferencesViewState_1.emptyNotificationPreferences)(), savedOverrides);
|
|
268
|
+
});
|
|
246
269
|
},
|
|
247
270
|
setGroupChannelMaster(draft, action) {
|
|
248
271
|
// Mirror of `toggleEventChannel` but scoped to the group-channel master
|
|
249
272
|
// held under `groupChannelEnabledByGroupId[groupId][channel]`.
|
|
250
273
|
const { channel, enabled, groupId } = action.payload;
|
|
274
|
+
const overrides = overridesFor(draft.localOverridesByDomain, action.payload.domain ?? notificationRegistryState_1.DEFAULT_NOTIFICATION_DOMAIN);
|
|
251
275
|
const groupMap = {
|
|
252
|
-
...(
|
|
276
|
+
...(overrides.groupChannelEnabledByGroupId[groupId] ?? {}),
|
|
253
277
|
};
|
|
254
278
|
groupMap[channel] = enabled;
|
|
255
|
-
|
|
279
|
+
overrides.groupChannelEnabledByGroupId[groupId] = groupMap;
|
|
256
280
|
},
|
|
257
281
|
setGroupFrequency(draft, action) {
|
|
258
|
-
draft.
|
|
282
|
+
const overrides = overridesFor(draft.localOverridesByDomain, action.payload.domain ?? notificationRegistryState_1.DEFAULT_NOTIFICATION_DOMAIN);
|
|
283
|
+
overrides.groupFrequencyByGroupId[action.payload.groupId] =
|
|
259
284
|
action.payload.frequency;
|
|
260
285
|
},
|
|
261
286
|
toggleEventChannel(draft, action) {
|
|
262
287
|
const { channel, enabled, eventId } = action.payload;
|
|
288
|
+
const overrides = overridesFor(draft.localOverridesByDomain, action.payload.domain ?? notificationRegistryState_1.DEFAULT_NOTIFICATION_DOMAIN);
|
|
263
289
|
const eventMap = {
|
|
264
|
-
...(
|
|
290
|
+
...(overrides.eventEnabledByChannel[eventId] ?? {}),
|
|
265
291
|
};
|
|
266
292
|
eventMap[channel] = enabled;
|
|
267
|
-
|
|
293
|
+
overrides.eventEnabledByChannel[eventId] = eventMap;
|
|
268
294
|
},
|
|
269
295
|
},
|
|
270
296
|
extraReducers: (builder) => {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { FetchStateAndError } from '../../commonStateTypes/common';
|
|
2
|
+
import { NotificationDomain } from '../../entity/notificationRegistry/notificationRegistryState';
|
|
2
3
|
import { RootState } from '../../rootStateTypes';
|
|
3
4
|
import { NotificationPreferences } from './notificationPreferencesViewState';
|
|
4
5
|
export declare const getNotificationPreferencesSaveState: (state: RootState) => FetchStateAndError;
|
|
6
|
+
export declare const getEffectiveNotificationPreferencesForDomain: (state: RootState, domain: NotificationDomain) => NotificationPreferences;
|
|
5
7
|
export declare const getEffectiveNotificationPreferences: (state: RootState) => NotificationPreferences;
|
|
8
|
+
export declare const getNotificationLocalOverridesForDomain: (state: RootState, domain: NotificationDomain) => NotificationPreferences;
|
|
6
9
|
export declare const getNotificationLocalOverrides: (state: RootState) => NotificationPreferences;
|
|
10
|
+
export declare const hasUnsavedNotificationPreferencesForDomain: (state: RootState, domain: NotificationDomain) => boolean;
|
|
7
11
|
export declare const hasUnsavedNotificationPreferences: (state: RootState) => boolean;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasUnsavedNotificationPreferences = exports.getNotificationLocalOverrides = exports.getEffectiveNotificationPreferences = exports.getNotificationPreferencesSaveState = void 0;
|
|
3
|
+
exports.hasUnsavedNotificationPreferences = exports.hasUnsavedNotificationPreferencesForDomain = exports.getNotificationLocalOverrides = exports.getNotificationLocalOverridesForDomain = exports.getEffectiveNotificationPreferences = exports.getEffectiveNotificationPreferencesForDomain = exports.getNotificationPreferencesSaveState = void 0;
|
|
4
4
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
5
|
+
const notificationRegistryState_1 = require("../../entity/notificationRegistry/notificationRegistryState");
|
|
6
|
+
const notificationPreferencesViewState_1 = require("./notificationPreferencesViewState");
|
|
5
7
|
const getView = (state) => state.notificationPreferencesViewState;
|
|
6
8
|
const getNotificationPreferencesSaveState = (state) => getView(state).savePreferencesState;
|
|
7
9
|
exports.getNotificationPreferencesSaveState = getNotificationPreferencesSaveState;
|
|
@@ -9,7 +11,12 @@ exports.getNotificationPreferencesSaveState = getNotificationPreferencesSaveStat
|
|
|
9
11
|
// stable reference while neither input changes — a plain function would
|
|
10
12
|
// allocate a fresh object on every call and re-render every `useSelector`
|
|
11
13
|
// consumer on any unrelated dispatch.
|
|
12
|
-
|
|
14
|
+
const EMPTY_PREFERENCES = (0, notificationPreferencesViewState_1.emptyNotificationPreferences)();
|
|
15
|
+
// One per domain: a shared createSelector has a cache of one and would thrash across two.
|
|
16
|
+
const effectivePreferencesSelectorByDomain = new Map();
|
|
17
|
+
const createEffectivePreferencesSelector = (domain) => (0, toolkit_1.createSelector)((state) => getView(state).preferencesByDomain[domain], (state) => getView(state).localOverridesByDomain[domain], (storedPreferences, storedOverrides) => {
|
|
18
|
+
const preferences = storedPreferences ?? EMPTY_PREFERENCES;
|
|
19
|
+
const localOverrides = storedOverrides ?? EMPTY_PREFERENCES;
|
|
13
20
|
const mergedEventEnabledByChannel = { ...preferences.eventEnabledByChannel };
|
|
14
21
|
Object.entries(localOverrides.eventEnabledByChannel).forEach(([eventId, channels]) => {
|
|
15
22
|
mergedEventEnabledByChannel[eventId] = {
|
|
@@ -33,8 +40,26 @@ exports.getEffectiveNotificationPreferences = (0, toolkit_1.createSelector)((sta
|
|
|
33
40
|
},
|
|
34
41
|
};
|
|
35
42
|
});
|
|
36
|
-
const
|
|
43
|
+
const getEffectiveNotificationPreferencesForDomain = (state, domain) => {
|
|
44
|
+
let selector = effectivePreferencesSelectorByDomain.get(domain);
|
|
45
|
+
if (selector == null) {
|
|
46
|
+
selector = createEffectivePreferencesSelector(domain);
|
|
47
|
+
effectivePreferencesSelectorByDomain.set(domain, selector);
|
|
48
|
+
}
|
|
49
|
+
return selector(state);
|
|
50
|
+
};
|
|
51
|
+
exports.getEffectiveNotificationPreferencesForDomain = getEffectiveNotificationPreferencesForDomain;
|
|
52
|
+
const getEffectiveNotificationPreferences = (state) => (0, exports.getEffectiveNotificationPreferencesForDomain)(state, notificationRegistryState_1.DEFAULT_NOTIFICATION_DOMAIN);
|
|
53
|
+
exports.getEffectiveNotificationPreferences = getEffectiveNotificationPreferences;
|
|
54
|
+
const getNotificationLocalOverridesForDomain = (state, domain) => getView(state).localOverridesByDomain[domain] ?? EMPTY_PREFERENCES;
|
|
55
|
+
exports.getNotificationLocalOverridesForDomain = getNotificationLocalOverridesForDomain;
|
|
56
|
+
const getNotificationLocalOverrides = (state) => (0, exports.getNotificationLocalOverridesForDomain)(state, notificationRegistryState_1.DEFAULT_NOTIFICATION_DOMAIN);
|
|
37
57
|
exports.getNotificationLocalOverrides = getNotificationLocalOverrides;
|
|
38
|
-
|
|
58
|
+
const isDirty = (localOverrides) => Object.keys(localOverrides.eventEnabledByChannel).length > 0 ||
|
|
39
59
|
Object.keys(localOverrides.groupChannelEnabledByGroupId).length > 0 ||
|
|
40
|
-
Object.keys(localOverrides.groupFrequencyByGroupId).length > 0
|
|
60
|
+
Object.keys(localOverrides.groupFrequencyByGroupId).length > 0;
|
|
61
|
+
const hasUnsavedNotificationPreferencesForDomain = (state, domain) => isDirty((0, exports.getNotificationLocalOverridesForDomain)(state, domain));
|
|
62
|
+
exports.hasUnsavedNotificationPreferencesForDomain = hasUnsavedNotificationPreferencesForDomain;
|
|
63
|
+
// Drives the shared page-level Save/Cancel footer.
|
|
64
|
+
const hasUnsavedNotificationPreferences = (state) => Object.values(getView(state).localOverridesByDomain).some((localOverrides) => localOverrides != null && isDirty(localOverrides));
|
|
65
|
+
exports.hasUnsavedNotificationPreferences = hasUnsavedNotificationPreferences;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FetchStateAndError } from '../../commonStateTypes/common';
|
|
2
|
-
import { NotificationChannel, NotificationFrequency } from '../../entity/notificationRegistry/notificationRegistryState';
|
|
2
|
+
import { NotificationChannel, NotificationDomain, NotificationFrequency } from '../../entity/notificationRegistry/notificationRegistryState';
|
|
3
3
|
export interface NotificationPreferences {
|
|
4
4
|
eventEnabledByChannel: Record<string, Partial<Record<NotificationChannel, boolean>>>;
|
|
5
5
|
groupChannelEnabledByGroupId: Record<string, Partial<Record<NotificationChannel, boolean>>>;
|
|
@@ -7,9 +7,10 @@ export interface NotificationPreferences {
|
|
|
7
7
|
}
|
|
8
8
|
export interface NotificationPreferencesViewState {
|
|
9
9
|
cancelEpoch: number;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
localOverridesByDomain: NotificationPreferencesByDomain;
|
|
11
|
+
preferencesByDomain: NotificationPreferencesByDomain;
|
|
12
12
|
saveEpoch: number;
|
|
13
13
|
savePreferencesState: FetchStateAndError;
|
|
14
14
|
}
|
|
15
|
+
export type NotificationPreferencesByDomain = Partial<Record<NotificationDomain, NotificationPreferences>>;
|
|
15
16
|
export declare const emptyNotificationPreferences: () => NotificationPreferences;
|
|
@@ -41,11 +41,21 @@ const fetchNotificationSettingsEpic = (actions$, state$, zeniAPI) => actions$.pi
|
|
|
41
41
|
// 67d6918e.
|
|
42
42
|
updateActions.push((0, notificationRegistryReducer_1.updateNotificationRegistry)({
|
|
43
43
|
registry: response.data.task_checklist_registry ?? undefined,
|
|
44
|
+
// An absent `<domain>_registry` means that domain's gate is off.
|
|
45
|
+
registriesByDomain: {
|
|
46
|
+
task_checklist: response.data.task_checklist_registry ?? undefined,
|
|
47
|
+
commenting: response.data.commenting_registry ?? undefined,
|
|
48
|
+
},
|
|
44
49
|
registryEpochAtDispatch,
|
|
45
50
|
}));
|
|
46
|
-
|
|
51
|
+
// One action so the domains cannot land on different store epochs.
|
|
52
|
+
const preferencesByDomain = {
|
|
53
|
+
task_checklist: response.data.task_checklist_preferences ?? undefined,
|
|
54
|
+
commenting: response.data.commenting_preferences ?? undefined,
|
|
55
|
+
};
|
|
56
|
+
if (Object.values(preferencesByDomain).some((preferences) => preferences != null)) {
|
|
47
57
|
updateActions.push((0, notificationPreferencesViewReducer_1.fetchNotificationPreferencesSuccess)({
|
|
48
|
-
|
|
58
|
+
preferencesByDomain,
|
|
49
59
|
saveEpochAtDispatch,
|
|
50
60
|
}));
|
|
51
61
|
}
|
|
@@ -37,6 +37,8 @@ export interface NotificationSettingsPayload {
|
|
|
37
37
|
pending_bill_approval_notification: RemindersPayload | null;
|
|
38
38
|
pending_reimbursement_approval_notification: RemindersPayload | null;
|
|
39
39
|
uncategorized_transaction_notification: RemindersPayload | null;
|
|
40
|
+
commenting_preferences?: NotificationPreferencesPayload;
|
|
41
|
+
commenting_registry?: NotificationRegistryPayload;
|
|
40
42
|
month_end_email_recipient_email_ids?: string[];
|
|
41
43
|
task_checklist_preferences?: NotificationPreferencesPayload;
|
|
42
44
|
task_checklist_registry?: NotificationRegistryPayload;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.53-beta0ND",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, switchMap, takeUntil } from 'rxjs/operators';
|
|
3
|
-
import { updateJESchedules, updateJESchedulesDetails, } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
4
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
-
import { clearAll } from '../../../../rootActions';
|
|
6
|
-
import { fetchFailedJePostings, fetchFailedJePostingsFailure, fetchFailedJePostingsSuccess, initializeJeScheduleLocalData, } from '../../reducers/jeSchedulesViewReducer';
|
|
7
|
-
/**
|
|
8
|
-
* Fetches every currently-failing posting for the tenant, on its own endpoint and with no window.
|
|
9
|
-
*
|
|
10
|
-
* Sends no query at all. The endpoint takes an optional `expected_post_start_date` floor and the
|
|
11
|
-
* client deliberately omits it: a failure is outstanding work until someone resolves it, whatever
|
|
12
|
-
* month it belongs to, and windowing this list is exactly what kept older failures off the only
|
|
13
|
-
* screen that can resolve them.
|
|
14
|
-
*
|
|
15
|
-
* `switchMap`, not `mergeMap`: there is one list per tenant, so a second trigger supersedes the
|
|
16
|
-
* first rather than racing it.
|
|
17
|
-
*/
|
|
18
|
-
export const fetchFailedJePostingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchFailedJePostings.match), switchMap(() => zeniAPI
|
|
19
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expenses_automation/failed_je_postings`)
|
|
20
|
-
.pipe(switchMap((response) => {
|
|
21
|
-
if (!isSuccessResponse(response) || response.data == null) {
|
|
22
|
-
return of(fetchFailedJePostingsFailure(response.status));
|
|
23
|
-
}
|
|
24
|
-
const failedJeSchedules = response.data.failed_je_postings?.je_schedules ?? [];
|
|
25
|
-
const failedScheduledJournalEntries = response.data.failed_je_postings?.scheduled_journal_entries ?? [];
|
|
26
|
-
// Order matters and matches fetchJeSchedulesEpic: updateJESchedules fans out to the
|
|
27
|
-
// vendor / account / class / user entities, updateJESchedulesDetails then attaches the
|
|
28
|
-
// journal entries, and only then can initializeJeScheduleLocalData read them back.
|
|
29
|
-
return from([
|
|
30
|
-
updateJESchedules(failedJeSchedules),
|
|
31
|
-
updateJESchedulesDetails(failedJeSchedules, failedScheduledJournalEntries),
|
|
32
|
-
initializeJeScheduleLocalData(failedJeSchedules),
|
|
33
|
-
fetchFailedJePostingsSuccess(failedJeSchedules),
|
|
34
|
-
]);
|
|
35
|
-
}), catchError((error) => of(fetchFailedJePostingsFailure(createZeniAPIStatus('Unexpected Error', 'fetch failed JE postings REST API call errored out' +
|
|
36
|
-
JSON.stringify(error))))),
|
|
37
|
-
// A tenant switch clears the store while this request is still in flight. Without this
|
|
38
|
-
// the old tenant's rows are written back into the freshly cleared store and stay on
|
|
39
|
-
// screen under the new tenant until a manual refresh.
|
|
40
|
-
takeUntil(actions$.pipe(filter(clearAll.match))))));
|