@zeniai/client-epic-state 4.19.41-betaML3 → 4.19.41-betaML4
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/epic.d.ts +3 -3
- package/lib/epic.js +3 -3
- package/lib/esm/epic.js +3 -3
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/backgroundRefetchReviewTabEpic.js +37 -23
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/expenseAutomationView/epics/transactionCategorization/backgroundRefetchReviewTabEpic.js +36 -22
- package/package.json +1 -1
|
@@ -33,7 +33,6 @@ const backgroundRefetchReviewTabEpic = (actions$, state$, zeniAPI) => actions$.p
|
|
|
33
33
|
};
|
|
34
34
|
return zeniAPI.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`);
|
|
35
35
|
};
|
|
36
|
-
let isFirstPage = true;
|
|
37
36
|
return fetchPage(null).pipe((0, operators_1.expand)((response) => {
|
|
38
37
|
if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
|
|
39
38
|
return rxjs_1.EMPTY;
|
|
@@ -43,44 +42,59 @@ const backgroundRefetchReviewTabEpic = (actions$, state$, zeniAPI) => actions$.p
|
|
|
43
42
|
return rxjs_1.EMPTY;
|
|
44
43
|
}
|
|
45
44
|
return fetchPage(nextToken);
|
|
46
|
-
}), (0, operators_1.
|
|
45
|
+
}), (0, operators_1.reduce)((acc, response) => {
|
|
47
46
|
if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
|
|
47
|
+
return { ...acc, failureStatus: response.status };
|
|
48
|
+
}
|
|
49
|
+
const nextToken = response.data.next_page_token ?? null;
|
|
50
|
+
return {
|
|
51
|
+
...acc,
|
|
52
|
+
allTransactions: [
|
|
53
|
+
...acc.allTransactions,
|
|
54
|
+
...response.data.transactions,
|
|
55
|
+
],
|
|
56
|
+
finalPageToken: nextToken,
|
|
57
|
+
finalStatus: response.status,
|
|
58
|
+
totalCount: response.data.total_count,
|
|
59
|
+
};
|
|
60
|
+
}, {
|
|
61
|
+
allTransactions: [],
|
|
62
|
+
failureStatus: null,
|
|
63
|
+
finalPageToken: null,
|
|
64
|
+
finalStatus: null,
|
|
65
|
+
totalCount: 0,
|
|
66
|
+
}), (0, operators_1.mergeMap)((accumulated) => {
|
|
67
|
+
if (accumulated.failureStatus != null ||
|
|
68
|
+
accumulated.finalStatus == null) {
|
|
48
69
|
return (0, rxjs_1.of)((0, transactionsViewReducer_1.fetchTransactionCategorizationFailure)({
|
|
49
70
|
selectedPeriod,
|
|
50
71
|
selectedTab: SELECTED_TAB,
|
|
51
|
-
status:
|
|
72
|
+
status: accumulated.failureStatus ??
|
|
73
|
+
(0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'background refetch review tab received error response'),
|
|
52
74
|
}));
|
|
53
75
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const nextToken = response.data.next_page_token ?? null;
|
|
59
|
-
const isFinalPage = nextToken == null || nextToken === storedPageToken;
|
|
60
|
-
const updateActions = [
|
|
61
|
-
(0, transactionReducer_1.updateTransactions)(response.data.transactions, (value) => value.transaction_id, 'merge'),
|
|
76
|
+
const transactionIds = accumulated.allTransactions.map((t) => t.transaction_id);
|
|
77
|
+
const lineItemsByTransactionIds = (0, transactionCategorizationLocalDataHelper_1.getLineItemsByTransactionsIdsFromResponse)(accumulated.allTransactions);
|
|
78
|
+
return (0, rxjs_1.from)([
|
|
79
|
+
(0, transactionReducer_1.updateTransactions)(accumulated.allTransactions, (value) => value.transaction_id, 'merge'),
|
|
62
80
|
(0, transactionsViewReducer_1.updateTransactionCategorizationUIState)({
|
|
63
81
|
selectedTab: SELECTED_TAB,
|
|
64
82
|
uiState: {
|
|
65
|
-
|
|
66
|
-
pageToken: nextToken,
|
|
83
|
+
pageToken: accumulated.finalPageToken,
|
|
67
84
|
},
|
|
68
85
|
}),
|
|
69
|
-
(0, transactionsViewReducer_1.initializeTransactionCategorizationViewLocalData)(SELECTED_TAB, transactionIds, selectedPeriod,
|
|
86
|
+
(0, transactionsViewReducer_1.initializeTransactionCategorizationViewLocalData)(SELECTED_TAB, transactionIds, selectedPeriod, false, accumulated.finalPageToken, accumulated.totalCount, lineItemsByTransactionIds, true, isUncategorizedExpenseCategoryEnabled),
|
|
70
87
|
(0, transactionsViewReducer_1.updateTotalCountForTransactionCategorization)({
|
|
71
88
|
selectedPeriod,
|
|
72
89
|
selectedTab: SELECTED_TAB,
|
|
73
|
-
totalCount:
|
|
90
|
+
totalCount: accumulated.totalCount,
|
|
74
91
|
}),
|
|
75
|
-
|
|
76
|
-
if (isFinalPage) {
|
|
77
|
-
updateActions.push((0, transactionsViewReducer_1.fetchTransactionCategorizationSuccess)({
|
|
92
|
+
(0, transactionsViewReducer_1.fetchTransactionCategorizationSuccess)({
|
|
78
93
|
refreshViewInBackground: true,
|
|
79
94
|
selectedTab: SELECTED_TAB,
|
|
80
|
-
status:
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
return (0, rxjs_1.from)(updateActions);
|
|
95
|
+
status: accumulated.finalStatus,
|
|
96
|
+
}),
|
|
97
|
+
]);
|
|
84
98
|
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, transactionsViewReducer_1.fetchTransactionCategorizationFailure)({
|
|
85
99
|
selectedPeriod,
|
|
86
100
|
selectedTab: SELECTED_TAB,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.19.41-
|
|
3
|
+
"version": "4.19.41-betaML4",
|
|
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",
|