@zeniai/client-epic-state 5.3.21-betaAK1 → 5.3.22

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 (58) hide show
  1. package/lib/entity/genericEntity/customerWithSubCustomersId.d.ts +7 -0
  2. package/lib/entity/genericEntity/customerWithSubCustomersId.js +17 -0
  3. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  4. package/lib/entity/snackbar/snackbarTypes.js +1 -0
  5. package/lib/entity/tenant/tenantPayload.d.ts +6 -0
  6. package/lib/entity/tenant/tenantPayload.js +5 -0
  7. package/lib/entity/tenant/tenantReducer.d.ts +6 -2
  8. package/lib/entity/tenant/tenantReducer.js +28 -4
  9. package/lib/entity/tenant/tenantSelector.d.ts +2 -1
  10. package/lib/entity/tenant/tenantSelector.js +4 -1
  11. package/lib/entity/tenant/tenantState.d.ts +10 -0
  12. package/lib/entity/tenant/tenantState.js +5 -0
  13. package/lib/epic.d.ts +2 -1
  14. package/lib/epic.js +2 -0
  15. package/lib/esm/entity/genericEntity/customerWithSubCustomersId.js +12 -0
  16. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
  17. package/lib/esm/entity/tenant/tenantPayload.js +4 -1
  18. package/lib/esm/entity/tenant/tenantReducer.js +27 -3
  19. package/lib/esm/entity/tenant/tenantSelector.js +2 -0
  20. package/lib/esm/entity/tenant/tenantState.js +4 -1
  21. package/lib/esm/epic.js +2 -0
  22. package/lib/esm/index.js +7 -6
  23. package/lib/esm/view/companyView/companyViewReducer.js +26 -1
  24. package/lib/esm/view/companyView/epic/companyPassport/updateCustomersTabSettingEpic.js +47 -0
  25. package/lib/esm/view/companyView/selector/companyPassportViewSelector.js +2 -0
  26. package/lib/esm/view/companyView/types/companyPassport/companyPassportViewState.js +4 -0
  27. package/lib/esm/view/customerSummaryView/customerSummaryViewReducer.js +39 -6
  28. package/lib/esm/view/customerSummaryView/customerSummaryViewSelector.js +41 -11
  29. package/lib/esm/view/customerSummaryView/epic/fetchCustomerSummaryListEpic.js +6 -1
  30. package/lib/esm/view/spendManagement/billPay/magicLinkView/magicLinkViewSelector.js +1 -0
  31. package/lib/esm/view/transactionList/fetchTransactionListByEntityEpic.js +11 -2
  32. package/lib/esm/view/transactionList/transactionListReducer.js +24 -15
  33. package/lib/esm/view/trend/fetchIncomeTrendEpic.js +6 -2
  34. package/lib/index.d.ts +9 -8
  35. package/lib/index.js +53 -46
  36. package/lib/view/companyView/companyViewReducer.d.ts +8 -1
  37. package/lib/view/companyView/companyViewReducer.js +28 -3
  38. package/lib/view/companyView/epic/companyPassport/updateCustomersTabSettingEpic.d.ts +11 -0
  39. package/lib/view/companyView/epic/companyPassport/updateCustomersTabSettingEpic.js +51 -0
  40. package/lib/view/companyView/selector/companyPassportViewSelector.d.ts +1 -0
  41. package/lib/view/companyView/selector/companyPassportViewSelector.js +4 -1
  42. package/lib/view/companyView/types/companyPassport/companyPassportViewState.d.ts +1 -0
  43. package/lib/view/companyView/types/companyPassport/companyPassportViewState.js +4 -0
  44. package/lib/view/customerSummaryView/customerSummaryViewPayload.d.ts +20 -1
  45. package/lib/view/customerSummaryView/customerSummaryViewReducer.d.ts +3 -1
  46. package/lib/view/customerSummaryView/customerSummaryViewReducer.js +42 -6
  47. package/lib/view/customerSummaryView/customerSummaryViewSelector.d.ts +13 -1
  48. package/lib/view/customerSummaryView/customerSummaryViewSelector.js +45 -12
  49. package/lib/view/customerSummaryView/customerSummaryViewState.d.ts +24 -10
  50. package/lib/view/customerSummaryView/epic/fetchCustomerSummaryListEpic.js +6 -1
  51. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  52. package/lib/view/spendManagement/billPay/magicLinkView/magicLinkViewSelector.d.ts +6 -10
  53. package/lib/view/spendManagement/billPay/magicLinkView/magicLinkViewSelector.js +1 -0
  54. package/lib/view/transactionList/fetchTransactionListByEntityEpic.js +11 -2
  55. package/lib/view/transactionList/transactionListReducer.d.ts +3 -1
  56. package/lib/view/transactionList/transactionListReducer.js +24 -15
  57. package/lib/view/trend/fetchIncomeTrendEpic.js +6 -2
  58. package/package.json +1 -1
