@zeniai/client-epic-state 5.1.68-betaDI2 → 5.1.69-betaAK0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/lib/esm/index.js +9 -9
  2. package/lib/esm/view/invoicing/couponView/couponViewEpics.js +0 -3
  3. package/lib/esm/view/invoicing/couponView/couponViewReducer.js +7 -1
  4. package/lib/esm/view/invoicing/couponView/couponViewSelector.js +27 -14
  5. package/lib/esm/view/invoicing/invoiceList/fetchInvoiceListEpic.js +7 -5
  6. package/lib/esm/view/invoicing/invoiceList/fetchInvoiceListPageEpic.js +2 -1
  7. package/lib/esm/view/invoicing/invoiceList/invoiceListReducer.js +62 -36
  8. package/lib/esm/view/invoicing/invoiceList/invoiceListSelector.js +19 -15
  9. package/lib/esm/view/invoicing/invoiceList/invoiceListState.js +10 -0
  10. package/lib/esm/view/invoicing/invoicingCreditNoteListView/epics/fetchInvoicingCreditNoteListEpic.js +0 -3
  11. package/lib/esm/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewReducer.js +7 -1
  12. package/lib/esm/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewSelector.js +23 -13
  13. package/lib/esm/view/invoicing/invoicingCustomerDetailView/fetchInvoicingCustomerDetailPageEpic.js +3 -2
  14. package/lib/esm/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewSelector.js +1 -1
  15. package/lib/esm/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListEpic.js +0 -3
  16. package/lib/esm/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.js +7 -1
  17. package/lib/esm/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.js +25 -12
  18. package/lib/esm/view/invoicing/invoicingDunningCaseListView/epics/fetchInvoicingDunningCaseListEpic.js +0 -3
  19. package/lib/esm/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.js +7 -1
  20. package/lib/esm/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewSelector.js +23 -13
  21. package/lib/esm/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListEpic.js +0 -3
  22. package/lib/esm/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.js +7 -1
  23. package/lib/esm/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.js +22 -12
  24. package/lib/esm/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListEpic.js +7 -5
  25. package/lib/esm/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListPageEpic.js +2 -1
  26. package/lib/esm/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewReducer.js +56 -25
  27. package/lib/esm/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewSelector.js +15 -11
  28. package/lib/esm/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewState.js +10 -0
  29. package/lib/esm/view/notificationPreferencesView/epics/saveNotificationPreferencesEpic.js +12 -9
  30. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewPayload.js +2 -7
  31. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewReducer.js +2 -47
  32. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewSelector.js +0 -9
  33. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewState.js +0 -1
  34. package/lib/esm/view/spendManagement/billPay/billDetailView/billDetailViewSelector.js +8 -2
  35. package/lib/esm/view/spendManagement/helpers.js +12 -0
  36. package/lib/esm/view/spendManagement/reimbursement/editRemiView/epics/fetchEditRemiDetailPageEpic.js +0 -12
  37. package/lib/esm/view/spendManagement/reimbursement/remiDetailView/remiDetailViewSelector.js +4 -2
  38. package/lib/index.d.ts +9 -9
  39. package/lib/index.js +21 -16
  40. package/lib/view/invoicing/couponView/couponViewEpics.js +0 -3
  41. package/lib/view/invoicing/couponView/couponViewReducer.d.ts +1 -1
  42. package/lib/view/invoicing/couponView/couponViewReducer.js +8 -2
  43. package/lib/view/invoicing/couponView/couponViewSelector.d.ts +1 -0
  44. package/lib/view/invoicing/couponView/couponViewSelector.js +27 -14
  45. package/lib/view/invoicing/couponView/couponViewState.d.ts +2 -1
  46. package/lib/view/invoicing/invoiceList/fetchInvoiceListEpic.d.ts +1 -1
  47. package/lib/view/invoicing/invoiceList/fetchInvoiceListEpic.js +7 -5
  48. package/lib/view/invoicing/invoiceList/fetchInvoiceListPageEpic.js +2 -1
  49. package/lib/view/invoicing/invoiceList/invoiceListReducer.d.ts +5 -4
  50. package/lib/view/invoicing/invoiceList/invoiceListReducer.js +63 -37
  51. package/lib/view/invoicing/invoiceList/invoiceListSelector.d.ts +1 -0
  52. package/lib/view/invoicing/invoiceList/invoiceListSelector.js +19 -15
  53. package/lib/view/invoicing/invoiceList/invoiceListState.d.ts +21 -7
  54. package/lib/view/invoicing/invoiceList/invoiceListState.js +13 -1
  55. package/lib/view/invoicing/invoicingCreditNoteListView/epics/fetchInvoicingCreditNoteListEpic.js +0 -3
  56. package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewReducer.d.ts +1 -1
  57. package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewReducer.js +8 -2
  58. package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewSelector.d.ts +1 -0
  59. package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewSelector.js +23 -13
  60. package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewState.d.ts +2 -1
  61. package/lib/view/invoicing/invoicingCustomerDetailView/fetchInvoicingCustomerDetailPageEpic.js +3 -2
  62. package/lib/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewSelector.js +1 -1
  63. package/lib/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListEpic.js +0 -3
  64. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.d.ts +1 -1
  65. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.js +8 -2
  66. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.d.ts +1 -0
  67. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.js +25 -12
  68. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewState.d.ts +2 -1
  69. package/lib/view/invoicing/invoicingDunningCaseListView/epics/fetchInvoicingDunningCaseListEpic.js +0 -3
  70. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.d.ts +1 -1
  71. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.js +8 -2
  72. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewSelector.d.ts +1 -0
  73. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewSelector.js +23 -13
  74. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewState.d.ts +2 -1
  75. package/lib/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListEpic.js +0 -3
  76. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.d.ts +1 -1
  77. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.js +8 -2
  78. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.d.ts +1 -0
  79. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.js +22 -12
  80. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewState.d.ts +3 -1
  81. package/lib/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListEpic.d.ts +1 -1
  82. package/lib/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListEpic.js +7 -5
  83. package/lib/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListPageEpic.js +2 -1
  84. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewReducer.d.ts +1 -1
  85. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewReducer.js +57 -26
  86. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewSelector.d.ts +1 -0
  87. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewSelector.js +15 -11
  88. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewState.d.ts +18 -4
  89. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewState.js +13 -1
  90. package/lib/view/notificationPreferencesView/epics/saveNotificationPreferencesEpic.d.ts +8 -2
  91. package/lib/view/notificationPreferencesView/epics/saveNotificationPreferencesEpic.js +9 -6
  92. package/lib/view/notificationPreferencesView/notificationPreferencesViewPayload.d.ts +0 -1
  93. package/lib/view/notificationPreferencesView/notificationPreferencesViewPayload.js +2 -7
  94. package/lib/view/notificationPreferencesView/notificationPreferencesViewReducer.d.ts +1 -6
  95. package/lib/view/notificationPreferencesView/notificationPreferencesViewReducer.js +3 -48
  96. package/lib/view/notificationPreferencesView/notificationPreferencesViewSelector.js +0 -9
  97. package/lib/view/notificationPreferencesView/notificationPreferencesViewState.d.ts +0 -1
  98. package/lib/view/notificationPreferencesView/notificationPreferencesViewState.js +0 -1
  99. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewSelector.d.ts +1 -0
  100. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewSelector.js +7 -1
  101. package/lib/view/spendManagement/helpers.d.ts +1 -0
  102. package/lib/view/spendManagement/helpers.js +14 -1
  103. package/lib/view/spendManagement/reimbursement/editRemiView/epics/fetchEditRemiDetailPageEpic.d.ts +1 -2
  104. package/lib/view/spendManagement/reimbursement/editRemiView/epics/fetchEditRemiDetailPageEpic.js +0 -12
  105. package/lib/view/spendManagement/reimbursement/remiDetailView/remiDetailViewSelector.d.ts +1 -0
  106. package/lib/view/spendManagement/reimbursement/remiDetailView/remiDetailViewSelector.js +3 -1
  107. package/package.json +1 -1
