@zeniai/client-epic-state 5.1.69 → 5.1.70

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 (81) hide show
  1. package/lib/esm/index.js +7 -7
  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/index.d.ts +7 -7
  30. package/lib/index.js +15 -8
  31. package/lib/view/invoicing/couponView/couponViewEpics.js +0 -3
  32. package/lib/view/invoicing/couponView/couponViewReducer.d.ts +1 -1
  33. package/lib/view/invoicing/couponView/couponViewReducer.js +8 -2
  34. package/lib/view/invoicing/couponView/couponViewSelector.d.ts +1 -0
  35. package/lib/view/invoicing/couponView/couponViewSelector.js +27 -14
  36. package/lib/view/invoicing/couponView/couponViewState.d.ts +2 -1
  37. package/lib/view/invoicing/invoiceList/fetchInvoiceListEpic.d.ts +1 -1
  38. package/lib/view/invoicing/invoiceList/fetchInvoiceListEpic.js +7 -5
  39. package/lib/view/invoicing/invoiceList/fetchInvoiceListPageEpic.js +2 -1
  40. package/lib/view/invoicing/invoiceList/invoiceListReducer.d.ts +5 -4
  41. package/lib/view/invoicing/invoiceList/invoiceListReducer.js +63 -37
  42. package/lib/view/invoicing/invoiceList/invoiceListSelector.d.ts +1 -0
  43. package/lib/view/invoicing/invoiceList/invoiceListSelector.js +19 -15
  44. package/lib/view/invoicing/invoiceList/invoiceListState.d.ts +20 -7
  45. package/lib/view/invoicing/invoiceList/invoiceListState.js +13 -1
  46. package/lib/view/invoicing/invoicingCreditNoteListView/epics/fetchInvoicingCreditNoteListEpic.js +0 -3
  47. package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewReducer.d.ts +1 -1
  48. package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewReducer.js +8 -2
  49. package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewSelector.d.ts +1 -0
  50. package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewSelector.js +23 -13
  51. package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewState.d.ts +2 -1
  52. package/lib/view/invoicing/invoicingCustomerDetailView/fetchInvoicingCustomerDetailPageEpic.js +3 -2
  53. package/lib/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewSelector.js +1 -1
  54. package/lib/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListEpic.js +0 -3
  55. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.d.ts +1 -1
  56. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.js +8 -2
  57. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.d.ts +1 -0
  58. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.js +25 -12
  59. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewState.d.ts +2 -1
  60. package/lib/view/invoicing/invoicingDunningCaseListView/epics/fetchInvoicingDunningCaseListEpic.js +0 -3
  61. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.d.ts +1 -1
  62. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.js +8 -2
  63. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewSelector.d.ts +1 -0
  64. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewSelector.js +23 -13
  65. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewState.d.ts +2 -1
  66. package/lib/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListEpic.js +0 -3
  67. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.d.ts +1 -1
  68. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.js +8 -2
  69. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.d.ts +1 -0
  70. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.js +22 -12
  71. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewState.d.ts +3 -1
  72. package/lib/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListEpic.d.ts +1 -1
  73. package/lib/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListEpic.js +7 -5
  74. package/lib/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListPageEpic.js +2 -1
  75. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewReducer.d.ts +1 -1
  76. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewReducer.js +57 -26
  77. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewSelector.d.ts +1 -0
  78. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewSelector.js +15 -11
  79. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewState.d.ts +18 -4
  80. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewState.js +13 -1
  81. package/package.json +1 -1
@@ -27,7 +27,7 @@ export declare const fetchInvoicingCouponList: import("@reduxjs/toolkit").Action
27
27
  ids: ID[];
28
28
  keepExistingListItems: boolean;
29
29
  nextCursor: string | null;