@@ -1,15 +1,11 @@
1
+ import { FetchState } from '../../../../commonStateTypes/common';
1
2
  import { RootState } from '../../../../rootStateTypes';
2
3
  import { AddressUpdatableInfo } from '../../../addressView/addressViewState';
3
4
  import { BankAccountSelectorView } from '../../../bankAccountView/bankAccountViewSelector';
4
- export declare const getMagicLinkView: (rootState: RootState) => {
5
- authParams: import("../../../..").AuthParams;
6
- companyName: string;
7
- billAttachment: import("../../../..").Attachment | undefined;
8
- currencySymbol: string;
9
- amount: number;
10
- billFetchState: import("../../../../commonStateTypes/common").FetchState;
11
- fetchState: import("../../../../commonStateTypes/common").FetchState;
12
- };
13
- export type MagicLinkView = ReturnType<typeof getMagicLinkView>;
5
+ import { MagicLinkViewState } from './magicLinkViewState';
6
+ export interface MagicLinkView extends Pick<MagicLinkViewState, 'amount' | 'authParams' | 'billAttachment' | 'companyName' | 'currencySymbol' | 'error' | 'fetchState'> {
7
+ billFetchState: FetchState;
8
+ }
9
+ export declare const getMagicLinkView: (rootState: RootState) => MagicLinkView;
14
10
  export declare function getMagicLinkBankAccountView(state: RootState): BankAccountSelectorView;
15
11
  export declare function getMagicLinkCurrentAddressState(rootState: RootState): AddressUpdatableInfo | undefined;
@@ -13,6 +13,7 @@ const getMagicLinkView = (rootState) => {
13
13
  amount: magicLinkViewState.amount,
14
14
  billFetchState: magicLinkViewState.billFetchStatus.fetchState,
15
15
  fetchState: magicLinkViewState.fetchState,
16
+ error: magicLinkViewState.error,
16
17
  };
17
18
  };
18
19
  exports.getMagicLinkView = getMagicLinkView;
@@ -8,6 +8,7 @@ const get_1 = __importDefault(require("lodash/get"));
8
8
  const rxjs_1 = require("rxjs");
9
9
  const operators_1 = require("rxjs/operators");
10
10
  const timePeriod_1 = require("../../commonStateTypes/timePeriod");
11
+ const customerWithSubCustomersId_1 = require("../../entity/genericEntity/customerWithSubCustomersId");
11
12
  const transactionReducer_1 = require("../../entity/transaction/transactionReducer");
12
13
  const responsePayload_1 = require("../../responsePayload");
13
14
  const transactionListReducer_1 = require("./transactionListReducer");
@@ -19,12 +20,20 @@ const fetchTransactionListByEntityEpic = (actions$, state$, zeniAPI) => actions$
19
20
  if (action.payload.cacheOverride === true ||
20
21
  entityTransactions == null ||
21
22
  entityTransactions.hasValidState() === false) {
23
+ // Customers tab rolled-up view: cached under its own id, sent as the customer id plus the flag
24
+ const { customerId: entityId, includeSubCustomers } = action.payload.entity.type === 'customer'
25
+ ? (0, customerWithSubCustomersId_1.fromCustomerEntityId)(action.payload.entity.id)
26
+ : {
27
+ customerId: action.payload.entity.id,
28
+ includeSubCustomers: false,
29
+ };
22
30
  const queryParam = {
23
31
  start_date: (0, timePeriod_1.toString)(action.payload.period.start),
24
32
  end_date: (0, timePeriod_1.toString)(action.payload.period.end),
25
33
  sort_by: 'create_time',
26
34
  sort_order: 'desc',
27
- entity_id: action.payload.entity.id,
35
+ entity_id: entityId,
36
+ ...(includeSubCustomers ? { include_sub_customers: true } : {}),
28
37
  entity_name: action.payload.entity.name,
29
38
  entity_type: action.payload.entity.type,
30
39
  is_fetch_all_transactions: action.payload.isFetchAllTransactions === true
@@ -37,7 +46,7 @@ const fetchTransactionListByEntityEpic = (actions$, state$, zeniAPI) => actions$
37
46
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
38
47
  const updateActions = [];
39
48
  updateActions.push((0, transactionReducer_1.updateTransactions)(response.data.transactions, (value) => value.transaction_id));
40
- updateActions.push((0, transactionListReducer_1.updateTransactionListByEntity)(response.data));
49
+ updateActions.push((0, transactionListReducer_1.updateTransactionListByEntity)(response.data, action.payload.entity.id));
41
50
  return (0, rxjs_1.from)(updateActions);
42
51
  }
43
52
  else {
@@ -38,7 +38,9 @@ export declare const parallelFetchAccountTransactionList: import("@reduxjs/toolk
38
38
  period: TimePeriod;
39
39
  cacheOverride: any;
40
40
  isFetchAllTransactions: any;
41
- }, "transactionList/fetchEntityTransactionList", never, never>, updateTransactionListByEntity: import("@reduxjs/toolkit").ActionCreatorWithPayload<TransactionListByEntityPayload, "transactionList/updateTransactionListByEntity">, updateTransactionListByEntityFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entity: Entity, period: TimePeriod, error: ZeniAPIStatus<Record<string, unknown>>], {
41
+ }, "transactionList/fetchEntityTransactionList", never, never>, updateTransactionListByEntity: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: TransactionListByEntityPayload, entityId?: string | undefined], TransactionListByEntityPayload, "transactionList/updateTransactionListByEntity", never, {
42
+ entityId: string | undefined;
43
+ }>, updateTransactionListByEntityFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entity: Entity, period: TimePeriod, error: ZeniAPIStatus<Record<string, unknown>>], {
42
44
  entity: Entity;
43
45
  period: TimePeriod;
44
46
  error: ZeniAPIStatus<Record<string, unknown>>;
@@ -168,21 +168,30 @@ const transactionList = (0, toolkit_1.createSlice)({
168
168
  };
169
169
  },
170
170
  },
