@zeniai/client-epic-state 5.2.78 → 5.2.79
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/esm/view/invoicing/couponView/couponViewReducer.js +14 -25
- package/lib/esm/view/invoicing/couponView/couponViewSelector.js +21 -22
- package/lib/esm/view/invoicing/couponView/couponViewState.js +2 -0
- package/lib/esm/view/invoicing/couponView/fetchInvoicingCouponListEpic.js +26 -8
- package/lib/esm/view/invoicing/couponView/fetchInvoicingCouponListPageEpic.js +16 -2
- package/lib/esm/view/invoicing/createInvoice/createInvoiceSelector.js +23 -15
- package/lib/esm/view/invoicing/createInvoice/epics/fetchCreateInvoiceFormPageEpic.js +5 -2
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +2 -2
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/fetchInvoicingSubscriptionDetailPageEpic.js +9 -6
- package/lib/esm/view/invoicing/invoicingCreditNoteListView/epics/fetchInvoicingCreditNoteListEpic.js +25 -8
- package/lib/esm/view/invoicing/invoicingCreditNoteListView/epics/fetchInvoicingCreditNoteListPageEpic.js +15 -2
- package/lib/esm/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewReducer.js +12 -23
- package/lib/esm/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewSelector.js +6 -9
- package/lib/esm/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListEpic.js +26 -8
- package/lib/esm/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListPageEpic.js +16 -2
- package/lib/esm/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.js +14 -25
- package/lib/esm/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.js +16 -13
- package/lib/esm/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewState.js +2 -0
- package/lib/esm/view/invoicing/invoicingDunningCaseListView/epics/fetchInvoicingDunningCaseListEpic.js +25 -8
- package/lib/esm/view/invoicing/invoicingDunningCaseListView/epics/fetchInvoicingDunningCaseListPageEpic.js +15 -2
- package/lib/esm/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.js +12 -23
- package/lib/esm/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewSelector.js +6 -9
- package/lib/esm/view/invoicing/invoicingListTabCache.js +98 -0
- package/lib/esm/view/invoicing/invoicingOverview/epics/fetchInvoicingOverviewEpic.js +4 -7
- package/lib/esm/view/invoicing/invoicingOverview/invoicingOverviewSelector.js +8 -5
- package/lib/esm/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListEpic.js +28 -9
- package/lib/esm/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListPageEpic.js +15 -2
- package/lib/esm/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.js +13 -25
- package/lib/esm/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.js +6 -9
- package/lib/view/invoicing/couponView/couponViewReducer.d.ts +8 -1
- package/lib/view/invoicing/couponView/couponViewReducer.js +14 -25
- package/lib/view/invoicing/couponView/couponViewSelector.js +20 -21
- package/lib/view/invoicing/couponView/couponViewState.d.ts +7 -4
- package/lib/view/invoicing/couponView/couponViewState.js +3 -1
- package/lib/view/invoicing/couponView/fetchInvoicingCouponListEpic.d.ts +1 -1
- package/lib/view/invoicing/couponView/fetchInvoicingCouponListEpic.js +25 -7
- package/lib/view/invoicing/couponView/fetchInvoicingCouponListPageEpic.js +16 -2
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.js +22 -14
- package/lib/view/invoicing/createInvoice/epics/fetchCreateInvoiceFormPageEpic.js +5 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +1 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/fetchInvoicingSubscriptionDetailPageEpic.js +9 -6
- package/lib/view/invoicing/invoicingCreditNoteListView/epics/fetchInvoicingCreditNoteListEpic.d.ts +1 -1
- package/lib/view/invoicing/invoicingCreditNoteListView/epics/fetchInvoicingCreditNoteListEpic.js +24 -7
- package/lib/view/invoicing/invoicingCreditNoteListView/epics/fetchInvoicingCreditNoteListPageEpic.js +15 -2
- package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewReducer.d.ts +8 -1
- package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewReducer.js +12 -23
- package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewSelector.js +6 -9
- package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewState.d.ts +5 -4
- package/lib/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListEpic.d.ts +1 -1
- package/lib/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListEpic.js +25 -7
- package/lib/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListPageEpic.js +16 -2
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.d.ts +8 -1
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.js +14 -25
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.d.ts +5 -0
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.js +17 -13
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewState.d.ts +7 -4
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewState.js +3 -1
- package/lib/view/invoicing/invoicingDunningCaseListView/epics/fetchInvoicingDunningCaseListEpic.d.ts +1 -1
- package/lib/view/invoicing/invoicingDunningCaseListView/epics/fetchInvoicingDunningCaseListEpic.js +24 -7
- package/lib/view/invoicing/invoicingDunningCaseListView/epics/fetchInvoicingDunningCaseListPageEpic.js +15 -2
- package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.d.ts +8 -1
- package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.js +12 -23
- package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewSelector.js +6 -9
- package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewState.d.ts +5 -4
- package/lib/view/invoicing/invoicingListTabCache.d.ts +71 -0
- package/lib/view/invoicing/invoicingListTabCache.js +111 -0
- package/lib/view/invoicing/invoicingOverview/epics/fetchInvoicingOverviewEpic.js +4 -7
- package/lib/view/invoicing/invoicingOverview/invoicingOverviewSelector.js +8 -5
- package/lib/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListEpic.d.ts +1 -1
- package/lib/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListEpic.js +27 -8
- package/lib/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListPageEpic.js +15 -2
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.d.ts +8 -1
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.js +13 -25
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.js +6 -9
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewState.d.ts +5 -5
- package/package.json +1 -1
|
@@ -4,18 +4,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.addInvoicingCustomerToList = exports.setInvoicingCustomerActiveTab = exports.updateInvoicingCustomerFilters = exports.updateInvoicingCustomerCountsFailure = exports.updateInvoicingCustomerCounts = exports.fetchInvoicingCustomerCounts = exports.updateInvoicingCustomerListFailure = exports.updateInvoicingCustomerList = exports.fetchInvoicingCustomerListPage = exports.fetchInvoicingCustomerList = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const rootActions_1 = require("../../../rootActions");
|
|
7
|
+
const invoicingListTabCache_1 = require("../invoicingListTabCache");
|
|
8
|
+
const invoicingCustomerListViewState_1 = require("./invoicingCustomerListViewState");
|
|
7
9
|
exports.initialState = {
|
|
8
|
-
fetchState: 'Not-Started',
|
|
9
|
-
error: undefined,
|
|
10
10
|
activeTab: 'all',
|
|
11
|
-
|
|
12
|
-
nextCursor: null,
|
|
11
|
+
byTab: {},
|
|
13
12
|
filters: {},
|
|
14
13
|
counts: { all: 0 },
|
|
15
14
|
countsFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
16
|
-
hasValidState() {
|
|
17
|
-
return this.fetchState === 'Completed';
|
|
18
|
-
},
|
|
19
15
|
};
|
|
20
16
|
const invoicingCustomerListView = (0, toolkit_1.createSlice)({
|
|
21
17
|
name: 'invoicingCustomerListView',
|
|
@@ -23,14 +19,9 @@ const invoicingCustomerListView = (0, toolkit_1.createSlice)({
|
|
|
23
19
|
reducers: {
|
|
24
20
|
fetchInvoicingCustomerList: {
|
|
25
21
|
reducer(draft, action) {
|
|
26
|
-
|
|
27
|
-
draft.ids = [];
|
|
28
|
-
draft.nextCursor = null;
|
|
29
|
-
}
|
|
22
|
+
(0, invoicingListTabCache_1.startInvoicingListTabFetch)(draft.byTab, (0, invoicingListTabCache_1.invoicingListFetchTab)(draft.activeTab, action.payload.tabId, invoicingCustomerListViewState_1.INVOICING_CUSTOMER_CLIENT_FILTERED_TAB_IDS), action.payload.keepExistingListItems);
|
|
30
23
|
draft.filters = action.payload.filters;
|
|
31
24
|
draft.sort = action.payload.sort;
|
|
32
|
-
draft.fetchState = 'In-Progress';
|
|
33
|
-
draft.error = undefined;
|
|
34
25
|
},
|
|
35
26
|
prepare(payload) {
|
|
36
27
|
return {
|
|
@@ -39,12 +30,17 @@ const invoicingCustomerListView = (0, toolkit_1.createSlice)({
|
|
|
39
30
|
cursor: payload.cursor,
|
|
40
31
|
keepExistingListItems: payload.keepExistingListItems ?? false,
|
|
41
32
|
sort: payload.sort,
|
|
33
|
+
tabId: payload.tabId,
|
|
42
34
|
},
|
|
43
35
|
};
|
|
44
36
|
},
|
|
45
37
|
},
|
|
46
38
|
fetchInvoicingCustomerListPage: {
|
|
47
39
|
reducer(draft, action) {
|
|
40
|
+
// Another search or sort makes every cached tab stale.
|
|
41
|
+
if (!(0, invoicingListTabCache_1.isSameInvoicingListQuery)(draft, action.payload)) {
|
|
42
|
+
draft.byTab = {};
|
|
43
|
+
}
|
|
48
44
|
draft.filters = action.payload.filters;
|
|
49
45
|
draft.sort = action.payload.sort;
|
|
50
46
|
},
|
|
@@ -59,16 +55,10 @@ const invoicingCustomerListView = (0, toolkit_1.createSlice)({
|
|
|
59
55
|
},
|
|
60
56
|
},
|
|
61
57
|
updateInvoicingCustomerList(draft, action) {
|
|
62
|
-
draft.
|
|
63
|
-
? [...new Set([...draft.ids, ...action.payload.ids])]
|
|
64
|
-
: action.payload.ids;
|
|
65
|
-
draft.nextCursor = action.payload.nextCursor;
|
|
66
|
-
draft.fetchState = 'Completed';
|
|
67
|
-
draft.error = undefined;
|
|
58
|
+
(0, invoicingListTabCache_1.completeInvoicingListTabFetch)(draft.byTab, action.payload.tabId, action.payload);
|
|
68
59
|
},
|
|
69
60
|
updateInvoicingCustomerListFailure(draft, action) {
|
|
70
|
-
draft.
|
|
71
|
-
draft.error = action.payload;
|
|
61
|
+
(0, invoicingListTabCache_1.failInvoicingListTabFetch)(draft.byTab, action.payload.tabId, action.payload.status);
|
|
72
62
|
},
|
|
73
63
|
fetchInvoicingCustomerCounts(draft) {
|
|
74
64
|
draft.countsFetchState.fetchState = 'In-Progress';
|
|
@@ -86,8 +76,8 @@ const invoicingCustomerListView = (0, toolkit_1.createSlice)({
|
|
|
86
76
|
updateInvoicingCustomerFilters(draft, action) {
|
|
87
77
|
draft.filters = action.payload;
|
|
88
78
|
},
|
|
89
|
-
// Select a status tab. The
|
|
90
|
-
//
|
|
79
|
+
// Select a status tab. The view dispatches the page fetch after, which loads
|
|
80
|
+
// the tab from the server only when its cache is empty or failed.
|
|
91
81
|
setInvoicingCustomerActiveTab(draft, action) {
|
|
92
82
|
draft.activeTab = action.payload;
|
|
93
83
|
},
|
|
@@ -98,10 +88,9 @@ const invoicingCustomerListView = (0, toolkit_1.createSlice)({
|
|
|
98
88
|
// dispatch time, so bump only `counts.all` when `status` is absent.
|
|
99
89
|
addInvoicingCustomerToList(draft, action) {
|
|
100
90
|
const { id, status } = action.payload;
|
|
101
|
-
if (draft.
|
|
91
|
+
if (!(0, invoicingListTabCache_1.addToInvoicingListTabs)(draft.byTab, id, status)) {
|
|
102
92
|
return;
|
|
103
93
|
}
|
|
104
|
-
draft.ids = [id, ...draft.ids];
|
|
105
94
|
draft.counts.all += 1;
|
|
106
95
|
if (status != null) {
|
|
107
96
|
draft.counts[status] = (draft.counts[status] ?? 0) + 1;
|
|
@@ -25,3 +25,8 @@ export interface InvoicingCustomerListView extends SelectorView {
|
|
|
25
25
|
* every unrelated redux action because a fresh array was built each call.
|
|
26
26
|
*/
|
|
27
27
|
export declare const getInvoicingCustomerListView: (state: RootState) => InvoicingCustomerListView;
|
|
28
|
+
/**
|
|
29
|
+
* Every loaded customer, unfiltered: the pickers read this rather than the list
|
|
30
|
+
* view so they never narrow to whichever tab the customers list was left on.
|
|
31
|
+
*/
|
|
32
|
+
export declare const getInvoicingAllCustomers: (state: RootState) => InvoicingCustomer[];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInvoicingCustomerListView = void 0;
|
|
3
|
+
exports.getInvoicingAllCustomers = exports.getInvoicingCustomerListView = void 0;
|
|
4
4
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
5
5
|
const invoicingCustomerSelector_1 = require("../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector");
|
|
6
|
+
const invoicingListTabCache_1 = require("../invoicingListTabCache");
|
|
6
7
|
const invoicingTabHelper_1 = require("../invoicingTabHelper");
|
|
7
8
|
const invoicingCustomerListViewState_1 = require("./invoicingCustomerListViewState");
|
|
8
9
|
/**
|
|
@@ -13,22 +14,19 @@ const invoicingCustomerListViewState_1 = require("./invoicingCustomerListViewSta
|
|
|
13
14
|
*/
|
|
14
15
|
exports.getInvoicingCustomerListView = (0, toolkit_1.createSelector)((state) => state.invoicingCustomerState, (state) => state.invoicingCustomerListViewState, (state) => state.invoicingConfigViewState.customerStatusOptions, (customerState, listViewState, statusOptions) => {
|
|
15
16
|
const { activeTab } = listViewState;
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
: activeTab === 'at_risk'
|
|
23
|
-
? allCustomers.filter((customer) => customer.isAtRisk === true)
|
|
24
|
-
: allCustomers.filter((customer) => customer.status === activeTab);
|
|
17
|
+
const tab = (0, invoicingListTabCache_1.getInvoicingListTab)(listViewState.byTab, (0, invoicingListTabCache_1.invoicingListSourceTab)(activeTab, invoicingCustomerListViewState_1.INVOICING_CUSTOMER_CLIENT_FILTERED_TAB_IDS));
|
|
18
|
+
const tabRows = (0, invoicingCustomerSelector_1.getInvoicingCustomersByIds)(customerState, tab.ids);
|
|
19
|
+
// `at_risk` is not a stored status, so it is the `all` rows filtered here.
|
|
20
|
+
const customers = activeTab === 'at_risk'
|
|
21
|
+
? tabRows.filter((customer) => customer.isAtRisk === true)
|
|
22
|
+
: tabRows;
|
|
25
23
|
return {
|
|
26
24
|
activeTab,
|
|
27
25
|
columns: invoicingCustomerListViewState_1.INVOICING_CUSTOMER_COLUMNS,
|
|
28
26
|
customers,
|
|
29
|
-
fetchState:
|
|
30
|
-
error:
|
|
31
|
-
nextCursor:
|
|
27
|
+
fetchState: tab.fetchState,
|
|
28
|
+
error: tab.error,
|
|
29
|
+
nextCursor: tab.nextCursor,
|
|
32
30
|
filters: listViewState.filters,
|
|
33
31
|
count: listViewState.counts,
|
|
34
32
|
countsFetchState: listViewState.countsFetchState,
|
|
@@ -41,3 +39,9 @@ exports.getInvoicingCustomerListView = (0, toolkit_1.createSelector)((state) =>
|
|
|
41
39
|
sort: listViewState.sort,
|
|
42
40
|
};
|
|
43
41
|
});
|
|
42
|
+
/**
|
|
43
|
+
* Every loaded customer, unfiltered: the pickers read this rather than the list
|
|
44
|
+
* view so they never narrow to whichever tab the customers list was left on.
|
|
45
|
+
*/
|
|
46
|
+
const getInvoicingAllCustomers = (state) => (0, invoicingCustomerSelector_1.getInvoicingCustomersByIds)(state.invoicingCustomerState, (0, invoicingListTabCache_1.getInvoicingListTab)(state.invoicingCustomerListViewState.byTab, invoicingListTabCache_1.INVOICING_LIST_ALL_TAB).ids);
|
|
47
|
+
exports.getInvoicingAllCustomers = getInvoicingAllCustomers;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { FetchStateAndError
|
|
1
|
+
import { FetchStateAndError } from '../../../commonStateTypes/common';
|
|
2
2
|
import { InvoicingListCounts } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
3
3
|
import { InvoicingListSort } from '../invoicingApiHelper';
|
|
4
|
+
import { InvoicingListByTab } from '../invoicingListTabCache';
|
|
4
5
|
export interface InvoicingCustomerFilters {
|
|
5
6
|
search?: string;
|
|
6
7
|
}
|
|
@@ -22,14 +23,16 @@ export declare const INVOICING_CUSTOMER_COLUMNS: InvoicingCustomerColumnConfig[]
|
|
|
22
23
|
export declare const ALL_INVOICING_CUSTOMER_TAB_IDS: readonly ["all", "active", "trial", "at_risk"];
|
|
23
24
|
export declare const toInvoicingCustomerTabId: (v: string) => "active" | "all" | "trial" | "at_risk";
|
|
24
25
|
export type InvoicingCustomerTabId = ReturnType<typeof toInvoicingCustomerTabId>;
|
|
25
|
-
export interface InvoicingCustomerListViewState
|
|
26
|
+
export interface InvoicingCustomerListViewState {
|
|
26
27
|
/** Selected status tab (CES-owned so it persists across page revisits). */
|
|
27
28
|
activeTab: InvoicingCustomerTabId;
|
|
29
|
+
/** Per-tab rows, cursor and fetch state; each tab is its own `?status=` query. */
|
|
30
|
+
byTab: InvoicingListByTab;
|
|
28
31
|
counts: InvoicingListCounts;
|
|
29
32
|
countsFetchState: FetchStateAndError;
|
|
30
33
|
filters: InvoicingCustomerFilters;
|
|
31
|
-
ids: ID[];
|
|
32
|
-
nextCursor: string | null;
|
|
33
34
|
/** Active server-side sort (undefined = backend default order). */
|
|
34
35
|
sort?: InvoicingListSort;
|
|
35
36
|
}
|
|
37
|
+
/** Tabs the list API cannot filter on: they read the `all` rows, filtered here. */
|
|
38
|
+
export declare const INVOICING_CUSTOMER_CLIENT_FILTERED_TAB_IDS: readonly InvoicingCustomerTabId[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toInvoicingCustomerTabId = exports.ALL_INVOICING_CUSTOMER_TAB_IDS = exports.INVOICING_CUSTOMER_COLUMNS = exports.toInvoicingCustomerSortKey = exports.ALL_INVOICING_CUSTOMER_SORT_KEYS = void 0;
|
|
3
|
+
exports.INVOICING_CUSTOMER_CLIENT_FILTERED_TAB_IDS = exports.toInvoicingCustomerTabId = exports.ALL_INVOICING_CUSTOMER_TAB_IDS = exports.INVOICING_CUSTOMER_COLUMNS = exports.toInvoicingCustomerSortKey = exports.ALL_INVOICING_CUSTOMER_SORT_KEYS = void 0;
|
|
4
4
|
const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
|
|
5
5
|
exports.ALL_INVOICING_CUSTOMER_SORT_KEYS = [
|
|
6
6
|
'name',
|
|
@@ -28,3 +28,5 @@ exports.ALL_INVOICING_CUSTOMER_TAB_IDS = [
|
|
|
28
28
|
];
|
|
29
29
|
const toInvoicingCustomerTabId = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_INVOICING_CUSTOMER_TAB_IDS);
|
|
30
30
|
exports.toInvoicingCustomerTabId = toInvoicingCustomerTabId;
|
|
31
|
+
/** Tabs the list API cannot filter on: they read the `all` rows, filtered here. */
|
|
32
|
+
exports.INVOICING_CUSTOMER_CLIENT_FILTERED_TAB_IDS = ['at_risk'];
|
package/lib/view/invoicing/invoicingDunningCaseListView/epics/fetchInvoicingDunningCaseListEpic.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ import { RootState } from '../../../../rootStateTypes';
|
|
|
5
5
|
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
6
|
import { fetchInvoicingDunningCaseList, updateInvoicingDunningCaseList, updateInvoicingDunningCaseListFailure } from '../invoicingDunningCaseListViewReducer';
|
|
7
7
|
export type ActionType = ReturnType<typeof fetchInvoicingDunningCaseList> | ReturnType<typeof updateInvoicingDunningCaseList> | ReturnType<typeof updateInvoicingDunningCaseListFailure> | ReturnType<typeof updateInvoicingDunningCases>;
|
|
8
|
-
export declare const fetchInvoicingDunningCaseListEpic: (actions$: ActionsObservable<ActionType>,
|
|
8
|
+
export declare const fetchInvoicingDunningCaseListEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/invoicing/invoicingDunningCaseListView/epics/fetchInvoicingDunningCaseListEpic.js
CHANGED
|
@@ -6,9 +6,13 @@ const operators_1 = require("rxjs/operators");
|
|
|
6
6
|
const dunningCaseReducer_1 = require("../../../../entity/invoicing/dunningCase/dunningCaseReducer");
|
|
7
7
|
const responsePayload_1 = require("../../../../responsePayload");
|
|
8
8
|
const invoicingApiHelper_1 = require("../../invoicingApiHelper");
|
|
9
|
+
const invoicingListTabCache_1 = require("../../invoicingListTabCache");
|
|
9
10
|
const invoicingDunningCaseListViewReducer_1 = require("../invoicingDunningCaseListViewReducer");
|
|
10
|
-
const buildQuery = (filters, cursor, sort) => {
|
|
11
|
+
const buildQuery = (filters, cursor, sort, status) => {
|
|
11
12
|
const params = new URLSearchParams();
|
|
13
|
+
if (status != null) {
|
|
14
|
+
params.set('status', status);
|
|
15
|
+
}
|
|
12
16
|
if (filters.search != null && filters.search.length > 0) {
|
|
13
17
|
params.set('search', filters.search);
|
|
14
18
|
}
|
|
@@ -19,9 +23,15 @@ const buildQuery = (filters, cursor, sort) => {
|
|
|
19
23
|
(0, invoicingApiHelper_1.applyListSortParams)(params, sort);
|
|
20
24
|
return params;
|
|
21
25
|
};
|
|
22
|
-
const fetchInvoicingDunningCaseListEpic = (actions$,
|
|
26
|
+
const fetchInvoicingDunningCaseListEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(invoicingDunningCaseListViewReducer_1.fetchInvoicingDunningCaseList.match), (0, operators_1.map)((action) => ({
|
|
27
|
+
action,
|
|
28
|
+
tabId: (0, invoicingListTabCache_1.invoicingListFetchTab)(state$.value.invoicingDunningCaseListViewState.activeTab, action.payload.tabId),
|
|
29
|
+
})),
|
|
30
|
+
// Per tab: a newer fetch of the same tab replaces its in-flight one, while
|
|
31
|
+
// another tab's request keeps running and lands in its own cache.
|
|
32
|
+
(0, operators_1.groupBy)(({ tabId }) => tabId), (0, operators_1.mergeMap)((tabFetches$) => tabFetches$.pipe((0, operators_1.switchMap)(({ action, tabId }) => {
|
|
23
33
|
const { filters, cursor, keepExistingListItems, sort } = action.payload;
|
|
24
|
-
const apiUrl = (0, invoicingApiHelper_1.withQuery)(`${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/dunning`, buildQuery(filters, cursor, sort));
|
|
34
|
+
const apiUrl = (0, invoicingApiHelper_1.withQuery)(`${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/dunning`, buildQuery(filters, cursor, sort, (0, invoicingListTabCache_1.invoicingListStatusParam)(tabId)));
|
|
25
35
|
return zeniAPI.getJSON(apiUrl).pipe((0, operators_1.switchMap)((response) => {
|
|
26
36
|
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
27
37
|
const items = response.data?.items ?? [];
|
|
@@ -31,11 +41,18 @@ const fetchInvoicingDunningCaseListEpic = (actions$, _state$, zeniAPI) => action
|
|
|
31
41
|
ids: items.map((item) => item.id),
|
|
32
42
|
nextCursor: response.data?.next_cursor ?? null,
|
|
33
43
|
keepExistingListItems,
|
|
44
|
+
tabId,
|
|
34
45
|
}),
|
|
35
46
|
];
|
|
36
47
|
}
|
|
37
|
-
return (0, rxjs_1.of)((0, invoicingDunningCaseListViewReducer_1.updateInvoicingDunningCaseListFailure)(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}));
|
|
48
|
+
return (0, rxjs_1.of)((0, invoicingDunningCaseListViewReducer_1.updateInvoicingDunningCaseListFailure)({
|
|
49
|
+
status: response.status,
|
|
50
|
+
tabId,
|
|
51
|
+
}));
|
|
52
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, invoicingDunningCaseListViewReducer_1.updateInvoicingDunningCaseListFailure)({
|
|
53
|
+
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch dunning case list REST API call errored out ' +
|
|
54
|
+
JSON.stringify(error)),
|
|
55
|
+
tabId,
|
|
56
|
+
}))));
|
|
57
|
+
}))));
|
|
41
58
|
exports.fetchInvoicingDunningCaseListEpic = fetchInvoicingDunningCaseListEpic;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fetchInvoicingDunningCaseListPageEpic = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const invoicingListTabCache_1 = require("../../invoicingListTabCache");
|
|
6
7
|
const invoicingDunningCaseListViewReducer_1 = require("../invoicingDunningCaseListViewReducer");
|
|
7
8
|
/**
|
|
8
9
|
* Fetch unless the endpoint is already loaded or in flight — or always when the
|
|
@@ -20,8 +21,20 @@ const fetchInvoicingDunningCaseListPageEpic = (actions$, state$) => actions$.pip
|
|
|
20
21
|
const { cacheOverride, filters, sort } = action.payload;
|
|
21
22
|
const state = state$.value.invoicingDunningCaseListViewState;
|
|
22
23
|
const pageActions = [];
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
const tabId = (0, invoicingListTabCache_1.invoicingListSourceTab)(state.activeTab);
|
|
25
|
+
const tabFetch = (0, invoicingListTabCache_1.planInvoicingListTabFetch)((0, invoicingListTabCache_1.getInvoicingListTab)(state.byTab, tabId), cacheOverride);
|
|
26
|
+
if (tabFetch.kind === 'firstPage') {
|
|
27
|
+
pageActions.push((0, invoicingDunningCaseListViewReducer_1.fetchInvoicingDunningCaseList)({ filters, sort, tabId }));
|
|
28
|
+
}
|
|
29
|
+
else if (tabFetch.kind === 'nextPage') {
|
|
30
|
+
// Less than a page cached and the server has more: top it up.
|
|
31
|
+
pageActions.push((0, invoicingDunningCaseListViewReducer_1.fetchInvoicingDunningCaseList)({
|
|
32
|
+
cursor: tabFetch.cursor,
|
|
33
|
+
filters,
|
|
34
|
+
keepExistingListItems: true,
|
|
35
|
+
sort,
|
|
36
|
+
tabId,
|
|
37
|
+
}));
|
|
25
38
|
}
|
|
26
39
|
if (shouldFetch(state.countsFetchState, cacheOverride)) {
|
|
27
40
|
pageActions.push((0, invoicingDunningCaseListViewReducer_1.fetchInvoicingDunningCaseCounts)());
|
package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.d.ts
CHANGED
|
@@ -9,11 +9,14 @@ export declare const fetchInvoicingDunningCaseList: import("@reduxjs/toolkit").A
|
|
|
9
9
|
filters?: InvoicingDunningCaseFilters;
|
|
10
10
|
keepExistingListItems?: boolean;
|
|
11
11
|
sort?: InvoicingListSort;
|
|
12
|
+
/** The tab cache to fill; defaults to the active tab's. */
|
|
13
|
+
tabId?: string;
|
|
12
14
|
}], {
|
|
13
15
|
filters: InvoicingDunningCaseFilters;
|
|
14
16
|
cursor: string | undefined;
|
|
15
17
|
keepExistingListItems: boolean;
|
|
16
18
|
sort: InvoicingListSort | undefined;
|
|
19
|
+
tabId: string | undefined;
|
|
17
20
|
}, "invoicingDunningCaseListView/fetchInvoicingDunningCaseList", never, never>, fetchInvoicingDunningCaseListPage: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: {
|
|
18
21
|
cacheOverride?: boolean;
|
|
19
22
|
filters?: InvoicingDunningCaseFilters;
|
|
@@ -26,6 +29,10 @@ export declare const fetchInvoicingDunningCaseList: import("@reduxjs/toolkit").A
|
|
|
26
29
|
ids: ID[];
|
|
27
30
|
keepExistingListItems: boolean;
|
|
28
31
|
nextCursor: string | null;
|
|
29
|
-
|
|
32
|
+
tabId: string;
|
|
33
|
+
}, "invoicingDunningCaseListView/updateInvoicingDunningCaseList">, updateInvoicingDunningCaseListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
34
|
+
status: ZeniAPIStatus;
|
|
35
|
+
tabId: string;
|
|
36
|
+
}, "invoicingDunningCaseListView/updateInvoicingDunningCaseListFailure">, fetchInvoicingDunningCaseCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingDunningCaseListView/fetchInvoicingDunningCaseCounts">, updateInvoicingDunningCaseCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingDunningCaseListView/updateInvoicingDunningCaseCounts">, updateInvoicingDunningCaseCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingDunningCaseListView/updateInvoicingDunningCaseCountsFailure">, updateInvoicingDunningCaseFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingDunningCaseFilters, "invoicingDunningCaseListView/updateInvoicingDunningCaseFilters">, setInvoicingDunningCaseActiveTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"paused" | "cancelled" | "scheduled" | "retrying" | "manual_review" | "resolved" | "all", "invoicingDunningCaseListView/setInvoicingDunningCaseActiveTab">;
|
|
30
37
|
declare const _default: import("redux").Reducer<InvoicingDunningCaseListViewState>;
|
|
31
38
|
export default _default;
|
package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.js
CHANGED
|
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.setInvoicingDunningCaseActiveTab = exports.updateInvoicingDunningCaseFilters = exports.updateInvoicingDunningCaseCountsFailure = exports.updateInvoicingDunningCaseCounts = exports.fetchInvoicingDunningCaseCounts = exports.updateInvoicingDunningCaseListFailure = exports.updateInvoicingDunningCaseList = exports.fetchInvoicingDunningCaseListPage = exports.fetchInvoicingDunningCaseList = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const rootActions_1 = require("../../../rootActions");
|
|
7
|
+
const invoicingListTabCache_1 = require("../invoicingListTabCache");
|
|
7
8
|
exports.initialState = {
|
|
8
|
-
fetchState: 'Not-Started',
|
|
9
|
-
error: undefined,
|
|
10
9
|
activeTab: 'all',
|
|
11
|
-
|
|
12
|
-
nextCursor: null,
|
|
10
|
+
byTab: {},
|
|
13
11
|
filters: {},
|
|
14
12
|
counts: { all: 0 },
|
|
15
13
|
countsFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
16
|
-
hasValidState() {
|
|
17
|
-
return this.fetchState === 'Completed';
|
|
18
|
-
},
|
|
19
14
|
};
|
|
20
15
|
const invoicingDunningCaseListView = (0, toolkit_1.createSlice)({
|
|
21
16
|
name: 'invoicingDunningCaseListView',
|
|
@@ -23,14 +18,9 @@ const invoicingDunningCaseListView = (0, toolkit_1.createSlice)({
|
|
|
23
18
|
reducers: {
|
|
24
19
|
fetchInvoicingDunningCaseList: {
|
|
25
20
|
reducer(draft, action) {
|
|
26
|
-
|
|
27
|
-
draft.ids = [];
|
|
28
|
-
draft.nextCursor = null;
|
|
29
|
-
}
|
|
21
|
+
(0, invoicingListTabCache_1.startInvoicingListTabFetch)(draft.byTab, (0, invoicingListTabCache_1.invoicingListFetchTab)(draft.activeTab, action.payload.tabId), action.payload.keepExistingListItems);
|
|
30
22
|
draft.filters = action.payload.filters;
|
|
31
23
|
draft.sort = action.payload.sort;
|
|
32
|
-
draft.fetchState = 'In-Progress';
|
|
33
|
-
draft.error = undefined;
|
|
34
24
|
},
|
|
35
25
|
prepare(payload) {
|
|
36
26
|
return {
|
|
@@ -39,12 +29,17 @@ const invoicingDunningCaseListView = (0, toolkit_1.createSlice)({
|
|
|
39
29
|
cursor: payload.cursor,
|
|
40
30
|
keepExistingListItems: payload.keepExistingListItems ?? false,
|
|
41
31
|
sort: payload.sort,
|
|
32
|
+
tabId: payload.tabId,
|
|
42
33
|
},
|
|
43
34
|
};
|
|
44
35
|
},
|
|
45
36
|
},
|
|
46
37
|
fetchInvoicingDunningCaseListPage: {
|
|
47
38
|
reducer(draft, action) {
|
|
39
|
+
// Another search or sort makes every cached tab stale.
|
|
40
|
+
if (!(0, invoicingListTabCache_1.isSameInvoicingListQuery)(draft, action.payload)) {
|
|
41
|
+
draft.byTab = {};
|
|
42
|
+
}
|
|
48
43
|
draft.filters = action.payload.filters;
|
|
49
44
|
draft.sort = action.payload.sort;
|
|
50
45
|
},
|
|
@@ -59,16 +54,10 @@ const invoicingDunningCaseListView = (0, toolkit_1.createSlice)({
|
|
|
59
54
|
},
|
|
60
55
|
},
|
|
61
56
|
updateInvoicingDunningCaseList(draft, action) {
|
|
62
|
-
draft.
|
|
63
|
-
? [...new Set([...draft.ids, ...action.payload.ids])]
|
|
64
|
-
: action.payload.ids;
|
|
65
|
-
draft.nextCursor = action.payload.nextCursor;
|
|
66
|
-
draft.fetchState = 'Completed';
|
|
67
|
-
draft.error = undefined;
|
|
57
|
+
(0, invoicingListTabCache_1.completeInvoicingListTabFetch)(draft.byTab, action.payload.tabId, action.payload);
|
|
68
58
|
},
|
|
69
59
|
updateInvoicingDunningCaseListFailure(draft, action) {
|
|
70
|
-
draft.
|
|
71
|
-
draft.error = action.payload;
|
|
60
|
+
(0, invoicingListTabCache_1.failInvoicingListTabFetch)(draft.byTab, action.payload.tabId, action.payload.status);
|
|
72
61
|
},
|
|
73
62
|
fetchInvoicingDunningCaseCounts(draft) {
|
|
74
63
|
draft.countsFetchState.fetchState = 'In-Progress';
|
|
@@ -86,8 +75,8 @@ const invoicingDunningCaseListView = (0, toolkit_1.createSlice)({
|
|
|
86
75
|
updateInvoicingDunningCaseFilters(draft, action) {
|
|
87
76
|
draft.filters = action.payload;
|
|
88
77
|
},
|
|
89
|
-
// Select a status tab. The
|
|
90
|
-
//
|
|
78
|
+
// Select a status tab. The view dispatches the page fetch after, which loads
|
|
79
|
+
// the tab from the server only when its cache is empty or failed.
|
|
91
80
|
setInvoicingDunningCaseActiveTab(draft, action) {
|
|
92
81
|
draft.activeTab = action.payload;
|
|
93
82
|
},
|
package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewSelector.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getInvoicingDunningCaseListView = void 0;
|
|
4
4
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
5
5
|
const dunningCaseSelector_1 = require("../../../entity/invoicing/dunningCase/dunningCaseSelector");
|
|
6
|
+
const invoicingListTabCache_1 = require("../invoicingListTabCache");
|
|
6
7
|
const invoicingTabHelper_1 = require("../invoicingTabHelper");
|
|
7
8
|
const invoicingDunningCaseListViewState_1 = require("./invoicingDunningCaseListViewState");
|
|
8
9
|
/**
|
|
@@ -12,12 +13,8 @@ const invoicingDunningCaseListViewState_1 = require("./invoicingDunningCaseListV
|
|
|
12
13
|
*/
|
|
13
14
|
exports.getInvoicingDunningCaseListView = (0, toolkit_1.createSelector)((state) => state.invoicingDunningCaseState, (state) => state.invoicingDunningCaseListViewState, (state) => state.invoicingConfigViewState.dunningCaseStatusOptions, (dunningCaseState, listViewState, statusOptions) => {
|
|
14
15
|
const { activeTab } = listViewState;
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
// active tab client-side ('all' shows everything).
|
|
18
|
-
const dunningCases = activeTab === 'all'
|
|
19
|
-
? allDunningCases
|
|
20
|
-
: allDunningCases.filter((dunningCase) => dunningCase.status === activeTab);
|
|
16
|
+
const tab = (0, invoicingListTabCache_1.getInvoicingListTab)(listViewState.byTab, (0, invoicingListTabCache_1.invoicingListSourceTab)(activeTab));
|
|
17
|
+
const dunningCases = (0, dunningCaseSelector_1.getInvoicingDunningCasesByIds)(dunningCaseState, tab.ids);
|
|
21
18
|
return {
|
|
22
19
|
activeTab,
|
|
23
20
|
columns: invoicingDunningCaseListViewState_1.INVOICING_DUNNING_CASE_COLUMNS,
|
|
@@ -25,9 +22,9 @@ exports.getInvoicingDunningCaseListView = (0, toolkit_1.createSelector)((state)
|
|
|
25
22
|
count: listViewState.counts,
|
|
26
23
|
countsFetchState: listViewState.countsFetchState,
|
|
27
24
|
filters: listViewState.filters,
|
|
28
|
-
nextCursor:
|
|
29
|
-
fetchState:
|
|
30
|
-
error:
|
|
25
|
+
nextCursor: tab.nextCursor,
|
|
26
|
+
fetchState: tab.fetchState,
|
|
27
|
+
error: tab.error,
|
|
31
28
|
statusOptions,
|
|
32
29
|
tabIds: (0, invoicingTabHelper_1.invoicingTabIdsFromConfig)({
|
|
33
30
|
allTabIds: invoicingDunningCaseListViewState_1.ALL_INVOICING_DUNNING_CASE_TAB_IDS,
|
package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewState.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { FetchStateAndError
|
|
1
|
+
import { FetchStateAndError } from '../../../commonStateTypes/common';
|
|
2
2
|
import { InvoicingListCounts } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
3
3
|
import { InvoicingListSort } from '../invoicingApiHelper';
|
|
4
|
+
import { InvoicingListByTab } from '../invoicingListTabCache';
|
|
4
5
|
export interface InvoicingDunningCaseFilters {
|
|
5
6
|
search?: string;
|
|
6
7
|
}
|
|
@@ -22,14 +23,14 @@ export declare const INVOICING_DUNNING_CASE_COLUMNS: InvoicingDunningCaseColumnC
|
|
|
22
23
|
export declare const ALL_INVOICING_DUNNING_CASE_TAB_IDS: readonly ["all", "retrying", "scheduled", "manual_review", "paused", "resolved", "cancelled"];
|
|
23
24
|
export declare const toInvoicingDunningCaseTabId: (v: string) => "paused" | "cancelled" | "scheduled" | "retrying" | "manual_review" | "resolved" | "all";
|
|
24
25
|
export type InvoicingDunningCaseTabId = ReturnType<typeof toInvoicingDunningCaseTabId>;
|
|
25
|
-
export interface InvoicingDunningCaseListViewState
|
|
26
|
+
export interface InvoicingDunningCaseListViewState {
|
|
26
27
|
/** Selected status tab (CES-owned so it persists across page revisits). */
|
|
27
28
|
activeTab: InvoicingDunningCaseTabId;
|
|
29
|
+
/** Per-tab rows, cursor and fetch state; each tab is its own `?status=` query. */
|
|
30
|
+
byTab: InvoicingListByTab;
|
|
28
31
|
counts: InvoicingListCounts;
|
|
29
32
|
countsFetchState: FetchStateAndError;
|
|
30
33
|
filters: InvoicingDunningCaseFilters;
|
|
31
|
-
ids: ID[];
|
|
32
|
-
nextCursor: string | null;
|
|
33
34
|
/** Active server-side sort (undefined = backend default order). */
|
|
34
35
|
sort?: InvoicingListSort;
|
|
35
36
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { FetchStateAndError, ID } from '../../commonStateTypes/common';
|
|
2
|
+
import { ZeniAPIStatus } from '../../responsePayload';
|
|
3
|
+
import { InvoicingListSort } from './invoicingApiHelper';
|
|
4
|
+
/**
|
|
5
|
+
* One status tab of a list. Each tab is its own server query (`?status=`), so
|
|
6
|
+
* its rows, cursor and fetch state are cached apart: switching back to a loaded
|
|
7
|
+
* tab costs no request.
|
|
8
|
+
*/
|
|
9
|
+
export interface InvoicingListTab extends FetchStateAndError {
|
|
10
|
+
ids: ID[];
|
|
11
|
+
nextCursor: string | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Keyed by the raw tab id: tabs come from `/1.0/config`, so a status this
|
|
15
|
+
* build's tab-id union does not know still gets a cache entry.
|
|
16
|
+
*/
|
|
17
|
+
export type InvoicingListByTab = Record<string, InvoicingListTab>;
|
|
18
|
+
export declare const INVOICING_LIST_ALL_TAB = "all";
|
|
19
|
+
/** A tab's cache, or a not-started one when it was never fetched. */
|
|
20
|
+
export declare const getInvoicingListTab: (byTab: InvoicingListByTab, tabId: string) => InvoicingListTab;
|
|
21
|
+
/**
|
|
22
|
+
* The cache a tab reads and fetches. A tab the list API cannot filter on (a
|
|
23
|
+
* derived grouping such as the customers' `at_risk`, not a stored status) is
|
|
24
|
+
* the `all` rows, filtered by the selector.
|
|
25
|
+
*/
|
|
26
|
+
export declare const invoicingListSourceTab: (tabId: string, clientFilteredTabIds?: readonly string[]) => string;
|
|
27
|
+
/**
|
|
28
|
+
* The cache a list fetch fills: the tab the caller named, else the active tab's
|
|
29
|
+
* source. The reducer and the epic both resolve it, so they agree on the tab.
|
|
30
|
+
*/
|
|
31
|
+
export declare const invoicingListFetchTab: (activeTab: string, requestedTab: string | undefined, clientFilteredTabIds?: readonly string[]) => string;
|
|
32
|
+
/** The `status` query param for a source tab; `all` sends none. */
|
|
33
|
+
export declare const invoicingListStatusParam: (sourceTab: string) => string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Whether two list queries match, so their per-tab caches stay valid. A filter
|
|
36
|
+
* left unset and one cleared to `''` are the same query.
|
|
37
|
+
*/
|
|
38
|
+
export declare const isSameInvoicingListQuery: (a: {
|
|
39
|
+
filters: object;
|
|
40
|
+
sort?: InvoicingListSort;
|
|
41
|
+
}, b: {
|
|
42
|
+
filters: object;
|
|
43
|
+
sort?: InvoicingListSort;
|
|
44
|
+
}) => boolean;
|
|
45
|
+
/** What opening a tab should fetch, if anything. */
|
|
46
|
+
export type InvoicingListTabFetch = {
|
|
47
|
+
kind: 'none';
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'firstPage';
|
|
50
|
+
} | {
|
|
51
|
+
cursor: string;
|
|
52
|
+
kind: 'nextPage';
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Fetch a tab that is empty or failed; top up one that holds less than a page
|
|
56
|
+
* while the server says there is more; leave a full or complete one cached.
|
|
57
|
+
* Runs on page/tab visits only, so a server returning short pages cannot loop.
|
|
58
|
+
*/
|
|
59
|
+
export declare function planInvoicingListTabFetch(tab: InvoicingListTab, cacheOverride: boolean): InvoicingListTabFetch;
|
|
60
|
+
export declare function startInvoicingListTabFetch(byTab: InvoicingListByTab, tabId: string, keepExistingListItems: boolean): void;
|
|
61
|
+
export declare function completeInvoicingListTabFetch(byTab: InvoicingListByTab, tabId: string, page: {
|
|
62
|
+
ids: ID[];
|
|
63
|
+
keepExistingListItems: boolean;
|
|
64
|
+
nextCursor: string | null;
|
|
65
|
+
}): void;
|
|
66
|
+
export declare function failInvoicingListTabFetch(byTab: InvoicingListByTab, tabId: string, error: ZeniAPIStatus): void;
|
|
67
|
+
/**
|
|
68
|
+
* A created record leads `all` and, when its status is known, that status's
|
|
69
|
+
* tab if already loaded. Returns false when `all` already had it.
|
|
70
|
+
*/
|
|
71
|
+
export declare function addToInvoicingListTabs(byTab: InvoicingListByTab, id: ID, status?: string): boolean;
|