@zeniai/client-epic-state 5.0.81-betaAK1 → 5.0.81-betaAK3
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/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.js +18 -2
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.d.ts +2 -4
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.js +18 -2
- package/package.json +2 -1
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import { zeroAmount } from '../../../../commonStateTypes/amount';
|
|
2
2
|
import { reduceAllFetchState } from '../../../../commonStateTypes/reduceFetchState';
|
|
3
3
|
import { getUpcomingPaymentEventsByIds } from '../../../../entity/upcomingPaymentEvent/upcomingPaymentEventSelector';
|
|
4
|
+
/**
|
|
5
|
+
* Default account type used when the recommend payload has no movement to
|
|
6
|
+
* expose yet (e.g. before the first fetch resolves). Callers that care about
|
|
7
|
+
* the movement should also gate on `fetchState === 'Completed'`.
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_BANK_ACCOUNT_TYPE = 'deposit_account';
|
|
10
|
+
const DEFAULT_SUB_MOVEMENT_TYPE = 'push';
|
|
4
11
|
export const getCashManagementOverviewBanner = (state) => {
|
|
5
12
|
const { banner } = state.cashManagementOverviewState;
|
|
13
|
+
// The banner today surfaces a single recommended movement (the first one
|
|
14
|
+
// returned by the agent). When the agent returns multiple groups/movements
|
|
15
|
+
// we'll need to broaden this — for now consumers only render one.
|
|
16
|
+
const movement = banner.data?.moneyMovements[0]?.movements[0];
|
|
6
17
|
return {
|
|
7
18
|
fetchState: banner.fetchState,
|
|
8
19
|
error: banner.error,
|
|
9
|
-
|
|
20
|
+
amount: movement?.amount ?? zeroAmount(),
|
|
21
|
+
destinationBankAccountId: movement?.destinationBankAccountId ?? '',
|
|
22
|
+
destinationBankAccountType: movement?.destinationBankAccountType ?? DEFAULT_BANK_ACCOUNT_TYPE,
|
|
23
|
+
reasoning: movement?.reasoning ?? '',
|
|
24
|
+
sourceBankAccountId: movement?.sourceBankAccountId ?? '',
|
|
25
|
+
sourceBankAccountType: movement?.sourceBankAccountType ?? DEFAULT_BANK_ACCOUNT_TYPE,
|
|
26
|
+
subMovementType: movement?.subMovementType ?? DEFAULT_SUB_MOVEMENT_TYPE,
|
|
10
27
|
version: 0,
|
|
11
28
|
};
|
|
12
29
|
};
|
|
@@ -41,7 +58,6 @@ export const getCashManagementOverview = (state) => {
|
|
|
41
58
|
const totalCash = addAmounts(treasuryBalance, cashBalance);
|
|
42
59
|
return {
|
|
43
60
|
banner: getCashManagementOverviewBanner(state),
|
|
44
|
-
bannerFetchState,
|
|
45
61
|
cashBalance,
|
|
46
62
|
horizonDays: cashManagementOverviewState.upcomingPaymentEvents.horizonDays,
|
|
47
63
|
outflowEvents: getUpcomingPaymentEventsByIds(state.upcomingPaymentEventState, cashManagementOverviewState.upcomingPaymentEvents.eventIds),
|
|
@@ -3,13 +3,11 @@ import { FetchStateAndError } from '../../../../commonStateTypes/common';
|
|
|
3
3
|
import { SelectorView } from '../../../../commonStateTypes/viewAndReport/viewAndReport';
|
|
4
4
|
import { UpcomingPaymentEvent } from '../../../../entity/upcomingPaymentEvent/upcomingPaymentEventState';
|
|
5
5
|
import { RootState } from '../../../../reducer';
|
|
6
|
-
import {
|
|
7
|
-
export interface CashManagementOverviewBannerSelectorView extends SelectorView {
|
|
8
|
-
data?: CashManagementBannerData;
|
|
6
|
+
import { CashManagementMovement } from './cashManagementOverviewState';
|
|
7
|
+
export interface CashManagementOverviewBannerSelectorView extends SelectorView, CashManagementMovement {
|
|
9
8
|
}
|
|
10
9
|
export interface CashManagementOverviewSelectorView extends SelectorView {
|
|
11
10
|
banner: CashManagementOverviewBannerSelectorView;
|
|
12
|
-
bannerFetchState: FetchStateAndError;
|
|
13
11
|
cashBalance: Amount;
|
|
14
12
|
horizonDays: number;
|
|
15
13
|
outflowEvents: UpcomingPaymentEvent[];
|
|
@@ -4,12 +4,29 @@ exports.getCashManagementOverview = exports.getCashManagementOverviewBanner = vo
|
|
|
4
4
|
const amount_1 = require("../../../../commonStateTypes/amount");
|
|
5
5
|
const reduceFetchState_1 = require("../../../../commonStateTypes/reduceFetchState");
|
|
6
6
|
const upcomingPaymentEventSelector_1 = require("../../../../entity/upcomingPaymentEvent/upcomingPaymentEventSelector");
|
|
7
|
+
/**
|
|
8
|
+
* Default account type used when the recommend payload has no movement to
|
|
9
|
+
* expose yet (e.g. before the first fetch resolves). Callers that care about
|
|
10
|
+
* the movement should also gate on `fetchState === 'Completed'`.
|
|
11
|
+
*/
|
|
12
|
+
const DEFAULT_BANK_ACCOUNT_TYPE = 'deposit_account';
|
|
13
|
+
const DEFAULT_SUB_MOVEMENT_TYPE = 'push';
|
|
7
14
|
const getCashManagementOverviewBanner = (state) => {
|
|
8
15
|
const { banner } = state.cashManagementOverviewState;
|
|
16
|
+
// The banner today surfaces a single recommended movement (the first one
|
|
17
|
+
// returned by the agent). When the agent returns multiple groups/movements
|
|
18
|
+
// we'll need to broaden this — for now consumers only render one.
|
|
19
|
+
const movement = banner.data?.moneyMovements[0]?.movements[0];
|
|
9
20
|
return {
|
|
10
21
|
fetchState: banner.fetchState,
|
|
11
22
|
error: banner.error,
|
|
12
|
-
|
|
23
|
+
amount: movement?.amount ?? (0, amount_1.zeroAmount)(),
|
|
24
|
+
destinationBankAccountId: movement?.destinationBankAccountId ?? '',
|
|
25
|
+
destinationBankAccountType: movement?.destinationBankAccountType ?? DEFAULT_BANK_ACCOUNT_TYPE,
|
|
26
|
+
reasoning: movement?.reasoning ?? '',
|
|
27
|
+
sourceBankAccountId: movement?.sourceBankAccountId ?? '',
|
|
28
|
+
sourceBankAccountType: movement?.sourceBankAccountType ?? DEFAULT_BANK_ACCOUNT_TYPE,
|
|
29
|
+
subMovementType: movement?.subMovementType ?? DEFAULT_SUB_MOVEMENT_TYPE,
|
|
13
30
|
version: 0,
|
|
14
31
|
};
|
|
15
32
|
};
|
|
@@ -45,7 +62,6 @@ const getCashManagementOverview = (state) => {
|
|
|
45
62
|
const totalCash = addAmounts(treasuryBalance, cashBalance);
|
|
46
63
|
return {
|
|
47
64
|
banner: (0, exports.getCashManagementOverviewBanner)(state),
|
|
48
|
-
bannerFetchState,
|
|
49
65
|
cashBalance,
|
|
50
66
|
horizonDays: cashManagementOverviewState.upcomingPaymentEvents.horizonDays,
|
|
51
67
|
outflowEvents: (0, upcomingPaymentEventSelector_1.getUpcomingPaymentEventsByIds)(state.upcomingPaymentEventState, cashManagementOverviewState.upcomingPaymentEvents.eventIds),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.81-
|
|
3
|
+
"version": "5.0.81-betaAK3",
|
|
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",
|
|
@@ -108,6 +108,7 @@
|
|
|
108
108
|
"test:typecheck": "echo 'Typechecking test files...' && NODE_OPTIONS=--max-old-space-size=4096 time tsc -p tsconfig.typecheck.json",
|
|
109
109
|
"test:typecheck-modified-files": "chmod +x ./scripts/tsc-modified-files.sh && ./scripts/tsc-modified-files.sh master tsconfig.typecheck.json",
|
|
110
110
|
"test": "pnpm lint-modified-files && pnpm test:typecheck-modified-files && vitest run --typecheck",
|
|
111
|
+
"test:full": "vitest run --typecheck",
|
|
111
112
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0 --fix",
|
|
112
113
|
"lint-modified-files": "chmod +x ./scripts/lint-modified-files.sh && ./scripts/lint-modified-files.sh",
|
|
113
114
|
"lint:fix-modified-files": "chmod +x ./scripts/lint-modified-files.sh && LINT_FIX=true ./scripts/lint-modified-files.sh",
|