171
- updateTransactionListByEntity(draft, action) {
172
- const transactionIDs = action.payload.transactions.map((transactionPayload) => transactionPayload.transaction_id);
173
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
174
- const entity = mapTransactionQueryMetaDataToEntity(action.payload.query);
175
- const key = (0, transactionListState_1.getEntityTranKey)(entity, {
176
- start: (0, timePeriod_1.toAbsoluteDay)(action.payload.query.start_date),
177
- end: (0, timePeriod_1.toAbsoluteDay)(action.payload.query.end_date),
178
- });
179
- draft.byEntity.transactionListByEntityKey[key] = {
180
- ...transactionListState_1.initialEntityTransactionState,
181
- fetchState: 'Completed',
182
- error: undefined,
183
- entity: entity,
184
- transactionIDs,
185
- };
171
+ updateTransactionListByEntity: {
172
+ // `entityId`: the requested entity's id when it differs from the query's (a rolled-up customer)
173
+ prepare(payload, entityId) {
174
+ return { payload, meta: { entityId } };
175
+ },
176
+ reducer(draft, action) {
177
+ const transactionIDs = action.payload.transactions.map((transactionPayload) => transactionPayload.transaction_id);
178
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
179
+ const entity = {
180
+ ...mapTransactionQueryMetaDataToEntity(action.payload.query),
181
+ ...(action.meta.entityId != null && { id: action.meta.entityId }),
182
+ };
183
+ const key = (0, transactionListState_1.getEntityTranKey)(entity, {
184
+ start: (0, timePeriod_1.toAbsoluteDay)(action.payload.query.start_date),
185
+ end: (0, timePeriod_1.toAbsoluteDay)(action.payload.query.end_date),
186
+ });
187
+ draft.byEntity.transactionListByEntityKey[key] = {
188
+ ...transactionListState_1.initialEntityTransactionState,
189
+ fetchState: 'Completed',
190
+ error: undefined,
191
+ entity: entity,
192
+ transactionIDs,
193
+ };
194
+ },
186
195
  },
187
196
  updateTransactionListByEntityFailure: {
188
197
  reducer(draft, action) {
@@ -6,6 +6,7 @@ const operators_1 = require("rxjs/operators");
6
6
  const timeframeTick_1 = require("../../commonStateTypes/timeframeTick");
7
7
  const customerIncomeTrendKey_1 = require("../../entity/customerIncome/customerIncomeTrendKey");
8
8
  const customerIncomeTrendReducer_1 = require("../../entity/customerIncome/customerIncomeTrendReducer");
9
+ const customerWithSubCustomersId_1 = require("../../entity/genericEntity/customerWithSubCustomersId");
9
10
  const responsePayload_1 = require("../../responsePayload");
10
11
  const zeniDayJS_1 = require("../../zeniDayJS");
11
12
  const trendReducer_1 = require("./trendReducer");
@@ -28,11 +29,14 @@ const fetchIncomeTrendEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, op
28
29
  return (0, rxjs_1.of)((0, trendReducer_1.updateTrendSuccess)(requestedPeriod));
29
30
  }
30
31
  }
32
+ // The rolled-up view is cached under its own id; the API takes the customer id plus the flag
33
+ const { customerId: apiCustomerId, includeSubCustomers } = (0, customerWithSubCustomersId_1.fromCustomerEntityId)(customerId);
31
34
  const query = {
32
- entity_id: customerId,
35
+ entity_id: apiCustomerId,
33
36
  entity_type: 'customer',
34
- customer_id: customerId,
37
+ customer_id: apiCustomerId,
35
38
  customer_name: customerName,
39
+ ...(includeSubCustomers ? { include_sub_customers: true } : {}),
36
40
  ...(dateRange != null
37
41
  ? { start_date: dateRange.startDate, end_date: dateRange.endDate }
38
42
  : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.3.21-betaAK1",
3
+ "version": "5.3.22",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",