@@ -6,9 +6,10 @@ import { ZeniAPIStatus } from '../../../responsePayload';
6
6
  import { InvoicingListSort } from '../invoicingApiHelper';
7
7
  import { InvoiceListFilters, InvoiceListState } from './invoiceListState';
8
8
  /**
9
- * Whether two invoice-list queries (filters + sort) would return the same list.
10
- * Used to invalidate the cached list when a page mounts with a different query
11
- * — e.g. the customer detail page after the main Invoices page, or vice versa.
9
+ * Whether two invoice-list queries share the same base (tab-independent) query.
10
+ * The status tab is server-side per-tab, so it is excluded here — when the base
11
+ * query changes (search / customer / subscription / dates / sort) every per-tab
12
+ * cache is stale and the reducer resets them all.
12
13
  */
13
14
  export declare const sameInvoiceListQuery: (a: {
14
15
  filters: InvoiceListFilters;
@@ -40,7 +41,7 @@ export declare const fetchInvoiceList: import("@reduxjs/toolkit").ActionCreatorW
40
41
  invoices: InvoicingInvoicePayload[];
41
42
  keepExistingListItems: boolean;
42
43
  nextCursor: string | null;
43
- }, "invoicingInvoiceList/updateInvoiceList">, updateInvoiceListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingInvoiceList/updateInvoiceListFailure">, fetchInvoiceCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingInvoiceList/fetchInvoiceCounts">, updateInvoiceCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingInvoiceList/updateInvoiceCounts">, updateInvoiceCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingInvoiceList/updateInvoiceCountsFailure">, fetchInvoiceKPIs: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingInvoiceList/fetchInvoiceKPIs">, updateInvoiceKPIs: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingInvoiceKPIs, "invoicingInvoiceList/updateInvoiceKPIs">, updateInvoiceKPIsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingInvoiceList/updateInvoiceKPIsFailure">, updateInvoiceListFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoiceListFilters, "invoicingInvoiceList/updateInvoiceListFilters">, addInvoiceToList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
44
+ }, "invoicingInvoiceList/updateInvoiceList">, updateInvoiceListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingInvoiceList/updateInvoiceListFailure">, fetchInvoiceCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingInvoiceList/fetchInvoiceCounts">, updateInvoiceCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingInvoiceList/updateInvoiceCounts">, updateInvoiceCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingInvoiceList/updateInvoiceCountsFailure">, fetchInvoiceKPIs: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingInvoiceList/fetchInvoiceKPIs">, updateInvoiceKPIs: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingInvoiceKPIs, "invoicingInvoiceList/updateInvoiceKPIs">, updateInvoiceKPIsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingInvoiceList/updateInvoiceKPIsFailure">, updateInvoiceListFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoiceListFilters, "invoicingInvoiceList/updateInvoiceListFilters">, setInvoiceActiveTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"paid" | "voided" | "partially_paid" | "payment_due" | "not_paid" | "all", "invoicingInvoiceList/setInvoiceActiveTab">, addInvoiceToList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
44
45
  id: ID;
45
46
  status: InvoicingInvoiceStatus;
46
47
  }, "invoicingInvoiceList/addInvoiceToList">, clearInvoiceList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingInvoiceList/clearInvoiceList">;
@@ -1,35 +1,39 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearInvoiceList = exports.addInvoiceToList = exports.updateInvoiceListFilters = exports.updateInvoiceKPIsFailure = exports.updateInvoiceKPIs = exports.fetchInvoiceKPIs = exports.updateInvoiceCountsFailure = exports.updateInvoiceCounts = exports.fetchInvoiceCounts = exports.updateInvoiceListFailure = exports.updateInvoiceList = exports.fetchInvoiceListPage = exports.fetchInvoiceList = exports.initialState = exports.sameInvoiceListQuery = void 0;
4
+ exports.clearInvoiceList = exports.addInvoiceToList = exports.setInvoiceActiveTab = exports.updateInvoiceListFilters = exports.updateInvoiceKPIsFailure = exports.updateInvoiceKPIs = exports.fetchInvoiceKPIs = exports.updateInvoiceCountsFailure = exports.updateInvoiceCounts = exports.fetchInvoiceCounts = exports.updateInvoiceListFailure = exports.updateInvoiceList = exports.fetchInvoiceListPage = exports.fetchInvoiceList = exports.initialState = exports.sameInvoiceListQuery = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
+ const invoiceListState_1 = require("./invoiceListState");
6
7
  /**
7
- * Whether two invoice-list queries (filters + sort) would return the same list.
8
- * Used to invalidate the cached list when a page mounts with a different query
9
- * — e.g. the customer detail page after the main Invoices page, or vice versa.
8
+ * Whether two invoice-list queries share the same base (tab-independent) query.
9
+ * The status tab is server-side per-tab, so it is excluded here — when the base
10
+ * query changes (search / customer / subscription / dates / sort) every per-tab
11
+ * cache is stale and the reducer resets them all.
10
12
  */
11
13
  const sameInvoiceListQuery = (a, b) => a.filters.customerId === b.filters.customerId &&
12
14
  a.filters.subscriptionId === b.filters.subscriptionId &&
13
- a.filters.status === b.filters.status &&
14
15
  a.filters.search === b.filters.search &&
15
16
  a.filters.dateFrom === b.filters.dateFrom &&
