@zeniai/client-epic-state 5.1.62-betaRD5 → 5.1.62-betaRD7

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.
@@ -4,13 +4,14 @@ import { getJEScheduleTransactionKey } from '../../../../../entity/jeSchedules/j
4
4
  import { toTransactionType } from '../../../../../entity/transaction/stateTypes/transactionType';
5
5
  import { updateScheduleTransactions } from '../../../../../entity/transaction/transactionReducer';
6
6
  import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
7
- import { getAccountIdsForLabel } from '../../../../accountList/accountListSelector';
8
- import { getAccountLabelForScheduleType, getAccountsTypesForScheduleEpics, } from '../../../../scheduleView/scheduleListView/scheduleListHelper';
9
7
  import { searchTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess, } from '../../../reducers/jeSchedulesViewReducer';
10
8
  import { MIN_NEW_SCHEDULE_SEARCH_LENGTH } from '../../../types/jeSchedulesViewState';
11
9
  /** Dropdown-sized result set — no pagination for Base Transaction search. */
12
10
  const NEW_SCHEDULE_SEARCH_PAGE_SIZE = 10;
13
- export const searchTransactionsForNewScheduleEpic = (actions$, state$, zeniAPI) => {
11
+ /** Fallback when the backend sends a null currency for a search result. */
12
+ const DEFAULT_CURRENCY_CODE = 'USD';
13
+ const DEFAULT_CURRENCY_SYMBOL = '$';
14
+ export const searchTransactionsForNewScheduleEpic = (actions$, _state$, zeniAPI) => {
14
15
  const searchActions$ = actions$.pipe(filter(searchTransactionsForNewSchedule.match));
15
16
  /** No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP. */
16
17
  const newSearchTooShortOrClear$ = searchActions$.pipe(filter((action) => action.payload.query.trim().length < MIN_NEW_SCHEDULE_SEARCH_LENGTH));
@@ -20,20 +21,10 @@ export const searchTransactionsForNewScheduleEpic = (actions$, state$, zeniAPI)
20
21
  if (query.length < MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
21
22
  return EMPTY;
22
23
  }
23
- // The search is scoped to accounts eligible for the schedule type being
24
- // searched for (e.g. accounts labeled prepaid_expenses/fixed_assets) —
25
- // same resolution fetchScheduleListEpic already does for the schedules
26
- // list screen. If the shared schedulesAccountList fetch hasn't
27
- // completed yet, this resolves to [] (zero results until it has).
28
- const { accountListState } = state$.value;
29
- const accountLabel = getAccountLabelForScheduleType(action.payload.scheduleType);
30
- const baseTxnAccountIds = accountLabel != null
31
- ? getAccountIdsForLabel(accountListState, getAccountsTypesForScheduleEpics().accountListKey, accountLabel)
32
- : [];
33
24
  const queryParam = {
34
25
  page_size: NEW_SCHEDULE_SEARCH_PAGE_SIZE,
35
26
  search_text: query,
36
- base_txn_account_ids: baseTxnAccountIds,
27
+ je_schedule_type: action.payload.scheduleType,
37
28
  };
38
29
  return zeniAPI
39
30
  .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/base_transaction_search?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
@@ -43,15 +34,18 @@ export const searchTransactionsForNewScheduleEpic = (actions$, state$, zeniAPI)
43
34
  const transactionsPerCurrency = {};
44
35
  transactions.forEach((transaction) => {
45
36
  const { currency_code, currency_symbol } = transaction;
46
- const existing = transactionsPerCurrency[currency_code];
47
- transactionsPerCurrency[currency_code] =
37
+ const currencyCode = currency_code ?? DEFAULT_CURRENCY_CODE;
38
+ const existing = transactionsPerCurrency[currencyCode];
39
+ transactionsPerCurrency[currencyCode] =
48
40
  existing != null
49
41
  ? {
50
42
  currencySymbol: existing.currencySymbol,
51
43
  transactions: [...existing.transactions, transaction],
52
44
  }
53
45
  : {
54
- currencySymbol: currency_symbol,
46
+ currencySymbol: currency_code == null
47
+ ? DEFAULT_CURRENCY_SYMBOL
48
+ : currency_symbol,
55
49
  transactions: [transaction],
56
50
  };
57
51
  });
@@ -5,4 +5,4 @@ import { RootState } from '../../../../../reducer';
5
5
  import { ZeniAPI } from '../../../../../zeniAPI';
6
6
  import { searchTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess } from '../../../reducers/jeSchedulesViewReducer';
7
7
  export type ActionType = ReturnType<typeof searchTransactionsForNewSchedule> | ReturnType<typeof searchTransactionsForNewScheduleSuccess> | ReturnType<typeof searchTransactionsForNewScheduleFailure> | ReturnType<typeof updateScheduleTransactions>;
8
- export declare const searchTransactionsForNewScheduleEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
8
+ export declare const searchTransactionsForNewScheduleEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -7,13 +7,14 @@ const jeSchedulesTypes_1 = require("../../../../../entity/jeSchedules/jeSchedule
7
7
  const transactionType_1 = require("../../../../../entity/transaction/stateTypes/transactionType");
8
8
  const transactionReducer_1 = require("../../../../../entity/transaction/transactionReducer");
9
9
  const responsePayload_1 = require("../../../../../responsePayload");
10
- const accountListSelector_1 = require("../../../../accountList/accountListSelector");
11
- const scheduleListHelper_1 = require("../../../../scheduleView/scheduleListView/scheduleListHelper");
12
10
  const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
13
11
  const jeSchedulesViewState_1 = require("../../../types/jeSchedulesViewState");
14
12
  /** Dropdown-sized result set — no pagination for Base Transaction search. */
15
13
  const NEW_SCHEDULE_SEARCH_PAGE_SIZE = 10;
16
- const searchTransactionsForNewScheduleEpic = (actions$, state$, zeniAPI) => {
14
+ /** Fallback when the backend sends a null currency for a search result. */
15
+ const DEFAULT_CURRENCY_CODE = 'USD';
16
+ const DEFAULT_CURRENCY_SYMBOL = '$';
17
+ const searchTransactionsForNewScheduleEpic = (actions$, _state$, zeniAPI) => {
17
18
  const searchActions$ = actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.searchTransactionsForNewSchedule.match));
18
19
  /** No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP. */
19
20
  const newSearchTooShortOrClear$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.query.trim().length < jeSchedulesViewState_1.MIN_NEW_SCHEDULE_SEARCH_LENGTH));
@@ -23,20 +24,10 @@ const searchTransactionsForNewScheduleEpic = (actions$, state$, zeniAPI) => {
23
24
  if (query.length < jeSchedulesViewState_1.MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
24
25
  return rxjs_1.EMPTY;
25
26
  }
26
- // The search is scoped to accounts eligible for the schedule type being
27
- // searched for (e.g. accounts labeled prepaid_expenses/fixed_assets) —
28
- // same resolution fetchScheduleListEpic already does for the schedules
29
- // list screen. If the shared schedulesAccountList fetch hasn't
30
- // completed yet, this resolves to [] (zero results until it has).
31
- const { accountListState } = state$.value;
32
- const accountLabel = (0, scheduleListHelper_1.getAccountLabelForScheduleType)(action.payload.scheduleType);
33
- const baseTxnAccountIds = accountLabel != null
34
- ? (0, accountListSelector_1.getAccountIdsForLabel)(accountListState, (0, scheduleListHelper_1.getAccountsTypesForScheduleEpics)().accountListKey, accountLabel)
35
- : [];
36
27
  const queryParam = {
37
28
  page_size: NEW_SCHEDULE_SEARCH_PAGE_SIZE,
38
29
  search_text: query,
39
- base_txn_account_ids: baseTxnAccountIds,
30
+ je_schedule_type: action.payload.scheduleType,
40
31
  };
41
32
  return zeniAPI
42
33
  .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/base_transaction_search?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
@@ -46,15 +37,18 @@ const searchTransactionsForNewScheduleEpic = (actions$, state$, zeniAPI) => {
46
37
  const transactionsPerCurrency = {};
47
38
  transactions.forEach((transaction) => {
48
39
  const { currency_code, currency_symbol } = transaction;
49
- const existing = transactionsPerCurrency[currency_code];
50
- transactionsPerCurrency[currency_code] =
40
+ const currencyCode = currency_code ?? DEFAULT_CURRENCY_CODE;
41
+ const existing = transactionsPerCurrency[currencyCode];
42
+ transactionsPerCurrency[currencyCode] =
51
43
  existing != null
52
44
  ? {
53
45
  currencySymbol: existing.currencySymbol,
54
46
  transactions: [...existing.transactions, transaction],
55
47
  }
56
48
  : {
57
- currencySymbol: currency_symbol,
49
+ currencySymbol: currency_code == null
50
+ ? DEFAULT_CURRENCY_SYMBOL
51
+ : currency_symbol,
58
52
  transactions: [transaction],
59
53
  };
60
54
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.62-betaRD5",
3
+ "version": "5.1.62-betaRD7",
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",