@zeniai/client-epic-state 5.1.62-betaRD3 → 5.1.62-betaRD4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +14 -1
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +1 -1
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +14 -1
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +2 -0
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +2 -2
- package/package.json +1 -1
|
@@ -4,11 +4,13 @@ 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';
|
|
7
9
|
import { searchTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess, } from '../../../reducers/jeSchedulesViewReducer';
|
|
8
10
|
import { MIN_NEW_SCHEDULE_SEARCH_LENGTH } from '../../../types/jeSchedulesViewState';
|
|
9
11
|
/** Dropdown-sized result set — no pagination for Base Transaction search. */
|
|
10
12
|
const NEW_SCHEDULE_SEARCH_PAGE_SIZE = 10;
|
|
11
|
-
export const searchTransactionsForNewScheduleEpic = (actions$,
|
|
13
|
+
export const searchTransactionsForNewScheduleEpic = (actions$, state$, zeniAPI) => {
|
|
12
14
|
const searchActions$ = actions$.pipe(filter(searchTransactionsForNewSchedule.match));
|
|
13
15
|
/** No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP. */
|
|
14
16
|
const newSearchTooShortOrClear$ = searchActions$.pipe(filter((action) => action.payload.query.trim().length < MIN_NEW_SCHEDULE_SEARCH_LENGTH));
|
|
@@ -18,9 +20,20 @@ export const searchTransactionsForNewScheduleEpic = (actions$, _state$, zeniAPI)
|
|
|
18
20
|
if (query.length < MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
|
|
19
21
|
return EMPTY;
|
|
20
22
|
}
|
|
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
|
+
: [];
|
|
21
33
|
const queryParam = {
|
|
22
34
|
page_size: NEW_SCHEDULE_SEARCH_PAGE_SIZE,
|
|
23
35
|
search_text: query,
|
|
36
|
+
base_txn_account_ids: baseTxnAccountIds,
|
|
24
37
|
};
|
|
25
38
|
return zeniAPI
|
|
26
39
|
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/base_transaction_search?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
@@ -419,8 +419,8 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
419
419
|
};
|
|
420
420
|
},
|
|
421
421
|
searchTransactionsForNewSchedule: {
|
|
422
|
-
prepare({ query }) {
|
|
423
|
-
return { payload: { query } };
|
|
422
|
+
prepare({ query, scheduleType, }) {
|
|
423
|
+
return { payload: { query, scheduleType } };
|
|
424
424
|
},
|
|
425
425
|
reducer(draft, action) {
|
|
426
426
|
const trimmed = action.payload.query.trim();
|
|
@@ -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>,
|
|
8
|
+
export declare const searchTransactionsForNewScheduleEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -7,11 +7,13 @@ 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");
|
|
10
12
|
const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
|
|
11
13
|
const jeSchedulesViewState_1 = require("../../../types/jeSchedulesViewState");
|
|
12
14
|
/** Dropdown-sized result set — no pagination for Base Transaction search. */
|
|
13
15
|
const NEW_SCHEDULE_SEARCH_PAGE_SIZE = 10;
|
|
14
|
-
const searchTransactionsForNewScheduleEpic = (actions$,
|
|
16
|
+
const searchTransactionsForNewScheduleEpic = (actions$, state$, zeniAPI) => {
|
|
15
17
|
const searchActions$ = actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.searchTransactionsForNewSchedule.match));
|
|
16
18
|
/** No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP. */
|
|
17
19
|
const newSearchTooShortOrClear$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.query.trim().length < jeSchedulesViewState_1.MIN_NEW_SCHEDULE_SEARCH_LENGTH));
|
|
@@ -21,9 +23,20 @@ const searchTransactionsForNewScheduleEpic = (actions$, _state$, zeniAPI) => {
|
|
|
21
23
|
if (query.length < jeSchedulesViewState_1.MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
|
|
22
24
|
return rxjs_1.EMPTY;
|
|
23
25
|
}
|
|
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
|
+
: [];
|
|
24
36
|
const queryParam = {
|
|
25
37
|
page_size: NEW_SCHEDULE_SEARCH_PAGE_SIZE,
|
|
26
38
|
search_text: query,
|
|
39
|
+
base_txn_account_ids: baseTxnAccountIds,
|
|
27
40
|
};
|
|
28
41
|
return zeniAPI
|
|
29
42
|
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/base_transaction_search?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
@@ -71,8 +71,10 @@ export declare const clearExpenseAutomationJESchedulesView: import("@reduxjs/too
|
|
|
71
71
|
status: ZeniAPIStatus;
|
|
72
72
|
}, "expenseAutomationJESchedulesView/saveNewScheduleFailure">, saveNewScheduleSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationJESchedulesView/saveNewScheduleSuccess">, searchTransactionsForNewSchedule: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[{
|
|
73
73
|
query: string;
|
|
74
|
+
scheduleType: "fixed_assets" | "prepaid_expenses";
|
|
74
75
|
}], {
|
|
75
76
|
query: string;
|
|
77
|
+
scheduleType: "prepaid_expenses" | "fixed_assets";
|
|
76
78
|
}, "expenseAutomationJESchedulesView/searchTransactionsForNewSchedule", never, never>, searchTransactionsForNewScheduleFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
77
79
|
status: ZeniAPIStatus;
|
|
78
80
|
}, "expenseAutomationJESchedulesView/searchTransactionsForNewScheduleFailure">, searchTransactionsForNewScheduleSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
@@ -424,8 +424,8 @@ const expenseAutomationJESchedulesView = (0, toolkit_1.createSlice)({
|
|
|
424
424
|
};
|
|
425
425
|
},
|
|
426
426
|
searchTransactionsForNewSchedule: {
|
|
427
|
-
prepare({ query }) {
|
|
428
|
-
return { payload: { query } };
|
|
427
|
+
prepare({ query, scheduleType, }) {
|
|
428
|
+
return { payload: { query, scheduleType } };
|
|
429
429
|
},
|
|
430
430
|
reducer(draft, action) {
|
|
431
431
|
const trimmed = action.payload.query.trim();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.1.62-
|
|
3
|
+
"version": "5.1.62-betaRD4",
|
|
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",
|