16
17
  a.filters.dateTo === b.filters.dateTo &&
17
18
  a.sort?.field === b.sort?.field &&
18
19
  a.sort?.dir === b.sort?.dir;
19
20
  exports.sameInvoiceListQuery = sameInvoiceListQuery;
21
+ /**
22
+ * Narrow an invoice status to a status tab id when one exists. Statuses like
23
+ * `draft` / `posted` / `pending` have no dedicated tab, so a newly created
24
+ * invoice in one of those states only lands in the `all` tab.
25
+ */
26
+ const statusToTabId = (status) => invoiceListState_1.ALL_INVOICING_INVOICE_TAB_IDS.includes(status)
27
+ ? status
28
+ : undefined;
20
29
  exports.initialState = {
21
- fetchState: 'Not-Started',
22
- error: undefined,
23
- invoiceIds: [],
24
- nextCursor: null,
30
+ activeTab: 'all',
31
+ byTab: (0, invoiceListState_1.makeInvoiceIdsByTab)(),
25
32
  filters: {},
26
33
  counts: { all: 0 },
27
34
  countsFetchState: { fetchState: 'Not-Started', error: undefined },
28
35
  kpis: undefined,
29
36
  kpisFetchState: { fetchState: 'Not-Started', error: undefined },
30
- hasValidState() {
31
- return this.fetchState === 'Completed';
32
- },
33
37
  };