30
- }, "invoicingCouponView/updateInvoicingCouponList">, updateInvoicingCouponListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCouponView/updateInvoicingCouponListFailure">, fetchInvoicingCouponCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCouponView/fetchInvoicingCouponCounts">, updateInvoicingCouponCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingCouponView/updateInvoicingCouponCounts">, updateInvoicingCouponCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCouponView/updateInvoicingCouponCountsFailure">, updateInvoicingCouponFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingCouponFilters, "invoicingCouponView/updateInvoicingCouponFilters">, addInvoicingCouponToList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
30
+ }, "invoicingCouponView/updateInvoicingCouponList">, updateInvoicingCouponListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCouponView/updateInvoicingCouponListFailure">, fetchInvoicingCouponCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCouponView/fetchInvoicingCouponCounts">, updateInvoicingCouponCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingCouponView/updateInvoicingCouponCounts">, updateInvoicingCouponCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCouponView/updateInvoicingCouponCountsFailure">, updateInvoicingCouponFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingCouponFilters, "invoicingCouponView/updateInvoicingCouponFilters">, setInvoicingCouponActiveTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"active" | "inactive" | "all", "invoicingCouponView/setInvoicingCouponActiveTab">, addInvoicingCouponToList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
31
31
  id: ID;
32
32
  status?: InvoicingCouponStatus;
33
33
  }, "invoicingCouponView/addInvoicingCouponToList">, clearInvoicingCouponView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCouponView/clearInvoicingCouponView">;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearInvoicingCouponView = exports.addInvoicingCouponToList = exports.updateInvoicingCouponFilters = exports.updateInvoicingCouponCountsFailure = exports.updateInvoicingCouponCounts = exports.fetchInvoicingCouponCounts = exports.updateInvoicingCouponListFailure = exports.updateInvoicingCouponList = exports.fetchInvoicingCouponListPage = exports.fetchInvoicingCouponList = exports.initialState = void 0;
4
+ exports.clearInvoicingCouponView = exports.addInvoicingCouponToList = exports.setInvoicingCouponActiveTab = exports.updateInvoicingCouponFilters = exports.updateInvoicingCouponCountsFailure = exports.updateInvoicingCouponCounts = exports.fetchInvoicingCouponCounts = exports.updateInvoicingCouponListFailure = exports.updateInvoicingCouponList = exports.fetchInvoicingCouponListPage = exports.fetchInvoicingCouponList = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  // The discounts-list tabs look up counts by tab id ('active' / 'inactive'),
7
7
  // while a coupon's status is 'active' | 'expired' | 'archived'. Collapse the