34
38
  const invoiceList = (0, toolkit_1.createSlice)({
35
39
  name: 'invoicingInvoiceList',
@@ -37,14 +41,15 @@ const invoiceList = (0, toolkit_1.createSlice)({
37
41
  reducers: {
38
42
  fetchInvoiceList: {
39
43
  reducer(draft, action) {
44
+ const tab = draft.byTab[draft.activeTab];
40
45
  if (!action.payload.keepExistingListItems) {
41
- draft.invoiceIds = [];
42
- draft.nextCursor = null;
46
+ tab.ids = [];
47
+ tab.nextCursor = null;
43
48
  }
44
49
  draft.filters = action.payload.filters;
45
50
  draft.sort = action.payload.sort;
46
- draft.fetchState = 'In-Progress';
47
- draft.error = undefined;
51
+ tab.fetchState = 'In-Progress';
52
+ tab.error = undefined;
48
53
  },
49
54
  prepare(payload) {
50
55
  return {
@@ -59,13 +64,11 @@ const invoiceList = (0, toolkit_1.createSlice)({
59
64
  },
60
65
  fetchInvoiceListPage: {
61
66
  reducer(draft, action) {
62
- // A different query invalidates the cached list — reset so the page
63
- // epic's shouldFetch refetches instead of showing another view's rows
64
- // (e.g. a customer-filtered list left behind by the detail page).
67
+ // A different base query invalidates every tab's cache — reset so the
68
+ // page epic's shouldFetch refetches the active tab instead of showing
69
+ // rows fetched under a stale search/customer/subscription/dates/sort.
65
70
  if (!(0, exports.sameInvoiceListQuery)(draft, action.payload)) {
66
- draft.invoiceIds = [];
67
- draft.nextCursor = null;
68
- draft.fetchState = 'Not-Started';
71
+ draft.byTab = (0, invoiceListState_1.makeInvoiceIdsByTab)();
69
72
  }
70
73
  draft.filters = action.payload.filters;
71
74
  draft.sort = action.payload.sort;
@@ -81,17 +84,19 @@ const invoiceList = (0, toolkit_1.createSlice)({
81
84
  },
82
85
  },
83
86
  updateInvoiceList(draft, action) {
87
+ const tab = draft.byTab[draft.activeTab];
84
88
  const newIds = action.payload.invoices.map((invoice) => invoice.id);
85
- draft.invoiceIds = action.payload.keepExistingListItems
86
- ? [...new Set([...draft.invoiceIds, ...newIds])]
89
+ tab.ids = action.payload.keepExistingListItems
90
+ ? [...new Set([...tab.ids, ...newIds])]
87
91
  : newIds;
88
- draft.nextCursor = action.payload.nextCursor;
89
- draft.fetchState = 'Completed';
90
- draft.error = undefined;
92
+ tab.nextCursor = action.payload.nextCursor;
93
+ tab.fetchState = 'Completed';
94
+ tab.error = undefined;
91
95
  },
92
96
  updateInvoiceListFailure(draft, action) {
93
- draft.fetchState = 'Error';
94
- draft.error = action.payload;
97
+ const tab = draft.byTab[draft.activeTab];
98
+ tab.fetchState = 'Error';
99
+ tab.error = action.payload;
95
100
  },
96
101
  fetchInvoiceCounts(draft) {
97
102
  draft.countsFetchState.fetchState = 'In-Progress';
@@ -122,24 +127,45 @@ const invoiceList = (0, toolkit_1.createSlice)({
122
127
  updateInvoiceListFilters(draft, action) {
123
128
  draft.filters = action.payload;
124
129
  },
130
+ // Select a status tab. The view dispatches the follow-up fetchInvoiceListPage
131
+ // so the page epic fetches the tab when its cache is empty and reuses it when
132
+ // already loaded.
133
+ setInvoiceActiveTab(draft, action) {
134
+ draft.activeTab = action.payload;
135
+ },
125
136
  // Reflect a newly created invoice in the cached list + tab counts so the
126
- // invoices page shows it without refetching from the server. Bumps the
127
- // `all` total and the per-status count key the tabs read (a create is
128
- // typically `draft`). KPIs are money aggregates (Amount, not a plain
129
- // increment), so they are left untouched and refetched lazily.
137
+ // invoices page shows it without refetching. Prepends the id to the `all`
138
+ // tab and its status tab (dedup via includes), and bumps the `all` total and
139
+ // the per-status count key the tabs read. KPIs are money aggregates, so they
140
+ // are left untouched and refetched lazily.
130
141
  addInvoiceToList(draft, action) {
131
142
  const { id, status } = action.payload;
132
- if (draft.invoiceIds.includes(id)) {
143
+ const allTab = draft.byTab['all'];
144
+ if (allTab.ids.includes(id)) {
133
145
  return;
134
146
  }
135
- draft.invoiceIds = [id, ...draft.invoiceIds];
147
+ allTab.ids = [id, ...allTab.ids];
148
+ const statusTab = statusToTabId(status);
149
+ if (statusTab != null) {
150
+ const tab = draft.byTab[statusTab];
151
+ if (!tab.ids.includes(id)) {
152
+ tab.ids = [id, ...tab.ids];
153
+ }
154
+ }
136
155
  draft.counts.all += 1;
137
156
  draft.counts[status] = (draft.counts[status] ?? 0) + 1;
138
157
  },
139
158
  clearInvoiceList(draft) {
140
- Object.assign(draft, exports.initialState);
159
+ draft.activeTab = 'all';
160
+ draft.byTab = (0, invoiceListState_1.makeInvoiceIdsByTab)();
161
+ draft.filters = {};
162
+ draft.sort = undefined;
163
+ draft.counts = { all: 0 };
164
+ draft.countsFetchState = { fetchState: 'Not-Started', error: undefined };
165
+ draft.kpis = undefined;
166
+ draft.kpisFetchState = { fetchState: 'Not-Started', error: undefined };
141
167
  },
142
168
  },
143
169
  });
144
- _a = invoiceList.actions, exports.fetchInvoiceList = _a.fetchInvoiceList, exports.fetchInvoiceListPage = _a.fetchInvoiceListPage, exports.updateInvoiceList = _a.updateInvoiceList, exports.updateInvoiceListFailure = _a.updateInvoiceListFailure, exports.fetchInvoiceCounts = _a.fetchInvoiceCounts, exports.updateInvoiceCounts = _a.updateInvoiceCounts, exports.updateInvoiceCountsFailure = _a.updateInvoiceCountsFailure, exports.fetchInvoiceKPIs = _a.fetchInvoiceKPIs, exports.updateInvoiceKPIs = _a.updateInvoiceKPIs, exports.updateInvoiceKPIsFailure = _a.updateInvoiceKPIsFailure, exports.updateInvoiceListFilters = _a.updateInvoiceListFilters, exports.addInvoiceToList = _a.addInvoiceToList, exports.clearInvoiceList = _a.clearInvoiceList;
170
+ _a = invoiceList.actions, exports.fetchInvoiceList = _a.fetchInvoiceList, exports.fetchInvoiceListPage = _a.fetchInvoiceListPage, exports.updateInvoiceList = _a.updateInvoiceList, exports.updateInvoiceListFailure = _a.updateInvoiceListFailure, exports.fetchInvoiceCounts = _a.fetchInvoiceCounts, exports.updateInvoiceCounts = _a.updateInvoiceCounts, exports.updateInvoiceCountsFailure = _a.updateInvoiceCountsFailure, exports.fetchInvoiceKPIs = _a.fetchInvoiceKPIs, exports.updateInvoiceKPIs = _a.updateInvoiceKPIs, exports.updateInvoiceKPIsFailure = _a.updateInvoiceKPIsFailure, exports.updateInvoiceListFilters = _a.updateInvoiceListFilters, exports.setInvoiceActiveTab = _a.setInvoiceActiveTab, exports.addInvoiceToList = _a.addInvoiceToList, exports.clearInvoiceList = _a.clearInvoiceList;
145
171
  exports.default = invoiceList.reducer;
@@ -5,6 +5,7 @@ import { InvoicingListCounts } from '../../../entity/invoicing/invoicingCommonPa
5
5
  import { RootState } from '../../../reducer';
6
6
  import { InvoiceListFilters, InvoicingInvoiceTabId } from './invoiceListState';
7
7
  export interface InvoiceListView extends SelectorView {
8
+ activeTab: InvoicingInvoiceTabId;
8
9
  counts: InvoicingListCounts;
9
10
  countsFetchState: FetchStateAndError;
10
11
  filters: InvoiceListFilters;
@@ -9,18 +9,22 @@ const invoiceListState_1 = require("./invoiceListState");
9
9
  * array (and the wrapping view object) keep referential identity until the
10
10
  * invoice entity slice or the list-view slice actually change.
11
11
  */
12
- exports.getInvoiceListView = (0, toolkit_1.createSelector)((state) => state.invoicingInvoiceState, (state) => state.invoicingInvoiceListState, (invoiceState, listViewState) => ({
13
- invoices: listViewState.invoiceIds
14
- .map((id) => invoiceState.invoiceByID[id])
15
- .filter((item) => item != null),
16
- counts: listViewState.counts,
17
- countsFetchState: listViewState.countsFetchState,
18
- filters: listViewState.filters,
19
- kpis: listViewState.kpis,
20
- kpisFetchState: listViewState.kpisFetchState,
21
- nextCursor: listViewState.nextCursor,
22
- tabIds: invoiceListState_1.INVOICING_INVOICE_TABS,
23
- fetchState: listViewState.fetchState,
24
- error: listViewState.error,
25
- version: 1.0,
26
- }));
12
+ exports.getInvoiceListView = (0, toolkit_1.createSelector)((state) => state.invoicingInvoiceState, (state) => state.invoicingInvoiceListState, (invoiceState, listViewState) => {
13
+ const activeTabState = listViewState.byTab[listViewState.activeTab];
14
+ return {
15
+ activeTab: listViewState.activeTab,
16
+ invoices: activeTabState.ids
17
+ .map((id) => invoiceState.invoiceByID[id])
18
+ .filter((item) => item != null),
19
+ counts: listViewState.counts,
20
+ countsFetchState: listViewState.countsFetchState,
21
+ filters: listViewState.filters,
22
+ kpis: listViewState.kpis,
23
+ kpisFetchState: listViewState.kpisFetchState,
24
+ nextCursor: activeTabState.nextCursor,
25
+ tabIds: invoiceListState_1.INVOICING_INVOICE_TABS,
26
+ fetchState: activeTabState.fetchState,
27
+ error: activeTabState.error,
28
+ version: 1.0,
29
+ };
30
+ });
@@ -1,4 +1,4 @@
1
- import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
1
+ import { FetchStateAndError, ID } from '../../../commonStateTypes/common';
2
2
  import { InvoicingInvoiceKPIs } from '../../../entity/invoicing/invoice/invoiceState';
3
3
  import { InvoicingListCounts } from '../../../entity/invoicing/invoicingCommonPayload';
4
4
  import { InvoicingListSort } from '../invoicingApiHelper';
@@ -18,19 +18,33 @@ export interface InvoiceListFilters {
18
18
  dateFrom?: string;
19
19
  dateTo?: string;
20
20
  search?: string;
21
- status?: string;
22
21
  subscriptionId?: ID;
23
22
  }
24
- export interface InvoiceListState extends FetchedState {
23
+ /**
24
+ * Per-tab cache slice. Each status tab is a separate server query (the backend
25
+ * filters by `status`), so its loaded ids, pagination cursor and fetch state are
26
+ * cached independently. Mirrors the transaction-list per-tab cache pattern.
27
+ */
28
+ export interface InvoiceTabState extends FetchStateAndError {
29
+ ids: ID[];
30
+ nextCursor: string | null;
31
+ }
32
+ export type InvoiceIdsByTab = Record<InvoicingInvoiceTabId, InvoiceTabState>;
33
+ export interface InvoiceListState {
34
+ /** Selected status tab (CES-owned so it persists across page revisits). */
35
+ activeTab: InvoicingInvoiceTabId;
36
+ /** Per-tab cached ids + cursor + fetch state. */
37
+ byTab: InvoiceIdsByTab;
38
+ /** Tab-independent list counts. */
25
39
  counts: InvoicingListCounts;
26
40
  countsFetchState: FetchStateAndError;
41
+ /** Base query shared across tabs (search / customer / subscription / dates). */
27
42
  filters: InvoiceListFilters;
28
- /** Ordered invoice IDs for the current list view. */
29
- invoiceIds: ID[];
30
43
  kpisFetchState: FetchStateAndError;
31
- /** Cursor for the next page (null when there are no more pages). */
32
- nextCursor: string | null;
44
+ /** Tab-independent money KPIs. */
33
45
  kpis?: InvoicingInvoiceKPIs;
34
46
  /** Active server-side sort (undefined = backend default order). */
35
47
  sort?: InvoicingListSort;
36
48
  }
49
+ export declare const makeInvoiceTabState: () => InvoiceTabState;
50
+ export declare const makeInvoiceIdsByTab: () => InvoiceIdsByTab;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.INVOICING_INVOICE_TABS = exports.toInvoicingInvoiceTabId = exports.ALL_INVOICING_INVOICE_TAB_IDS = void 0;
3
+ exports.makeInvoiceIdsByTab = exports.makeInvoiceTabState = exports.INVOICING_INVOICE_TABS = exports.toInvoicingInvoiceTabId = exports.ALL_INVOICING_INVOICE_TAB_IDS = void 0;
4
4
  const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
5
5
  exports.ALL_INVOICING_INVOICE_TAB_IDS = [
6
6
  'all',
@@ -21,3 +21,15 @@ exports.toInvoicingInvoiceTabId = toInvoicingInvoiceTabId;
21
21
  exports.INVOICING_INVOICE_TABS = [
22
22
  ...exports.ALL_INVOICING_INVOICE_TAB_IDS,
23
23
  ];
24
+ const makeInvoiceTabState = () => ({
25
+ ids: [],
26
+ nextCursor: null,
27
+ fetchState: 'Not-Started',
28
+ error: undefined,
29
+ });
30
+ exports.makeInvoiceTabState = makeInvoiceTabState;
31
+ const makeInvoiceIdsByTab = () => exports.ALL_INVOICING_INVOICE_TAB_IDS.reduce((acc, tabId) => {
32
+ acc[tabId] = (0, exports.makeInvoiceTabState)();
33
+ return acc;
34
+ }, {});
35
+ exports.makeInvoiceIdsByTab = makeInvoiceIdsByTab;
@@ -9,9 +9,6 @@ const invoicingApiHelper_1 = require("../../invoicingApiHelper");
9
9
  const invoicingCreditNoteListViewReducer_1 = require("../invoicingCreditNoteListViewReducer");
10
10
  const buildQuery = (filters, cursor, sort) => {
11
11
  const params = new URLSearchParams();
12
- if (filters.status != null && filters.status.length > 0) {
13
- params.set('status', filters.status);
14
- }
15
12
  if (filters.customerId != null) {
16
13
  params.set('customer_id', filters.customerId);
17
14
  }
@@ -26,6 +26,6 @@ export declare const fetchInvoicingCreditNoteList: import("@reduxjs/toolkit").Ac
26
26
  ids: ID[];
27
27
  keepExistingListItems: boolean;
28
28
  nextCursor: string | null;
29
- }, "invoicingCreditNoteListView/updateInvoicingCreditNoteList">, updateInvoicingCreditNoteListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCreditNoteListView/updateInvoicingCreditNoteListFailure">, fetchInvoicingCreditNoteCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCreditNoteListView/fetchInvoicingCreditNoteCounts">, updateInvoicingCreditNoteCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingCreditNoteListView/updateInvoicingCreditNoteCounts">, updateInvoicingCreditNoteCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCreditNoteListView/updateInvoicingCreditNoteCountsFailure">, updateInvoicingCreditNoteFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingCreditNoteFilters, "invoicingCreditNoteListView/updateInvoicingCreditNoteFilters">, clearInvoicingCreditNoteListView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCreditNoteListView/clearInvoicingCreditNoteListView">;
29
+ }, "invoicingCreditNoteListView/updateInvoicingCreditNoteList">, updateInvoicingCreditNoteListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCreditNoteListView/updateInvoicingCreditNoteListFailure">, fetchInvoicingCreditNoteCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCreditNoteListView/fetchInvoicingCreditNoteCounts">, updateInvoicingCreditNoteCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingCreditNoteListView/updateInvoicingCreditNoteCounts">, updateInvoicingCreditNoteCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCreditNoteListView/updateInvoicingCreditNoteCountsFailure">, updateInvoicingCreditNoteFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingCreditNoteFilters, "invoicingCreditNoteListView/updateInvoicingCreditNoteFilters">, setInvoicingCreditNoteActiveTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"adjusted" | "refunded" | "refund_due" | "voided" | "all", "invoicingCreditNoteListView/setInvoicingCreditNoteActiveTab">, clearInvoicingCreditNoteListView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCreditNoteListView/clearInvoicingCreditNoteListView">;
30
30
  declare const _default: import("redux").Reducer<InvoicingCreditNoteListViewState>;
31
31
  export default _default;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearInvoicingCreditNoteListView = exports.updateInvoicingCreditNoteFilters = exports.updateInvoicingCreditNoteCountsFailure = exports.updateInvoicingCreditNoteCounts = exports.fetchInvoicingCreditNoteCounts = exports.updateInvoicingCreditNoteListFailure = exports.updateInvoicingCreditNoteList = exports.fetchInvoicingCreditNoteListPage = exports.fetchInvoicingCreditNoteList = exports.initialState = void 0;
4
+ exports.clearInvoicingCreditNoteListView = exports.setInvoicingCreditNoteActiveTab = exports.updateInvoicingCreditNoteFilters = exports.updateInvoicingCreditNoteCountsFailure = exports.updateInvoicingCreditNoteCounts = exports.fetchInvoicingCreditNoteCounts = exports.updateInvoicingCreditNoteListFailure = exports.updateInvoicingCreditNoteList = exports.fetchInvoicingCreditNoteListPage = exports.fetchInvoicingCreditNoteList = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  exports.initialState = {
7
7
  fetchState: 'Not-Started',
8
8
  error: undefined,
9
+ activeTab: 'all',
9
10
  ids: [],
10
11
  nextCursor: null,
11
12
  filters: {},
@@ -84,10 +85,15 @@ const invoicingCreditNoteListView = (0, toolkit_1.createSlice)({
84
85
  updateInvoicingCreditNoteFilters(draft, action) {
85
86
  draft.filters = action.payload;
86
87
  },
88
+ // Select a status tab. The list API ignores `status` (returns all statuses),
89
+ // so the selector filters rows to this tab client-side — no refetch needed.
90
+ setInvoicingCreditNoteActiveTab(draft, action) {
91
+ draft.activeTab = action.payload;
92
+ },
87
93
  clearInvoicingCreditNoteListView(draft) {
88
94
  Object.assign(draft, exports.initialState);
89
95
  },
90
96
  },
91
97
  });
92
- _a = invoicingCreditNoteListView.actions, exports.fetchInvoicingCreditNoteList = _a.fetchInvoicingCreditNoteList, exports.fetchInvoicingCreditNoteListPage = _a.fetchInvoicingCreditNoteListPage, exports.updateInvoicingCreditNoteList = _a.updateInvoicingCreditNoteList, exports.updateInvoicingCreditNoteListFailure = _a.updateInvoicingCreditNoteListFailure, exports.fetchInvoicingCreditNoteCounts = _a.fetchInvoicingCreditNoteCounts, exports.updateInvoicingCreditNoteCounts = _a.updateInvoicingCreditNoteCounts, exports.updateInvoicingCreditNoteCountsFailure = _a.updateInvoicingCreditNoteCountsFailure, exports.updateInvoicingCreditNoteFilters = _a.updateInvoicingCreditNoteFilters, exports.clearInvoicingCreditNoteListView = _a.clearInvoicingCreditNoteListView;
98
+ _a = invoicingCreditNoteListView.actions, exports.fetchInvoicingCreditNoteList = _a.fetchInvoicingCreditNoteList, exports.fetchInvoicingCreditNoteListPage = _a.fetchInvoicingCreditNoteListPage, exports.updateInvoicingCreditNoteList = _a.updateInvoicingCreditNoteList, exports.updateInvoicingCreditNoteListFailure = _a.updateInvoicingCreditNoteListFailure, exports.fetchInvoicingCreditNoteCounts = _a.fetchInvoicingCreditNoteCounts, exports.updateInvoicingCreditNoteCounts = _a.updateInvoicingCreditNoteCounts, exports.updateInvoicingCreditNoteCountsFailure = _a.updateInvoicingCreditNoteCountsFailure, exports.updateInvoicingCreditNoteFilters = _a.updateInvoicingCreditNoteFilters, exports.setInvoicingCreditNoteActiveTab = _a.setInvoicingCreditNoteActiveTab, exports.clearInvoicingCreditNoteListView = _a.clearInvoicingCreditNoteListView;
93
99
  exports.default = invoicingCreditNoteListView.reducer;
@@ -6,6 +6,7 @@ import { RootState } from '../../../reducer';
6
6
  import { InvoicingListSort } from '../invoicingApiHelper';
7
7
  import { InvoicingCreditNoteColumnConfig, InvoicingCreditNoteFilters, InvoicingCreditNoteTabId } from './invoicingCreditNoteListViewState';
8
8
  export interface InvoicingCreditNoteListView extends SelectorView {
9
+ activeTab: InvoicingCreditNoteTabId;
9
10
  columns: InvoicingCreditNoteColumnConfig[];
10
11
  count: InvoicingListCounts;
11
12
  countsFetchState: FetchStateAndError;
@@ -9,16 +9,26 @@ const invoicingCreditNoteListViewState_1 = require("./invoicingCreditNoteListVie
9
9
  * object) keep referential identity until the credit-note entity slice or the
10
10
  * list-view slice actually change.
11
11
  */
12
- exports.getInvoicingCreditNoteListView = (0, toolkit_1.createSelector)((state) => state.invoicingCreditNoteState, (state) => state.invoicingCreditNoteListViewState, (creditNoteState, listViewState) => ({
13
- columns: invoicingCreditNoteListViewState_1.INVOICING_CREDIT_NOTE_COLUMNS,
14
- creditNotes: (0, creditNoteSelector_1.getInvoicingCreditNotesByIds)(creditNoteState, listViewState.ids),
15
- count: listViewState.counts,
16
- countsFetchState: listViewState.countsFetchState,
17
- filters: listViewState.filters,
18
- nextCursor: listViewState.nextCursor,
19
- tabIds: invoicingCreditNoteListViewState_1.INVOICING_CREDIT_NOTE_TABS,
20
- fetchState: listViewState.fetchState,
21
- error: listViewState.error,
22
- sort: listViewState.sort,
23
- version: 1.0,
24
- }));
12
+ exports.getInvoicingCreditNoteListView = (0, toolkit_1.createSelector)((state) => state.invoicingCreditNoteState, (state) => state.invoicingCreditNoteListViewState, (creditNoteState, listViewState) => {
13
+ const { activeTab } = listViewState;
14
+ const allCreditNotes = (0, creditNoteSelector_1.getInvoicingCreditNotesByIds)(creditNoteState, listViewState.ids);
15
+ // The list API ignores `status`, so it returns every status; filter to the
16
+ // active tab client-side ('all' shows everything).
17
+ const creditNotes = activeTab === 'all'
18
+ ? allCreditNotes
19
+ : allCreditNotes.filter((creditNote) => creditNote.status === activeTab);
20
+ return {
21
+ activeTab,
22
+ columns: invoicingCreditNoteListViewState_1.INVOICING_CREDIT_NOTE_COLUMNS,
23
+ creditNotes,
24
+ count: listViewState.counts,
25
+ countsFetchState: listViewState.countsFetchState,
26
+ filters: listViewState.filters,
27
+ nextCursor: listViewState.nextCursor,
28
+ tabIds: invoicingCreditNoteListViewState_1.INVOICING_CREDIT_NOTE_TABS,
29
+ fetchState: listViewState.fetchState,
30
+ error: listViewState.error,
31
+ sort: listViewState.sort,
32
+ version: 1.0,
33
+ };
34
+ });
@@ -4,7 +4,6 @@ import { InvoicingListSort } from '../invoicingApiHelper';
4
4
  export interface InvoicingCreditNoteFilters {
5
5
  customerId?: ID;
6
6
  search?: string;
7
- status?: string;
8
7
  }
9
8
  export declare const ALL_INVOICING_CREDIT_NOTE_SORT_KEYS: readonly ["credit_note", "customer", "date", "type", "status", "reference_invoice", "utilization", "total"];
10
9
  export declare const toInvoicingCreditNoteSortKey: (v: string) => "date" | "status" | "type" | "customer" | "total" | "credit_note" | "reference_invoice" | "utilization";
@@ -32,6 +31,8 @@ export type InvoicingCreditNoteTabId = ReturnType<typeof toInvoicingCreditNoteTa
32
31
  */
33
32
  export declare const INVOICING_CREDIT_NOTE_TABS: InvoicingCreditNoteTabId[];
34
33
  export interface InvoicingCreditNoteListViewState extends FetchedState {
34
+ /** Selected status tab (CES-owned so it persists across page revisits). */
35
+ activeTab: InvoicingCreditNoteTabId;
35
36
  counts: InvoicingListCounts;
36
37
  countsFetchState: FetchStateAndError;
37
38
  filters: InvoicingCreditNoteFilters;
@@ -23,6 +23,7 @@ const fetchInvoicingCustomerDetailPageEpic = (actions$, state$) => actions$.pipe
23
23
  const { cacheOverride, id } = action.payload;
24
24
  const customerDetail = state$.value.invoicingCustomerDetailViewState.detailById[id];
25
25
  const invoiceListState = state$.value.invoicingInvoiceListState;
26
+ const invoiceListTabState = invoiceListState.byTab[invoiceListState.activeTab];
26
27
  const settingsState = state$.value.invoicingSettingsViewState;
27
28
  const pageActions = [];
28
29
  if (shouldFetch({
@@ -36,8 +37,8 @@ const fetchInvoicingCustomerDetailPageEpic = (actions$, state$) => actions$.pipe
36
37
  const invoiceListIsForCustomer = invoiceListState.filters.customerId === id;
37
38
  if (!invoiceListIsForCustomer ||
38
39
  shouldFetch({
39
- fetchState: invoiceListState.fetchState,
40
- error: invoiceListState.error,
40
+ fetchState: invoiceListTabState.fetchState,
41
+ error: invoiceListTabState.error,
41
42
  }, cacheOverride)) {
42
43
  pageActions.push((0, invoiceListReducer_1.fetchInvoiceList)({ filters: { customerId: id } }));
43
44
  }
@@ -16,7 +16,7 @@ const getInvoicingCustomerDetail = (state, invoicingCustomerID) => {
16
16
  const settings = (0, settingsViewSelector_1.getInvoicingSettings)(state);
17
17
  return {
18
18
  invoicingCustomer: (0, invoicingCustomerSelector_1.getInvoicingCustomerById)(invoicingCustomerState, invoicingCustomerID),
19
- invoices: (0, invoiceSelector_1.getInvoicesByIds)(state.invoicingInvoiceState, state.invoicingInvoiceListState.invoiceIds),
19
+ invoices: (0, invoiceSelector_1.getInvoicesByIds)(state.invoicingInvoiceState, state.invoicingInvoiceListState.byTab[state.invoicingInvoiceListState.activeTab].ids),
20
20
  setupIntent: (0, customerPaymentMethodSelector_1.getInvoicingSetupIntent)(state),
21
21
  setupIntentFetchState: (0, customerPaymentMethodSelector_1.getInvoicingSetupIntentFetchState)(state),
22
22
  plaidLinkToken: (0, customerPaymentMethodSelector_1.getInvoicingPlaidLinkToken)(state),
@@ -14,9 +14,6 @@ const buildQuery = (filters, cursor, sort) => {
14
14
  if (filters.search != null && filters.search.length > 0) {
15
15
  params.set('search', filters.search);
16
16
  }
17
- if (filters.status != null && filters.status.length > 0) {
18
- params.set('status', filters.status);
19
- }
20
17
  params.set('limit', String(invoicingApiHelper_1.INVOICING_LIST_PAGE_SIZE));
21
18
  if (cursor != null) {
22
19
  params.set('cursor', cursor);
@@ -26,7 +26,7 @@ export declare const fetchInvoicingCustomerList: import("@reduxjs/toolkit").Acti
26
26
  ids: ID[];
27
27
  keepExistingListItems: boolean;
28
28
  nextCursor: string | null;
29
- }, "invoicingCustomerListView/updateInvoicingCustomerList">, updateInvoicingCustomerListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCustomerListView/updateInvoicingCustomerListFailure">, fetchInvoicingCustomerCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCustomerListView/fetchInvoicingCustomerCounts">, updateInvoicingCustomerCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingCustomerListView/updateInvoicingCustomerCounts">, updateInvoicingCustomerCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCustomerListView/updateInvoicingCustomerCountsFailure">, updateInvoicingCustomerFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingCustomerFilters, "invoicingCustomerListView/updateInvoicingCustomerFilters">, addInvoicingCustomerToList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
29
+ }, "invoicingCustomerListView/updateInvoicingCustomerList">, updateInvoicingCustomerListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCustomerListView/updateInvoicingCustomerListFailure">, fetchInvoicingCustomerCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCustomerListView/fetchInvoicingCustomerCounts">, updateInvoicingCustomerCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingCustomerListView/updateInvoicingCustomerCounts">, updateInvoicingCustomerCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCustomerListView/updateInvoicingCustomerCountsFailure">, updateInvoicingCustomerFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingCustomerFilters, "invoicingCustomerListView/updateInvoicingCustomerFilters">, setInvoicingCustomerActiveTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"active" | "at_risk" | "trial" | "all", "invoicingCustomerListView/setInvoicingCustomerActiveTab">, addInvoicingCustomerToList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
30
30
  id: ID;
31
31
  status?: string;
32
32
  }, "invoicingCustomerListView/addInvoicingCustomerToList">, clearInvoicingCustomerListView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCustomerListView/clearInvoicingCustomerListView">;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearInvoicingCustomerListView = exports.addInvoicingCustomerToList = exports.updateInvoicingCustomerFilters = exports.updateInvoicingCustomerCountsFailure = exports.updateInvoicingCustomerCounts = exports.fetchInvoicingCustomerCounts = exports.updateInvoicingCustomerListFailure = exports.updateInvoicingCustomerList = exports.fetchInvoicingCustomerListPage = exports.fetchInvoicingCustomerList = exports.initialState = void 0;
4
+ exports.clearInvoicingCustomerListView = 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
  exports.initialState = {
7
7
  fetchState: 'Not-Started',
8
8
  error: undefined,
9
+ activeTab: 'all',
9
10
  ids: [],
10
11
  nextCursor: null,
11
12
  filters: {},
@@ -84,6 +85,11 @@ const invoicingCustomerListView = (0, toolkit_1.createSlice)({
84
85
  updateInvoicingCustomerFilters(draft, action) {
85
86
  draft.filters = action.payload;
86
87
  },
88
+ // Select a status tab. The list API ignores `status` (returns all statuses),
89
+ // so the selector filters rows to this tab client-side — no refetch needed.
90
+ setInvoicingCustomerActiveTab(draft, action) {
91
+ draft.activeTab = action.payload;
92
+ },
87
93
  // Reflect a newly created customer in the cached list + tab counts so the
88
94
  // customer page shows the new row without refetching from the server. The
89
95
  // per-status count key mirrors the customer `status` value the counts map
@@ -105,5 +111,5 @@ const invoicingCustomerListView = (0, toolkit_1.createSlice)({
105
111
  },
106
112
  },
107
113
  });
108
- _a = invoicingCustomerListView.actions, exports.fetchInvoicingCustomerList = _a.fetchInvoicingCustomerList, exports.fetchInvoicingCustomerListPage = _a.fetchInvoicingCustomerListPage, exports.updateInvoicingCustomerList = _a.updateInvoicingCustomerList, exports.updateInvoicingCustomerListFailure = _a.updateInvoicingCustomerListFailure, exports.fetchInvoicingCustomerCounts = _a.fetchInvoicingCustomerCounts, exports.updateInvoicingCustomerCounts = _a.updateInvoicingCustomerCounts, exports.updateInvoicingCustomerCountsFailure = _a.updateInvoicingCustomerCountsFailure, exports.updateInvoicingCustomerFilters = _a.updateInvoicingCustomerFilters, exports.addInvoicingCustomerToList = _a.addInvoicingCustomerToList, exports.clearInvoicingCustomerListView = _a.clearInvoicingCustomerListView;
114
+ _a = invoicingCustomerListView.actions, exports.fetchInvoicingCustomerList = _a.fetchInvoicingCustomerList, exports.fetchInvoicingCustomerListPage = _a.fetchInvoicingCustomerListPage, exports.updateInvoicingCustomerList = _a.updateInvoicingCustomerList, exports.updateInvoicingCustomerListFailure = _a.updateInvoicingCustomerListFailure, exports.fetchInvoicingCustomerCounts = _a.fetchInvoicingCustomerCounts, exports.updateInvoicingCustomerCounts = _a.updateInvoicingCustomerCounts, exports.updateInvoicingCustomerCountsFailure = _a.updateInvoicingCustomerCountsFailure, exports.updateInvoicingCustomerFilters = _a.updateInvoicingCustomerFilters, exports.setInvoicingCustomerActiveTab = _a.setInvoicingCustomerActiveTab, exports.addInvoicingCustomerToList = _a.addInvoicingCustomerToList, exports.clearInvoicingCustomerListView = _a.clearInvoicingCustomerListView;
109
115
  exports.default = invoicingCustomerListView.reducer;
@@ -6,6 +6,7 @@ import { RootState } from '../../../reducer';
6
6
  import { InvoicingListSort } from '../invoicingApiHelper';
7
7
  import { InvoicingCustomerColumnConfig, InvoicingCustomerFilters, InvoicingCustomerTabId } from './invoicingCustomerListViewState';
8
8
  export interface InvoicingCustomerListView extends SelectorView {
9
+ activeTab: InvoicingCustomerTabId;
9
10
  columns: InvoicingCustomerColumnConfig[];
10
11
  count: InvoicingListCounts;
11
12
  countsFetchState: FetchStateAndError;
@@ -10,15 +10,28 @@ const invoicingCustomerListViewState_1 = require("./invoicingCustomerListViewSta
10
10
  * slice actually change. Without this, the connected list page re-rendered on
11
11
  * every unrelated redux action because a fresh array was built each call.
12
12
  */
13
- exports.getInvoicingCustomerListView = (0, toolkit_1.createSelector)((state) => state.invoicingCustomerState, (state) => state.invoicingCustomerListViewState, (customerState, listViewState) => ({
14
- columns: invoicingCustomerListViewState_1.INVOICING_CUSTOMER_COLUMNS,
15
- customers: (0, invoicingCustomerSelector_1.getInvoicingCustomersByIds)(customerState, listViewState.ids),
16
- fetchState: listViewState.fetchState,
17
- error: listViewState.error,
18
- nextCursor: listViewState.nextCursor,
19
- filters: listViewState.filters,
20
- count: listViewState.counts,
21
- countsFetchState: listViewState.countsFetchState,
22
- tabIds: invoicingCustomerListViewState_1.INVOICING_CUSTOMER_TABS,
23
- sort: listViewState.sort,
24
- }));
13
+ exports.getInvoicingCustomerListView = (0, toolkit_1.createSelector)((state) => state.invoicingCustomerState, (state) => state.invoicingCustomerListViewState, (customerState, listViewState) => {
14
+ const { activeTab } = listViewState;
15
+ const allCustomers = (0, invoicingCustomerSelector_1.getInvoicingCustomersByIds)(customerState, listViewState.ids);
16
+ // The list API ignores `status`, so it returns every status; filter to the
17
+ // active tab client-side ('all' shows everything, 'at_risk' keys off the
18
+ // `isAtRisk` flag, the rest match the customer `status`).
19
+ const customers = activeTab === 'all'
20
+ ? allCustomers
21
+ : activeTab === 'at_risk'
22
+ ? allCustomers.filter((customer) => customer.isAtRisk === true)
23
+ : allCustomers.filter((customer) => customer.status === activeTab);
24
+ return {
25
+ activeTab,
26
+ columns: invoicingCustomerListViewState_1.INVOICING_CUSTOMER_COLUMNS,
27
+ customers,
28
+ fetchState: listViewState.fetchState,
29
+ error: listViewState.error,
30
+ nextCursor: listViewState.nextCursor,
31
+ filters: listViewState.filters,
32
+ count: listViewState.counts,
33
+ countsFetchState: listViewState.countsFetchState,
34
+ tabIds: invoicingCustomerListViewState_1.INVOICING_CUSTOMER_TABS,
35
+ sort: listViewState.sort,
36
+ };
37
+ });
@@ -3,7 +3,6 @@ import { InvoicingListCounts } from '../../../entity/invoicing/invoicingCommonPa
3
3
  import { InvoicingListSort } from '../invoicingApiHelper';
4
4
  export interface InvoicingCustomerFilters {
5
5
  search?: string;
6
- status?: string;
7
6
  }
8
7
  export declare const ALL_INVOICING_CUSTOMER_SORT_KEYS: readonly ["name", "email", "billingAddress", "cardStatus", "autoCollect", "status"];
9
8
  export declare const toInvoicingCustomerSortKey: (v: string) => "status" | "name" | "cardStatus" | "email" | "billingAddress" | "autoCollect";
@@ -31,6 +30,8 @@ export type InvoicingCustomerTabId = ReturnType<typeof toInvoicingCustomerTabId>
31
30
  */
32
31
  export declare const INVOICING_CUSTOMER_TABS: InvoicingCustomerTabId[];
33
32
  export interface InvoicingCustomerListViewState extends FetchedState {
33
+ /** Selected status tab (CES-owned so it persists across page revisits). */
34
+ activeTab: InvoicingCustomerTabId;
34
35
  counts: InvoicingListCounts;
35
36
  countsFetchState: FetchStateAndError;
36
37
  filters: InvoicingCustomerFilters;