@@ -13,6 +13,7 @@ function couponStatusToTabCountKey(status) {
13
13
  exports.initialState = {
14
14
  fetchState: 'Not-Started',
15
15
  error: undefined,
16
+ activeTab: 'all',
16
17
  ids: [],
17
18
  nextCursor: null,
18
19
  filters: {},
@@ -91,6 +92,11 @@ const couponView = (0, toolkit_1.createSlice)({
91
92
  updateInvoicingCouponFilters(draft, action) {
92
93
  draft.filters = action.payload;
93
94
  },
95
+ // Select a status tab. The list API ignores `status` (returns all statuses),
96
+ // so the selector filters rows to this tab client-side — no refetch needed.
97
+ setInvoicingCouponActiveTab(draft, action) {
98
+ draft.activeTab = action.payload;
99
+ },
94
100
  // Reflect a newly created coupon in the cached discounts list + tab counts
95
101
  // so the list page shows it without refetching from the server. Edits keep
96
102
  // the same id/counts, so only creates dispatch this.
@@ -109,5 +115,5 @@ const couponView = (0, toolkit_1.createSlice)({
109
115
  },
110
116
  },
111
117
  });
112
- _a = couponView.actions, exports.fetchInvoicingCouponList = _a.fetchInvoicingCouponList, exports.fetchInvoicingCouponListPage = _a.fetchInvoicingCouponListPage, exports.updateInvoicingCouponList = _a.updateInvoicingCouponList, exports.updateInvoicingCouponListFailure = _a.updateInvoicingCouponListFailure, exports.fetchInvoicingCouponCounts = _a.fetchInvoicingCouponCounts, exports.updateInvoicingCouponCounts = _a.updateInvoicingCouponCounts, exports.updateInvoicingCouponCountsFailure = _a.updateInvoicingCouponCountsFailure, exports.updateInvoicingCouponFilters = _a.updateInvoicingCouponFilters, exports.addInvoicingCouponToList = _a.addInvoicingCouponToList, exports.clearInvoicingCouponView = _a.clearInvoicingCouponView;
118
+ _a = couponView.actions, exports.fetchInvoicingCouponList = _a.fetchInvoicingCouponList, exports.fetchInvoicingCouponListPage = _a.fetchInvoicingCouponListPage, exports.updateInvoicingCouponList = _a.updateInvoicingCouponList, exports.updateInvoicingCouponListFailure = _a.updateInvoicingCouponListFailure, exports.fetchInvoicingCouponCounts = _a.fetchInvoicingCouponCounts, exports.updateInvoicingCouponCounts = _a.updateInvoicingCouponCounts, exports.updateInvoicingCouponCountsFailure = _a.updateInvoicingCouponCountsFailure, exports.updateInvoicingCouponFilters = _a.updateInvoicingCouponFilters, exports.setInvoicingCouponActiveTab = _a.setInvoicingCouponActiveTab, exports.addInvoicingCouponToList = _a.addInvoicingCouponToList, exports.clearInvoicingCouponView = _a.clearInvoicingCouponView;
113
119
  exports.default = couponView.reducer;
@@ -12,6 +12,7 @@ export declare const getInvoicingCouponListHasMore: (state: RootState) => boolea
12
12
  export declare const getInvoicingCouponListFilters: (state: RootState) => InvoicingCouponFilters;
13
13
  export declare const getInvoicingCouponCounts: (state: RootState) => InvoicingListCounts;
14
14
  export interface InvoicingCouponListView extends SelectorView {
15
+ activeTab: InvoicingCouponTabId;
15
16
  columns: InvoicingCouponColumnConfig[];
16
17
  count: InvoicingListCounts;
17
18
  countsFetchState: FetchStateAndError;
@@ -26,18 +26,31 @@ exports.getInvoicingCouponCounts = getInvoicingCouponCounts;
26
26
  * array (and the wrapping view object) keep referential identity until the
27
27
  * coupon entity slice or the list-view slice actually change.
28
28
  */
29
- exports.getInvoicingCouponListView = (0, toolkit_1.createSelector)((state) => state.invoicingCouponState, (state) => state.invoicingCouponViewState, (couponState, listViewState) => ({
30
- columns: couponViewState_1.INVOICING_COUPON_COLUMNS,
31
- coupons: listViewState.ids
29
+ exports.getInvoicingCouponListView = (0, toolkit_1.createSelector)((state) => state.invoicingCouponState, (state) => state.invoicingCouponViewState, (couponState, listViewState) => {
30
+ const { activeTab } = listViewState;
31
+ const allCoupons = listViewState.ids
32
32
  .map((id) => couponState.couponByID[id])
33
- .filter((item) => item != null),
34
- count: listViewState.counts,
35
- countsFetchState: listViewState.countsFetchState,
36
- filters: listViewState.filters,
37
- nextCursor: listViewState.nextCursor,
38
- tabIds: couponViewState_1.INVOICING_COUPON_TABS,
39
- fetchState: listViewState.fetchState,
40
- error: listViewState.error,
41
- sort: listViewState.sort,
42
- version: 1.0,
43
- }));
33
+ .filter((item) => item != null);
34
+ // The list API ignores `status`, so it returns every status; filter to the
35
+ // active tab client-side. 'all' shows everything, 'active' shows only active
36
+ // coupons, and 'inactive' shows every non-active status (undefined included).
37
+ const coupons = activeTab === 'all'
38
+ ? allCoupons
39
+ : allCoupons.filter((coupon) => activeTab === 'active'
40
+ ? coupon.status === 'active'
41
+ : coupon.status !== 'active');
42
+ return {
43
+ activeTab,
44
+ columns: couponViewState_1.INVOICING_COUPON_COLUMNS,
45
+ coupons,
46
+ count: listViewState.counts,
47
+ countsFetchState: listViewState.countsFetchState,
48
+ filters: listViewState.filters,
49
+ nextCursor: listViewState.nextCursor,
50
+ tabIds: couponViewState_1.INVOICING_COUPON_TABS,
51
+ fetchState: listViewState.fetchState,
52
+ error: listViewState.error,
53
+ sort: listViewState.sort,
54
+ version: 1.0,
55
+ };
56
+ });
@@ -3,7 +3,6 @@ import { InvoicingListCounts } from '../../../entity/invoicing/invoicingCommonPa
3
3
  import { InvoicingListSort } from '../invoicingApiHelper';
4
4
  export interface InvoicingCouponFilters {
5
5
  search?: string;
6
- status?: string;
7
6
  }
8
7
  export declare const ALL_INVOICING_COUPON_SORT_KEYS: readonly ["coupon_id", "name", "discount", "duration", "created", "valid_till", "apply_on", "status", "redemptions"];
9
8
  export declare const toInvoicingCouponSortKey: (v: string) => "status" | "name" | "redemptions" | "created" | "coupon_id" | "discount" | "duration" | "valid_till" | "apply_on";
@@ -31,6 +30,8 @@ export type InvoicingCouponTabId = ReturnType<typeof toInvoicingCouponTabId>;
31
30
  */
32
31
  export declare const INVOICING_COUPON_TABS: InvoicingCouponTabId[];
33
32
  export interface InvoicingCouponViewState extends FetchedState {
33
+ /** Selected status tab (CES-owned so it persists across page revisits). */
34
+ activeTab: InvoicingCouponTabId;
34
35
  counts: InvoicingListCounts;
35
36
  countsFetchState: FetchStateAndError;
36
37
  filters: InvoicingCouponFilters;
@@ -6,4 +6,4 @@ import { RootState } from '../../../reducer';
6
6
  import { ZeniAPI } from '../../../zeniAPI';
7
7
  import { fetchInvoiceList, updateInvoiceList, updateInvoiceListFailure, updateInvoiceListFilters } from './invoiceListReducer';
8
8
  export type ActionType = ReturnType<typeof fetchInvoiceList> | ReturnType<typeof updateInvoiceList> | ReturnType<typeof updateInvoiceListFailure> | ReturnType<typeof updateInvoiceListFilters> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateInvoices>;
9
- export declare const fetchInvoiceListEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
9
+ export declare const fetchInvoiceListEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -9,10 +9,10 @@ const invoiceReducer_1 = require("../../../entity/invoicing/invoice/invoiceReduc
9
9
  const responsePayload_1 = require("../../../responsePayload");
10
10
  const invoicingApiHelper_1 = require("../invoicingApiHelper");
11
11
  const invoiceListReducer_1 = require("./invoiceListReducer");
12
- const buildInvoiceListQuery = (filters, cursor, sort) => {
12
+ const buildInvoiceListQuery = (filters, status, cursor, sort) => {
13
13
  const params = new URLSearchParams();
14
- if (filters.status != null && filters.status.length > 0) {
15
- params.set('status', filters.status);
14
+ if (status != null && status.length > 0) {
15
+ params.set('status', status);
16
16
  }
17
17
  if (filters.customerId != null) {
18
18
  params.set('customer_id', filters.customerId);
@@ -36,9 +36,11 @@ const buildInvoiceListQuery = (filters, cursor, sort) => {
36
36
  (0, invoicingApiHelper_1.applyListSortParams)(params, sort);
37
37
  return params;
38
38
  };
39
- const fetchInvoiceListEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(invoiceListReducer_1.fetchInvoiceList.match), (0, operators_1.switchMap)((action) => {
39
+ const fetchInvoiceListEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(invoiceListReducer_1.fetchInvoiceList.match), (0, operators_1.switchMap)((action) => {
40
40
  const { filters, cursor, keepExistingListItems, sort } = action.payload;
41
- const apiUrl = (0, invoicingApiHelper_1.withQuery)(`${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices`, buildInvoiceListQuery(filters, cursor, sort));
41
+ const { activeTab } = state$.value.invoicingInvoiceListState;
42
+ const status = activeTab !== 'all' ? activeTab : undefined;
43
+ const apiUrl = (0, invoicingApiHelper_1.withQuery)(`${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices`, buildInvoiceListQuery(filters, status, cursor, sort));
42
44
  return zeniAPI.getJSON(apiUrl).pipe((0, operators_1.switchMap)((response) => {
43
45
  if ((0, responsePayload_1.isSuccessResponse)(response)) {
44
46
  const items = response.data?.items ?? [];
@@ -19,8 +19,9 @@ const shouldFetch = (fetchStateAndError, cacheOverride) => cacheOverride ||
19
19
  const fetchInvoiceListPageEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(invoiceListReducer_1.fetchInvoiceListPage.match), (0, operators_1.mergeMap)((action) => {
20
20
  const { cacheOverride, filters, sort } = action.payload;
21
21
  const state = state$.value.invoicingInvoiceListState;
22
+ const activeTabState = state.invoiceByTab[state.activeTab];
22
23
  const pageActions = [];
23
- if (shouldFetch({ fetchState: state.fetchState, error: state.error }, cacheOverride)) {
24
+ if (shouldFetch({ fetchState: activeTabState.fetchState, error: activeTabState.error }, cacheOverride)) {
24
25
  pageActions.push((0, invoiceListReducer_1.fetchInvoiceList)({ filters, sort }));
25
26
  }
26
27
  if (shouldFetch(state.countsFetchState, cacheOverride)) {
@@ -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
+ invoiceByTab: (0, invoiceListState_1.makeInvoiceByTab)(),
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.invoiceByTab[draft.activeTab];
40
45
  if (!action.payload.keepExistingListItems) {
41
- draft.invoiceIds = [];
42
- draft.nextCursor = null;
46
+ tab.invoiceIds = [];
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.invoiceByTab = (0, invoiceListState_1.makeInvoiceByTab)();
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.invoiceByTab[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.invoiceIds = action.payload.keepExistingListItems
90
+ ? [...new Set([...tab.invoiceIds, ...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.invoiceByTab[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.invoiceByTab['all'];
144
+ if (allTab.invoiceIds.includes(id)) {
133
145
  return;
134
146
  }
135
- draft.invoiceIds = [id, ...draft.invoiceIds];
147
+ allTab.invoiceIds = [id, ...allTab.invoiceIds];
148
+ const statusTab = statusToTabId(status);
149
+ if (statusTab != null) {
150
+ const tab = draft.invoiceByTab[statusTab];
151
+ if (!tab.invoiceIds.includes(id)) {
152
+ tab.invoiceIds = [id, ...tab.invoiceIds];
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.invoiceByTab = (0, invoiceListState_1.makeInvoiceByTab)();
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.invoiceByTab[listViewState.activeTab];
14
+ return {
15
+ activeTab: listViewState.activeTab,
16
+ invoices: activeTabState.invoiceIds
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,32 @@ 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
+ invoiceIds: ID[];
30
+ nextCursor: string | null;
31
+ }
32
+ export interface InvoiceListState {
33
+ /** Selected status tab (CES-owned so it persists across page revisits). */
34
+ activeTab: InvoicingInvoiceTabId;
35
+ /** Tab-independent list counts. */
25
36
  counts: InvoicingListCounts;
26
37
  countsFetchState: FetchStateAndError;
38
+ /** Base query shared across tabs (search / customer / subscription / dates). */
27
39
  filters: InvoiceListFilters;
28
- /** Ordered invoice IDs for the current list view. */
29
- invoiceIds: ID[];
40
+ /** Per-tab cached invoice ids + cursor + fetch state. */
41
+ invoiceByTab: Record<InvoicingInvoiceTabId, InvoiceTabState>;
30
42
  kpisFetchState: FetchStateAndError;
31
- /** Cursor for the next page (null when there are no more pages). */
32
- nextCursor: string | null;
43
+ /** Tab-independent money KPIs. */
33
44
  kpis?: InvoicingInvoiceKPIs;
34
45
  /** Active server-side sort (undefined = backend default order). */
35
46
  sort?: InvoicingListSort;
36
47
  }
48
+ export declare const makeInvoiceTabState: () => InvoiceTabState;
49
+ export declare const makeInvoiceByTab: () => Record<InvoicingInvoiceTabId, InvoiceTabState>;
@@ -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.makeInvoiceByTab = 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
+ invoiceIds: [],
26
+ nextCursor: null,
27
+ fetchState: 'Not-Started',
28
+ error: undefined,
29
+ });
30
+ exports.makeInvoiceTabState = makeInvoiceTabState;
31
+ const makeInvoiceByTab = () => exports.ALL_INVOICING_INVOICE_TAB_IDS.reduce((acc, tabId) => {
32
+ acc[tabId] = (0, exports.makeInvoiceTabState)();
33
+ return acc;
34
+ }, {});
35
+ exports.makeInvoiceByTab = makeInvoiceByTab;
@@ -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
+ });