@mx-cartographer/experiences 9.7.153 → 9.7.155
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/CHANGELOG.md +8 -0
- package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js +42 -42
- package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js +37 -37
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +52 -52
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js +87 -87
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer.es.js +12 -12
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesContent.es.js +18 -18
- package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesContent.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/PlaceholderActionBlock.es.js +23 -22
- package/dist/insights-v2/actionBlocks/PlaceholderActionBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js +44 -44
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/SurveyModalActionBlock.es.js +24 -24
- package/dist/insights-v2/actionBlocks/SurveyModalActionBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/useTransactionDetailsBlock.es.js +20 -20
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/useTransactionDetailsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/util.d.ts +1 -2
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/util.es.js +3 -7
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/util.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +75 -75
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +11 -11
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js +58 -58
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.d.ts +7 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.es.js +28 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSubscriptionHeader.es.js +14 -33
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSubscriptionHeader.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js +24 -41
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/useOpenedCta.d.ts +9 -0
- package/dist/insights-v2/actionBlocks/useOpenedCta.es.js +11 -0
- package/dist/insights-v2/actionBlocks/useOpenedCta.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/util.d.ts +2 -1
- package/dist/insights-v2/actionBlocks/util.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +18 -15
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.d.ts +7 -0
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.es.js +21 -11
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/components/AmountPill.d.ts +4 -2
- package/dist/insights-v2/components/AmountPill.es.js +6 -5
- package/dist/insights-v2/components/AmountPill.es.js.map +1 -1
- package/dist/insights-v2/components/MerchantHighlightCard.d.ts +6 -1
- package/dist/insights-v2/components/MerchantHighlightCard.es.js +26 -22
- package/dist/insights-v2/components/MerchantHighlightCard.es.js.map +1 -1
- package/dist/transactions/components/shared/TransactionList.d.ts +1 -1
- package/dist/transactions/components/shared/TransactionList.es.js.map +1 -1
- package/dist/transactions/components/shared/transactionlist/TransactionRow.d.ts +1 -1
- package/dist/transactions/components/shared/transactionlist/TransactionRow.es.js +49 -44
- package/dist/transactions/components/shared/transactionlist/TransactionRow.es.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [9.7.155] - 11-13-2026
|
|
2
|
+
|
|
3
|
+
- **CHANGED** - Insights 2.0 action blocks read the CTA that opened their drawer through one shared `useOpenedCta` hook in...
|
|
4
|
+
|
|
5
|
+
## [9.7.154] - 11-13-2026
|
|
6
|
+
|
|
7
|
+
- **FIXED** - Monthly Subscription Aggregate: the single subscription card matches Figma, and the Subscriptions drawer keeps each row two lines tall with the frequency on the account line (WEC-2298)
|
|
8
|
+
|
|
1
9
|
## [9.7.153] - 11-13-2026
|
|
2
10
|
|
|
3
11
|
- **FIXED** - Insights 2.0 Expense Details: the Remove button matches Figma (WEC-2316)
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useAccountStore as
|
|
3
|
-
import { getFrequencyLabel as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import { useRecurringExpensesLoadState as
|
|
9
|
-
import { RecurringTransactionBlock as
|
|
10
|
-
import { AccountDetailsBlock as
|
|
11
|
-
import
|
|
12
|
-
import { buildSummary as
|
|
13
|
-
import { useState as
|
|
14
|
-
import { observer as
|
|
15
|
-
import
|
|
16
|
-
import { Text as
|
|
17
|
-
import { Fragment as
|
|
18
|
-
var
|
|
19
|
-
const [i, l] =
|
|
20
|
-
if (!k.isInitialized) return /* @__PURE__ */ o(
|
|
21
|
-
if (!e) return /* @__PURE__ */ o(
|
|
1
|
+
import q from "../../../common/utils/AccountDisplayName.es.js";
|
|
2
|
+
import { useAccountStore as z, useAppConfig as I, useCashflowStore as H, useGlobalCopyStore as J, useGlobalStore as K, useRecurringTransactionsStore as M } from "../../../common/context/hooks.es.js";
|
|
3
|
+
import { getFrequencyLabel as P } from "../../../core/utils/RecurringTransactionsUtil.es.js";
|
|
4
|
+
import C from "../../../common/components/drawer/Drawer.es.js";
|
|
5
|
+
import _ from "../../../common/components/Loader.es.js";
|
|
6
|
+
import Q from "../../components/CategoryTile.es.js";
|
|
7
|
+
import { useOpenedCta as U } from "../useOpenedCta.es.js";
|
|
8
|
+
import { useRecurringExpensesLoadState as V } from "../RecurringTransactionBlock/useRecurringTransactionPrepare.es.js";
|
|
9
|
+
import { RecurringTransactionBlock as W } from "../RecurringTransactionBlock/RecurringTransactionBlock.es.js";
|
|
10
|
+
import { AccountDetailsBlock as X } from "../AccountDetailsBlock/AccountDetailsBlock.es.js";
|
|
11
|
+
import Y from "./AccountListContent.es.js";
|
|
12
|
+
import { buildSummary as Z, isCheckingAccount as G, resolveBeatAccounts as tt, toAccountSection as S } from "./layout.es.js";
|
|
13
|
+
import { useState as T } from "react";
|
|
14
|
+
import { observer as ot } from "mobx-react-lite";
|
|
15
|
+
import et from "@mui/material/Stack";
|
|
16
|
+
import { Text as nt } from "@mxenabled/mxui";
|
|
17
|
+
import { Fragment as it, jsx as o, jsxs as ct } from "react/jsx-runtime";
|
|
18
|
+
var kt = ot(function({ beat: n }) {
|
|
19
|
+
const [i, l] = T(null), [r, m] = T(null), { copyStore: k } = K(), { accounts: p, common: v, insights_feed: L, recurring: s } = J(), { accountsLoaded: b, cashAccounts: x, visibleAccounts: d } = z(), w = U(n), { uiStore: D } = H(), { detailedRepeatingTransactions: R } = M(), { config: B } = I(), { failed: g, ready: f, retry: E } = V(), e = L?.account_list;
|
|
20
|
+
if (!k.isInitialized) return /* @__PURE__ */ o(_, {});
|
|
21
|
+
if (!e) return /* @__PURE__ */ o(et, {
|
|
22
22
|
sx: { p: 24 },
|
|
23
|
-
children: /* @__PURE__ */ o(
|
|
23
|
+
children: /* @__PURE__ */ o(nt, { children: v?.error_message ?? "Something went wrong." })
|
|
24
24
|
});
|
|
25
|
-
if (!b) return /* @__PURE__ */ o(
|
|
26
|
-
const
|
|
27
|
-
const c = d.find(({ guid: u }) => u === t.accountGuid),
|
|
25
|
+
if (!b) return /* @__PURE__ */ o(_, {});
|
|
26
|
+
const y = tt(n, d, x), F = y.filter(G), $ = y.filter((t) => !G(t)), a = B.display_available_balance_in_accounts, N = [S("checking", e.checking, F, a), S("savings", e.savings, $, a)].filter((t) => t.rows.length > 0), O = f ? [...D.expensesTilNextIncome].sort((t, c) => c.amount - t.amount).map((t) => {
|
|
27
|
+
const c = d.find(({ guid: u }) => u === t.accountGuid), A = R.find(({ guid: u }) => u === t.repeatingTransactionGuid);
|
|
28
28
|
return {
|
|
29
29
|
account: {
|
|
30
30
|
institutionGuid: t.institutionGuid,
|
|
31
|
-
name: c ?
|
|
31
|
+
name: c ? q(c) : t.institutionName
|
|
32
32
|
},
|
|
33
33
|
amount: t.amount,
|
|
34
|
-
frequency:
|
|
34
|
+
frequency: A && P(s, A, !1),
|
|
35
35
|
key: `${t.repeatingTransactionGuid}-${t.expectedDate.getTime()}`,
|
|
36
|
-
leading: /* @__PURE__ */ o(
|
|
36
|
+
leading: /* @__PURE__ */ o(Q, {
|
|
37
37
|
categoryGuid: t.categoryGuid,
|
|
38
38
|
size: 32
|
|
39
39
|
}),
|
|
40
40
|
name: t.name,
|
|
41
41
|
onClick: () => l(t)
|
|
42
42
|
};
|
|
43
|
-
}) : [],
|
|
44
|
-
return /* @__PURE__ */
|
|
45
|
-
/* @__PURE__ */ o(
|
|
43
|
+
}) : [], h = () => l(null), j = () => m(null);
|
|
44
|
+
return /* @__PURE__ */ ct(it, { children: [
|
|
45
|
+
/* @__PURE__ */ o(Y, {
|
|
46
46
|
copy: e,
|
|
47
|
-
expenses:
|
|
47
|
+
expenses: O,
|
|
48
48
|
expensesLoading: !f && !g,
|
|
49
49
|
onAccountClick: m,
|
|
50
50
|
onRetryExpenses: g ? E : void 0,
|
|
51
|
-
sections:
|
|
51
|
+
sections: N,
|
|
52
52
|
showAvailable: a,
|
|
53
|
-
summary:
|
|
53
|
+
summary: Z(w, e)
|
|
54
54
|
}),
|
|
55
|
-
/* @__PURE__ */ o(
|
|
55
|
+
/* @__PURE__ */ o(C, {
|
|
56
56
|
ariaLabelClose: s.close_drawer_aria,
|
|
57
57
|
isOpen: i !== null,
|
|
58
|
-
onClose:
|
|
58
|
+
onClose: h,
|
|
59
59
|
title: s.expense_details,
|
|
60
|
-
children: i && /* @__PURE__ */ o(
|
|
60
|
+
children: i && /* @__PURE__ */ o(W, {
|
|
61
61
|
beat: n,
|
|
62
62
|
layout: "insights",
|
|
63
|
-
onDeleted:
|
|
63
|
+
onDeleted: h,
|
|
64
64
|
repeatingTransactionGuid: i.repeatingTransactionGuid,
|
|
65
65
|
selectedRecurrence: i
|
|
66
66
|
})
|
|
67
67
|
}),
|
|
68
|
-
/* @__PURE__ */ o(
|
|
68
|
+
/* @__PURE__ */ o(C, {
|
|
69
69
|
ariaLabelClose: p?.close_account_details_aria,
|
|
70
70
|
isOpen: r !== null,
|
|
71
|
-
onClose:
|
|
71
|
+
onClose: j,
|
|
72
72
|
title: p?.account_details,
|
|
73
|
-
children: r && /* @__PURE__ */ o(
|
|
73
|
+
children: r && /* @__PURE__ */ o(X, { beat: {
|
|
74
74
|
...n,
|
|
75
75
|
primary_account: void 0,
|
|
76
76
|
primary_account_guid: r
|
|
@@ -79,7 +79,7 @@ var Dt = rt(function({ beat: n }) {
|
|
|
79
79
|
] });
|
|
80
80
|
});
|
|
81
81
|
export {
|
|
82
|
-
|
|
82
|
+
kt as AccountListBlock
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
//# sourceMappingURL=AccountListBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountListBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.tsx"],"sourcesContent":["import { useState } from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Drawer,\n Loader,\n useAccountStore,\n useAppConfig,\n useCashflowStore,\n useGlobalCopyStore,\n useGlobalStore,\n
|
|
1
|
+
{"version":3,"file":"AccountListBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.tsx"],"sourcesContent":["import { useState } from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Drawer,\n Loader,\n useAccountStore,\n useAppConfig,\n useCashflowStore,\n useGlobalCopyStore,\n useGlobalStore,\n useRecurringTransactionsStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport type { Recurrence } from '../../../core'\nimport { getFrequencyLabel } from '../../../core/utils/RecurringTransactionsUtil'\nimport CategoryTile from '../../components/CategoryTile'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { AccountDetailsBlock } from '../AccountDetailsBlock'\nimport {\n RecurringTransactionBlock,\n useRecurringExpensesLoadState,\n} from '../RecurringTransactionBlock'\nimport { useOpenedCta } from '../useOpenedCta'\n\nimport AccountListContent, { type ExpenseRow } from './AccountListContent'\nimport { buildSummary, isCheckingAccount, resolveBeatAccounts, toAccountSection } from './layout'\n\n/**\n * Account List drawer: the CTA's calculation, then Accounts and Recurring Expenses tabs.\n * A tapped expense opens its Expense Details, and a tapped account its Account Details (the shared\n * AccountDetailsBlock), each in a nested drawer.\n */\nexport const AccountListBlock = observer(function AccountListBlock({ beat }: ActionBlockProps) {\n const [tappedExpense, setTappedExpense] = useState<Recurrence | null>(null)\n const [tappedAccountGuid, setTappedAccountGuid] = useState<string | null>(null)\n const { copyStore } = useGlobalStore()\n const {\n accounts: accountsCopy,\n common: commonCopy,\n insights_feed: insightsFeedCopy,\n recurring: recurringCopy,\n } = useGlobalCopyStore()\n const { accountsLoaded, cashAccounts, visibleAccounts } = useAccountStore()\n const cta = useOpenedCta(beat)\n const { uiStore } = useCashflowStore()\n const { detailedRepeatingTransactions } = useRecurringTransactionsStore()\n const { config } = useAppConfig()\n const { failed: expensesFailed, ready: expensesReady, retry } = useRecurringExpensesLoadState()\n const copy = insightsFeedCopy?.account_list\n\n if (!copyStore.isInitialized) return <Loader />\n\n // Copy loads once at app start, so a retry cannot clear a missing namespace: a plain message.\n if (!copy) {\n return (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy?.error_message ?? 'Something went wrong.'}</Text>\n </Stack>\n )\n }\n\n if (!accountsLoaded) return <Loader />\n\n const listed = resolveBeatAccounts(beat, visibleAccounts, cashAccounts)\n const checking = listed.filter(isCheckingAccount)\n const savings = listed.filter((account) => !isCheckingAccount(account))\n const showAvailable = config.display_available_balance_in_accounts\n const sections = [\n toAccountSection('checking', copy.checking, checking, showAvailable),\n toAccountSection('savings', copy.savings, savings, showAvailable),\n ].filter((section) => section.rows.length > 0)\n\n // Every upcoming expense as its own row, largest first (Figma); no \"Other\" fold, so each opens its details.\n const expenses: ExpenseRow[] = expensesReady\n ? [...uiStore.expensesTilNextIncome]\n .sort((a, b) => b.amount - a.amount)\n .map((expense) => {\n const account = visibleAccounts.find(({ guid }) => guid === expense.accountGuid)\n const repeating = detailedRepeatingTransactions.find(\n ({ guid }) => guid === expense.repeatingTransactionGuid,\n )\n\n return {\n account: {\n institutionGuid: expense.institutionGuid,\n name: account ? getAccountDisplayName(account) : expense.institutionName,\n },\n amount: expense.amount,\n frequency: repeating && getFrequencyLabel(recurringCopy, repeating, false),\n key: `${expense.repeatingTransactionGuid}-${expense.expectedDate.getTime()}`,\n leading: <CategoryTile categoryGuid={expense.categoryGuid} size={32} />,\n name: expense.name,\n onClick: () => setTappedExpense(expense),\n }\n })\n : []\n\n const closeExpenseDetails = () => setTappedExpense(null)\n const closeAccountDetails = () => setTappedAccountGuid(null)\n\n return (\n <>\n <AccountListContent\n copy={copy}\n expenses={expenses}\n expensesLoading={!expensesReady && !expensesFailed}\n onAccountClick={setTappedAccountGuid}\n onRetryExpenses={expensesFailed ? retry : undefined}\n sections={sections}\n showAvailable={showAvailable}\n summary={buildSummary(cta, copy)}\n />\n <Drawer\n ariaLabelClose={recurringCopy.close_drawer_aria}\n isOpen={tappedExpense !== null}\n onClose={closeExpenseDetails}\n title={recurringCopy.expense_details}\n >\n {tappedExpense && (\n <RecurringTransactionBlock\n beat={beat}\n layout=\"insights\"\n onDeleted={closeExpenseDetails}\n repeatingTransactionGuid={tappedExpense.repeatingTransactionGuid}\n selectedRecurrence={tappedExpense}\n />\n )}\n </Drawer>\n <Drawer\n ariaLabelClose={accountsCopy?.close_account_details_aria}\n isOpen={tappedAccountGuid !== null}\n onClose={closeAccountDetails}\n title={accountsCopy?.account_details}\n >\n {tappedAccountGuid && (\n // The shared block shows the beat's account, so hand it the tapped one instead.\n <AccountDetailsBlock\n beat={{ ...beat, primary_account: undefined, primary_account_guid: tappedAccountGuid }}\n />\n )}\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AAqC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AA;AAAA,QACN,QAAO;AAAA,QACP,WAAW;AAAA,QACX,0BAA0B,EAAc;AAAA,QACxC,oBAAoB;AAAA,MACrB,CAAA;AAAA,IAEG,CAAA;AAAA,IACR,gBAAA,EAAC,GAAD;AAAA,MACE,gBAAgB,GAAc;AAAA,MAC9B,QAAQ,MAAsB;AAAA,MAC9B,SAAS;AAAA,MACT,OAAO,GAAc;AAAA,MAEpB,UAAA,KAEC,gBAAA,EAAC,GAAD,EACE,MAAM;AAAA,QAAE,GAAG;AAAA,QAAM,iBAAiB;AAAA,QAAW,sBAAsB;AAAA,MAAkB,EACtF,CAAA;AAAA,IAEG,CAAA;AAAA,EACR,EAAA,CAAA;AAEN,CAAC"}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { useGlobalCopyStore as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { hasDrawerBlock as
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import { actionBlocks as
|
|
8
|
-
import { useRef as
|
|
9
|
-
import { observer as
|
|
10
|
-
import
|
|
11
|
-
import { Text as
|
|
12
|
-
import { Fragment as
|
|
13
|
-
var
|
|
14
|
-
const r =
|
|
1
|
+
import { useGlobalCopyStore as A, useGlobalUiStore as B, useInsightsV2Store as S } from "../../common/context/hooks.es.js";
|
|
2
|
+
import b from "../../common/components/drawer/Drawer.es.js";
|
|
3
|
+
import w from "../../common/components/Loader.es.js";
|
|
4
|
+
import { hasDrawerBlock as L } from "../mappings/hasDrawerBlock.es.js";
|
|
5
|
+
import x from "../components/shared/StatusSnackbar.es.js";
|
|
6
|
+
import { useOpenedCta as D } from "./useOpenedCta.es.js";
|
|
7
|
+
import { actionBlocks as _ } from "../mappings/blocks.es.js";
|
|
8
|
+
import { useRef as O } from "react";
|
|
9
|
+
import { observer as T } from "mobx-react-lite";
|
|
10
|
+
import j from "@mui/material/Stack";
|
|
11
|
+
import { Text as F } from "@mxenabled/mxui";
|
|
12
|
+
import { Fragment as p, jsx as e, jsxs as d } from "react/jsx-runtime";
|
|
13
|
+
var G = (c, o) => {
|
|
14
|
+
const r = O(void 0);
|
|
15
15
|
return c ? (r.current ??= o, r.current) : (r.current = void 0, o);
|
|
16
16
|
}, f = ({ actionBlock: c, ...o }) => {
|
|
17
17
|
const { Component: r, usePrepare: i } = c;
|
|
18
18
|
return i(o), /* @__PURE__ */ e(r, { ...o });
|
|
19
|
-
},
|
|
20
|
-
const r =
|
|
19
|
+
}, M = T(function({ beat: o }) {
|
|
20
|
+
const r = A(), i = r.common, { isCopyLoaded: k } = B(), { actionDrawer: m, actionNotice: g, closeActionDrawer: h, setActionNotice: v } = S(), s = m.isDrawerOpen && m.guid === o.guid, n = G(s, D(o));
|
|
21
21
|
if (!o.insights_payload) return null;
|
|
22
|
-
if (!
|
|
23
|
-
const
|
|
22
|
+
if (!k) return s ? /* @__PURE__ */ e(w, {}) : null;
|
|
23
|
+
const a = g[o.guid], u = /* @__PURE__ */ e(x, {
|
|
24
24
|
closeAriaLabel: i.close_aria,
|
|
25
|
-
message:
|
|
26
|
-
onClose: () =>
|
|
27
|
-
open: !!
|
|
28
|
-
severity:
|
|
29
|
-
}),
|
|
30
|
-
if (
|
|
31
|
-
actionBlock:
|
|
25
|
+
message: a?.message ?? "",
|
|
26
|
+
onClose: () => v(o.guid, void 0),
|
|
27
|
+
open: !!a,
|
|
28
|
+
severity: a?.severity
|
|
29
|
+
}), l = L(n?.block), t = l ? _[n?.block] : void 0;
|
|
30
|
+
if (t?.presentation === "modal") return /* @__PURE__ */ d(p, { children: [s && /* @__PURE__ */ e(f, {
|
|
31
|
+
actionBlock: t,
|
|
32
32
|
beat: o
|
|
33
|
-
},
|
|
34
|
-
const
|
|
35
|
-
return /* @__PURE__ */
|
|
33
|
+
}, n?.block), u] });
|
|
34
|
+
const C = t?.title?.(n?.variant, r, o), y = t ? C || n?.label || "" : l ? i.error_heading : n?.label ?? "";
|
|
35
|
+
return /* @__PURE__ */ d(p, { children: [/* @__PURE__ */ e(b, {
|
|
36
36
|
ariaLabelClose: i.close_aria,
|
|
37
|
-
headerAction:
|
|
37
|
+
headerAction: t?.headerAction,
|
|
38
38
|
isOpen: s,
|
|
39
|
-
onClose:
|
|
40
|
-
title:
|
|
41
|
-
children:
|
|
42
|
-
actionBlock:
|
|
39
|
+
onClose: h,
|
|
40
|
+
title: y,
|
|
41
|
+
children: t ? /* @__PURE__ */ e(f, {
|
|
42
|
+
actionBlock: t,
|
|
43
43
|
beat: o
|
|
44
|
-
},
|
|
44
|
+
}, n?.block) : l ? /* @__PURE__ */ e(j, {
|
|
45
45
|
sx: { p: 24 },
|
|
46
|
-
children: /* @__PURE__ */ e(
|
|
46
|
+
children: /* @__PURE__ */ e(F, { children: i.error_message })
|
|
47
47
|
}) : null
|
|
48
|
-
}),
|
|
48
|
+
}), u] });
|
|
49
49
|
});
|
|
50
50
|
export {
|
|
51
|
-
|
|
51
|
+
M as ActionBlockLayer
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
//# sourceMappingURL=ActionBlockLayer.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBlockLayer.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/ActionBlockLayer.tsx"],"sourcesContent":["import { useRef } from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Drawer,\n Loader,\n useGlobalCopyStore,\n useGlobalUiStore,\n useInsightsV2Store,\n} from '../../common'\nimport {
|
|
1
|
+
{"version":3,"file":"ActionBlockLayer.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/ActionBlockLayer.tsx"],"sourcesContent":["import { useRef } from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Drawer,\n Loader,\n useGlobalCopyStore,\n useGlobalUiStore,\n useInsightsV2Store,\n} from '../../common'\nimport type { Beat } from '../../core'\nimport {\n actionBlocks,\n hasDrawerBlock,\n type ActionBlockEntry,\n type ActionBlockProps,\n} from '../mappings/blocks'\nimport StatusSnackbar from '../components/shared/StatusSnackbar'\nimport { useOpenedCta } from './useOpenedCta'\nimport type { OpenedCta } from './util'\n\ninterface ActionBlockLayerProps {\n beat: Beat\n}\n\n/** Keeps the CTA the user pressed for the open session: a refreshed beat may name another CTA there. */\nconst useSessionCta = (isOpen: boolean, resolved: OpenedCta): OpenedCta => {\n const pinned = useRef<OpenedCta>(undefined)\n\n if (!isOpen) {\n pinned.current = undefined\n return resolved\n }\n pinned.current ??= resolved\n\n return pinned.current\n}\n\n/**\n * Renders a registered action block. Callers MUST key this per block name — a\n * block with `usePrepare` and one without run a different number of hooks, so\n * reusing the same fiber across a block switch violates the rules of hooks.\n */\nconst ActionBlockRunner = ({\n actionBlock,\n ...blockProps\n}: ActionBlockProps & { actionBlock: ActionBlockEntry }) => {\n const { Component, usePrepare } = actionBlock\n\n usePrepare(blockProps)\n\n return <Component {...blockProps} />\n}\n\n// `observer` is required: this reads `isCopyLoaded` off GlobalUiStore and the\n// action drawer off InsightsV2Store. Without it the component never re-renders\n// and stays stuck on <Loader /> forever.\nexport const ActionBlockLayer = observer(function ActionBlockLayer({\n beat,\n}: ActionBlockLayerProps) {\n const copy = useGlobalCopyStore()\n const commonCopy = copy.common\n const { isCopyLoaded } = useGlobalUiStore()\n const { actionDrawer, actionNotice, closeActionDrawer, setActionNotice } = useInsightsV2Store()\n\n // Every card in the feed renders its own layer against the shared store, so\n // this card's drawer only opens when its beat is the one that triggered it.\n const isCurrentBeatOpen = actionDrawer.isDrawerOpen && actionDrawer.guid === beat.guid\n\n const currentCta = useSessionCta(isCurrentBeatOpen, useOpenedCta(beat))\n\n // Mirrors BaseLayout's guard — the layer is exported, so callers are not\n // guaranteed to have narrowed this already.\n if (!beat.insights_payload) return null\n\n if (!isCopyLoaded) return isCurrentBeatOpen ? <Loader /> : null\n\n // A block that closes its own drawer hands its message here, so it shows after the unmount.\n const notice = actionNotice[beat.guid]\n const noticeSnackbar = (\n <StatusSnackbar\n closeAriaLabel={commonCopy.close_aria}\n message={notice?.message ?? ''}\n onClose={() => setActionNotice(beat.guid, undefined)}\n open={Boolean(notice)}\n severity={notice?.severity}\n />\n )\n\n // A CTA without a real block never opens a drawer (BaseLayout won't trigger it);\n // a real-but-unknown block shows the error (\"oops\") content.\n const blockValid = hasDrawerBlock(currentCta?.block)\n const actionBlock = blockValid\n ? actionBlocks[currentCta?.block as keyof typeof actionBlocks]\n : undefined\n\n // A modal block owns its dialog: no drawer behind it, and nothing mounted until it is opened.\n if (actionBlock?.presentation === 'modal') {\n return (\n <>\n {isCurrentBeatOpen && (\n <ActionBlockRunner actionBlock={actionBlock} beat={beat} key={currentCta?.block} />\n )}\n {noticeSnackbar}\n </>\n )\n }\n\n const resolvedTitle = actionBlock?.title?.(currentCta?.variant, copy, beat)\n const drawerTitle = actionBlock\n ? resolvedTitle || currentCta?.label || ''\n : blockValid\n ? commonCopy.error_heading\n : (currentCta?.label ?? '')\n\n return (\n <>\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n headerAction={actionBlock?.headerAction}\n isOpen={isCurrentBeatOpen}\n onClose={closeActionDrawer}\n title={drawerTitle}\n >\n {actionBlock ? (\n <ActionBlockRunner actionBlock={actionBlock} beat={beat} key={currentCta?.block} />\n ) : blockValid ? (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy.error_message}</Text>\n </Stack>\n ) : null}\n </Drawer>\n {noticeSnackbar}\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;AA8BA,IAAM,IAAA,CAAiB,GAAiB,MAAmC;AACzE,QAAM,IAAS,EAAkB,MAAS;AAE1C,SAAK,KAIL,EAAO,YAAY,GAEZ,EAAO,YALZ,EAAO,UAAU,QACV;AAKX,GAOM,IAAA,CAAqB,EACzB,aAAA,GACA,GAAG,EAAA,MACuD;AAC1D,QAAM,EAAE,WAAA,GAAW,YAAA,EAAA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EAAW;AAAA,IAC3B,cAAc,GAAa;AAAA,IAC3B,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,OAAO;AAAA,IAEN,UAAA,IACC,gBAAA,EAAC,GAAD;AAAA,MAAgC,aAAA;AAAA,MAAmB,MAAA;AAAA,IAA+B,GAApB,GAAY,KAAQ,IAChF,IACF,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI,EAAE,GAAG,GAAG;AAAA,MACjB,UAAA,gBAAA,EAAC,GAAD,EAAA,UAAO,EAAW,cAAoB,CAAA;AAAA,IACjC,CAAA,IACL;AAAA,EACE,CAAA,GACP,CACD,EAAA,CAAA;AAEN,CAAC"}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { buildDynamicCopy as j } from "../../../core/utils/Localization.es.js";
|
|
2
2
|
import z from "../../../common/utils/AccountDisplayName.es.js";
|
|
3
|
-
import { useCategoryStore as q, useGlobalCopyStore as
|
|
3
|
+
import { useCategoryStore as q, useGlobalCopyStore as w, useInsightsV2Store as P, useSettingsStore as J, useUserStore as K } from "../../../common/context/hooks.es.js";
|
|
4
4
|
import B from "../../../common/components/Loader.es.js";
|
|
5
5
|
import Q from "../../../common/components/CurrencyDialog.es.js";
|
|
6
6
|
import { useBeatActions as X } from "../../beatActions.es.js";
|
|
7
7
|
import { ANALYTICS_EVENTS_CONFIG as d } from "../../analytics/analyticsEventsConfig.es.js";
|
|
8
8
|
import { useCtaHandler as Z } from "../../ctaActions/useCtaAction.es.js";
|
|
9
9
|
import { useAnalyticsEvent as oo } from "../../analytics/useAnalyticsEvent.es.js";
|
|
10
|
-
import {
|
|
10
|
+
import { useOpenedCta as eo } from "../useOpenedCta.es.js";
|
|
11
11
|
import { CreateBudgetDialog as to } from "./CreateBudgetDialog.es.js";
|
|
12
12
|
import { AMOUNT_INPUT_VARIANTS as io, CREATE_BUDGET_VARIANT as no, findLowBalanceProfile as ro, isAmountInputVariant as x, isWholeAmount as ao, resolveAmountInputVariant as so, toInputValue as co } from "./layout.es.js";
|
|
13
|
-
import
|
|
13
|
+
import r from "react";
|
|
14
14
|
import { observer as V } from "mobx-react-lite";
|
|
15
15
|
import k from "@mui/material/Stack";
|
|
16
|
-
import { H3 as lo, InstitutionLogo as uo, Text as
|
|
16
|
+
import { H3 as lo, InstitutionLogo as uo, Text as H } from "@mxenabled/mxui";
|
|
17
17
|
import { Icon as mo } from "@mxenabled/mx-icons";
|
|
18
18
|
import { jsx as o, jsxs as O } from "react/jsx-runtime";
|
|
19
19
|
import po from "@mui/material/Dialog";
|
|
20
|
-
import
|
|
21
|
-
var
|
|
22
|
-
const
|
|
20
|
+
import fo from "@mui/material/IconButton";
|
|
21
|
+
var S = ({ children: g, closeAriaLabel: i, heading: n, onClose: e }) => {
|
|
22
|
+
const a = r.useId();
|
|
23
23
|
return /* @__PURE__ */ o(po, {
|
|
24
|
-
"aria-labelledby": n ?
|
|
24
|
+
"aria-labelledby": n ? a : void 0,
|
|
25
25
|
maxWidth: "xs",
|
|
26
26
|
onClose: e,
|
|
27
27
|
open: !0,
|
|
@@ -33,10 +33,10 @@ var E = ({ children: y, closeAriaLabel: i, heading: n, onClose: e }) => {
|
|
|
33
33
|
},
|
|
34
34
|
children: [
|
|
35
35
|
n && /* @__PURE__ */ o(lo, {
|
|
36
|
-
id:
|
|
36
|
+
id: a,
|
|
37
37
|
children: n
|
|
38
38
|
}),
|
|
39
|
-
/* @__PURE__ */ o(
|
|
39
|
+
/* @__PURE__ */ o(fo, {
|
|
40
40
|
"aria-label": i || "Close",
|
|
41
41
|
onClick: e,
|
|
42
42
|
sx: {
|
|
@@ -49,74 +49,74 @@ var E = ({ children: y, closeAriaLabel: i, heading: n, onClose: e }) => {
|
|
|
49
49
|
sx: { color: "action.active" }
|
|
50
50
|
})
|
|
51
51
|
}),
|
|
52
|
-
|
|
52
|
+
g
|
|
53
53
|
]
|
|
54
54
|
})
|
|
55
55
|
});
|
|
56
56
|
}, ko = V(function({ beat: i }) {
|
|
57
|
-
const { common: n } =
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
}, [
|
|
57
|
+
const { common: n } = w(), { closeActionDrawer: e } = P(), a = q(), l = eo(i), [u] = r.useState(() => so(l)), m = u === no;
|
|
58
|
+
return r.useEffect(() => {
|
|
59
|
+
m && !a.categoriesLoaded && a.loadCategories();
|
|
60
|
+
}, [a, m]), m ? a.categoriesLoaded ? /* @__PURE__ */ o(to, { beat: i }) : /* @__PURE__ */ o(S, {
|
|
61
61
|
closeAriaLabel: n?.close_aria,
|
|
62
|
-
onClose:
|
|
62
|
+
onClose: e,
|
|
63
63
|
children: /* @__PURE__ */ o(B, {})
|
|
64
|
-
}) : /* @__PURE__ */ o(
|
|
64
|
+
}) : /* @__PURE__ */ o(_o, {
|
|
65
65
|
beat: i,
|
|
66
|
-
variant:
|
|
66
|
+
variant: u
|
|
67
67
|
});
|
|
68
|
-
}),
|
|
69
|
-
const { common: e, insights_feed:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}), []),
|
|
68
|
+
}), _o = V(function({ beat: i, variant: n }) {
|
|
69
|
+
const { common: e, insights_feed: a } = w(), { closeActionDrawer: l } = P(), u = J(), { userInsightProfile: m } = K(), A = Z(i, X()), E = oo(), c = a?.amount_input_modal, t = n === io.LOW_BALANCE_THRESHOLD, h = t ? ro(u.notificationProfiles, i.primary_account_guid) : void 0, T = t ? h?.threshold : m?.savings_opportunity_minimum_checking_account_balance, [R, G] = r.useState(t), p = r.useRef(!0);
|
|
70
|
+
r.useEffect(() => (p.current = !0, () => {
|
|
71
|
+
p.current = !1;
|
|
72
|
+
}), []), r.useEffect(() => {
|
|
73
73
|
t && u.loadNotificationProfiles().finally(() => {
|
|
74
|
-
|
|
74
|
+
p.current && G(!1);
|
|
75
75
|
});
|
|
76
76
|
}, [t, u]);
|
|
77
|
-
const [F, M] =
|
|
78
|
-
if (R) return /* @__PURE__ */ o(
|
|
77
|
+
const [F, M] = r.useState(null), [C, v] = r.useState(!1), [U, y] = r.useState(!1), f = F ?? co(T);
|
|
78
|
+
if (R) return /* @__PURE__ */ o(S, {
|
|
79
79
|
closeAriaLabel: e?.close_aria,
|
|
80
|
-
onClose:
|
|
80
|
+
onClose: l,
|
|
81
81
|
children: /* @__PURE__ */ o(B, {})
|
|
82
82
|
});
|
|
83
|
-
const
|
|
84
|
-
if (!
|
|
85
|
-
return console.warn(`amount_input_modal_block: ${
|
|
83
|
+
const s = x(n) ? c?.[n] : void 0, D = !!s?.title && !!s.description && !!s.input_label && !!c?.whole_number_error && !!c.save_error && !!e?.save_button && (!t || !!e.cancel_button) && !!e.close_aria;
|
|
84
|
+
if (!c || !s || !D || !(t ? h : m))
|
|
85
|
+
return console.warn(`amount_input_modal_block: ${c ? x(n) ? D ? t ? "no low-balance profile for the account" : "user insight profile not set by the host" : `copy incomplete for "${n}"` : `unknown variant "${n}"` : "copy namespace missing"}`), /* @__PURE__ */ o(S, {
|
|
86
86
|
closeAriaLabel: e?.close_aria,
|
|
87
87
|
heading: e?.error_heading,
|
|
88
|
-
onClose:
|
|
89
|
-
children: /* @__PURE__ */ o(
|
|
88
|
+
onClose: l,
|
|
89
|
+
children: /* @__PURE__ */ o(H, { children: e?.error_message })
|
|
90
90
|
});
|
|
91
91
|
const L = () => {
|
|
92
|
-
|
|
93
|
-
}, b = !t && !!T, N = i.primary_account ? z(i.primary_account) : "",
|
|
94
|
-
if (!
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
const Y = t ? await
|
|
98
|
-
profileGuid:
|
|
99
|
-
threshold:
|
|
100
|
-
}, { analytics: d.EDIT_INSIGHT_THRESHOLD_SAVE }) : await
|
|
101
|
-
|
|
92
|
+
E(t ? d.EDIT_INSIGHT_THRESHOLD_CANCELED : d.EDIT_SAFETY_NET_CANCEL), l();
|
|
93
|
+
}, b = !t && !!T, N = i.primary_account ? z(i.primary_account) : "", I = ao(f), $ = f !== "" && !I, W = async () => {
|
|
94
|
+
if (!I || C) return;
|
|
95
|
+
const _ = Number(f);
|
|
96
|
+
v(!0), y(!1);
|
|
97
|
+
const Y = t ? await A("updateNotificationProfileThreshold", {
|
|
98
|
+
profileGuid: h?.guid,
|
|
99
|
+
threshold: _
|
|
100
|
+
}, { analytics: d.EDIT_INSIGHT_THRESHOLD_SAVE }) : await A("updateUserInsightProfile", { fields: { savings_opportunity_minimum_checking_account_balance: _ } }, { analytics: d.EDIT_SAFETY_NET_SAVE });
|
|
101
|
+
p.current && (v(!1), Y ? l() : y(!0));
|
|
102
102
|
};
|
|
103
103
|
return /* @__PURE__ */ o(Q, {
|
|
104
104
|
closeAriaLabel: e.close_aria,
|
|
105
|
-
content: j(b &&
|
|
106
|
-
errorText: $ ?
|
|
107
|
-
handleInputChange: (
|
|
108
|
-
M(
|
|
105
|
+
content: j(b && s.description_edit || s.description, /* @__PURE__ */ o("strong", { children: N }, "account")),
|
|
106
|
+
errorText: $ ? c.whole_number_error : U ? c.save_error : void 0,
|
|
107
|
+
handleInputChange: (_) => {
|
|
108
|
+
M(_), y(!1);
|
|
109
109
|
},
|
|
110
|
-
handleInputClick: t ? () =>
|
|
110
|
+
handleInputClick: t ? () => E(d.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED) : void 0,
|
|
111
111
|
handleModalClose: L,
|
|
112
112
|
handlePrimaryAction: () => {
|
|
113
113
|
W();
|
|
114
114
|
},
|
|
115
115
|
handleSecondaryAction: L,
|
|
116
|
-
inputLabel:
|
|
117
|
-
inputValue:
|
|
116
|
+
inputLabel: s.input_label,
|
|
117
|
+
inputValue: f,
|
|
118
118
|
isOpen: !0,
|
|
119
|
-
isPrimaryDisabled:
|
|
119
|
+
isPrimaryDisabled: C || !I,
|
|
120
120
|
primaryText: e.save_button,
|
|
121
121
|
secondaryText: t ? e.cancel_button : void 0,
|
|
122
122
|
subtitle: t && i.primary_account ? /* @__PURE__ */ O(k, {
|
|
@@ -129,14 +129,14 @@ var E = ({ children: y, closeAriaLabel: i, heading: n, onClose: e }) => {
|
|
|
129
129
|
alt: "",
|
|
130
130
|
institutionGuid: i.primary_account.institution_guid ?? "",
|
|
131
131
|
size: 16
|
|
132
|
-
}), /* @__PURE__ */ o(
|
|
132
|
+
}), /* @__PURE__ */ o(H, {
|
|
133
133
|
color: "text.secondary",
|
|
134
134
|
uppercase: !0,
|
|
135
135
|
variant: "body2",
|
|
136
136
|
children: N
|
|
137
137
|
})]
|
|
138
138
|
}) : void 0,
|
|
139
|
-
title: b &&
|
|
139
|
+
title: b && s.title_edit || s.title
|
|
140
140
|
});
|
|
141
141
|
});
|
|
142
142
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmountInputModalBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport MuiDialog from '@mui/material/Dialog'\nimport IconButton from '@mui/material/IconButton'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n Loader,\n buildDynamicCopy,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n useSettingsStore,\n useUserStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\nimport { CreateBudgetDialog } from './CreateBudgetDialog'\nimport {\n AMOUNT_INPUT_VARIANTS,\n CREATE_BUDGET_VARIANT,\n findLowBalanceProfile,\n isAmountInputVariant,\n isWholeAmount,\n resolveAmountInputVariant,\n toInputValue,\n} from './layout'\n\n/** Dialog frame for the formless states: loading and a non-retriable problem. */\nconst StatusDialog = ({\n children,\n closeAriaLabel,\n heading,\n onClose,\n}: React.PropsWithChildren<{ closeAriaLabel?: string; heading?: string; onClose: () => void }>) => {\n const headingId = React.useId()\n\n return (\n <MuiDialog\n aria-labelledby={heading ? headingId : undefined}\n maxWidth=\"xs\"\n onClose={onClose}\n open={true}\n >\n <Stack sx={{ gap: 12, p: 24, position: 'relative' }}>\n {heading && <H3 id={headingId}>{heading}</H3>}\n <IconButton\n aria-label={closeAriaLabel || 'Close'}\n onClick={onClose}\n sx={{ position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n {children}\n </Stack>\n </MuiDialog>\n )\n}\n\n/** `amount_input_modal_block`: one whole-dollar amount in a modal, picked by the CTA variant. */\nexport const AmountInputModalBlock = observer(function AmountInputModalBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy } = useGlobalCopyStore()\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n const categoryStore = useCategoryStore()\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n // Read once on open: a refreshed beat must not swap the dialog under its snackbar.\n const [variant] = React.useState(() =>\n resolveAmountInputVariant(\n getDynamicCtaBasedOnTriggers(actionDrawer, primary_cta, secondary_cta, in_description_cta),\n ),\n )\n const isCreateBudget = variant === CREATE_BUDGET_VARIANT\n\n // The create dialog names the category, so it waits for the category store.\n React.useEffect(() => {\n if (isCreateBudget && !categoryStore.categoriesLoaded) void categoryStore.loadCategories()\n }, [categoryStore, isCreateBudget])\n\n if (!isCreateBudget) return <AmountSettingDialog beat={beat} variant={variant} />\n\n return categoryStore.categoriesLoaded ? (\n <CreateBudgetDialog beat={beat} />\n ) : (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n})\n\n/** The low-balance threshold and safety-net settings (the two `AMOUNT_INPUT_VARIANTS`). */\nconst AmountSettingDialog = observer(function AmountSettingDialog({\n beat,\n variant,\n}: ActionBlockProps & { variant?: string }) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const settingsStore = useSettingsStore()\n const { userInsightProfile } = useUserStore()\n const runHandler = useCtaHandler(beat, useBeatActions())\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const copy = insightsFeedCopy?.amount_input_modal\n const isLowBalance = variant === AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD\n\n const lowBalanceProfile = isLowBalance\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined\n const savedAmount = isLowBalance\n ? lowBalanceProfile?.threshold\n : userInsightProfile?.savings_opportunity_minimum_checking_account_balance\n\n // Mounting is the open, so profiles reload here and the threshold prefills as saved now.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(isLowBalance)\n // False once unmounted: a save that resolves after the user closed the dialog must not close\n // (or update) whatever action session is open by then.\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n React.useEffect(() => {\n if (!isLowBalance) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [isLowBalance, settingsStore])\n\n // `null` until the user types: the field shows the saved amount until then.\n const [typed, setTyped] = React.useState<string | null>(null)\n const [isSaving, setIsSaving] = React.useState(false)\n const [saveFailed, setSaveFailed] = React.useState(false)\n\n const value = typed ?? toInputValue(savedAmount)\n\n if (isLoadingProfiles) {\n return (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n }\n\n // Copy ships separately (see the doc's Rollout order), so check every string the form renders:\n // a partial ship falls to the error dialog instead of throwing mid-render.\n const variantCopy = isAmountInputVariant(variant) ? copy?.[variant] : undefined\n const hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!copy?.whole_number_error &&\n !!copy.save_error &&\n !!commonCopy?.save_button &&\n // Cancel renders for the low-balance variant only.\n (!isLowBalance || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = isLowBalance ? !!lowBalanceProfile : !!userInsightProfile\n\n if (!copy || !variantCopy || !hasCopy || !hasProfile) {\n // One message to the user; distinct warnings so a rollout problem can be traced to its cause.\n console.warn(\n `amount_input_modal_block: ${\n !copy\n ? 'copy namespace missing'\n : !isAmountInputVariant(variant)\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : isLowBalance\n ? 'no low-balance profile for the account'\n : 'user insight profile not set by the host'\n }`,\n )\n\n return (\n <StatusDialog\n closeAriaLabel={commonCopy?.close_aria}\n heading={commonCopy?.error_heading}\n onClose={closeActionDrawer}\n >\n <Text>{commonCopy?.error_message}</Text>\n </StatusDialog>\n )\n }\n\n // Trigger 4 — user dismissed without saving (close icon, Cancel button, backdrop). Pulse\n // parity: EditThreshold.js close button / EditSafetyNet.js cancel button.\n const handleDismiss = () => {\n fireAnalyticsEvent(\n isLowBalance\n ? ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED\n : ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n )\n closeActionDrawer()\n }\n\n const isEdit = !isLowBalance && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = isWholeAmount(value)\n const isInvalid = value !== '' && !isValid\n\n const handleSave = async () => {\n // Guarded here too, not only by the disabled button: Enter submits the dialog's form directly.\n if (!isValid || isSaving) return\n\n const amount = Number(value)\n\n setIsSaving(true)\n setSaveFailed(false)\n\n // Trigger 2: save analytics ride the handler run, fired only on success.\n const ok = isLowBalance\n ? await runHandler(\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE },\n )\n : await runHandler(\n 'updateUserInsightProfile',\n { fields: { savings_opportunity_minimum_checking_account_balance: amount } },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE },\n )\n\n if (!isMounted.current) return\n\n setIsSaving(false)\n\n if (ok) closeActionDrawer()\n else setSaveFailed(true)\n }\n\n return (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n // Only strings and the <strong> go in, so the result is renderable (the helper's type also\n // admits raw DOM nodes).\n content={\n buildDynamicCopy(\n (isEdit && variantCopy.description_edit) || variantCopy.description,\n <strong key=\"account\">{accountName}</strong>,\n ) as React.ReactNode\n }\n errorText={isInvalid ? copy.whole_number_error : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={\n // Pulse fires input-selected for the threshold dialog only (EditThreshold.js); the\n // safety-net dialog has no input event.\n isLowBalance\n ? () => fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED)\n : undefined\n }\n handleModalClose={handleDismiss}\n handlePrimaryAction={() => void handleSave()}\n handleSecondaryAction={handleDismiss}\n inputLabel={variantCopy.input_label}\n inputValue={value}\n isOpen={true}\n isPrimaryDisabled={isSaving || !isValid}\n primaryText={commonCopy.save_button}\n secondaryText={isLowBalance ? commonCopy.cancel_button : undefined}\n subtitle={\n isLowBalance && beat.primary_account ? (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n {/* Decorative: the account name is the visible text beside it. */}\n <InstitutionLogo\n alt=\"\"\n institutionGuid={beat.primary_account.institution_guid ?? ''}\n size={16}\n />\n <Text color=\"text.secondary\" uppercase={true} variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n ) : undefined\n }\n title={(isEdit && variantCopy.title_edit) || variantCopy.title}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,IAAM,IAAA,CAAgB,EACpB,UAAA,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MACP,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,QAAM,OAAM;AAAA,QAAiB,WAAW;AAAA,QAAM,SAAQ;AAAA,QACnD,UAAA;AAAA,MACG,CAAA,CACD;AAAA,IACL,CAAA,IAAA;AAAA,IAEN,OAAQ,KAAU,EAAY,cAAe,EAAY;AAAA,EAC1D,CAAA;AAEL,CAAC"}
|
|
1
|
+
{"version":3,"file":"AmountInputModalBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport MuiDialog from '@mui/material/Dialog'\nimport IconButton from '@mui/material/IconButton'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n Loader,\n buildDynamicCopy,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n useSettingsStore,\n useUserStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { useOpenedCta } from '../useOpenedCta'\n\nimport { CreateBudgetDialog } from './CreateBudgetDialog'\nimport {\n AMOUNT_INPUT_VARIANTS,\n CREATE_BUDGET_VARIANT,\n findLowBalanceProfile,\n isAmountInputVariant,\n isWholeAmount,\n resolveAmountInputVariant,\n toInputValue,\n} from './layout'\n\n/** Dialog frame for the formless states: loading and a non-retriable problem. */\nconst StatusDialog = ({\n children,\n closeAriaLabel,\n heading,\n onClose,\n}: React.PropsWithChildren<{ closeAriaLabel?: string; heading?: string; onClose: () => void }>) => {\n const headingId = React.useId()\n\n return (\n <MuiDialog\n aria-labelledby={heading ? headingId : undefined}\n maxWidth=\"xs\"\n onClose={onClose}\n open={true}\n >\n <Stack sx={{ gap: 12, p: 24, position: 'relative' }}>\n {heading && <H3 id={headingId}>{heading}</H3>}\n <IconButton\n aria-label={closeAriaLabel || 'Close'}\n onClick={onClose}\n sx={{ position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n {children}\n </Stack>\n </MuiDialog>\n )\n}\n\n/** `amount_input_modal_block`: one whole-dollar amount in a modal, picked by the CTA variant. */\nexport const AmountInputModalBlock = observer(function AmountInputModalBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const categoryStore = useCategoryStore()\n const openedCta = useOpenedCta(beat)\n // Read once on open: a refreshed beat must not swap the dialog under its snackbar.\n const [variant] = React.useState(() => resolveAmountInputVariant(openedCta))\n const isCreateBudget = variant === CREATE_BUDGET_VARIANT\n\n // The create dialog names the category, so it waits for the category store.\n React.useEffect(() => {\n if (isCreateBudget && !categoryStore.categoriesLoaded) void categoryStore.loadCategories()\n }, [categoryStore, isCreateBudget])\n\n if (!isCreateBudget) return <AmountSettingDialog beat={beat} variant={variant} />\n\n return categoryStore.categoriesLoaded ? (\n <CreateBudgetDialog beat={beat} />\n ) : (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n})\n\n/** The low-balance threshold and safety-net settings (the two `AMOUNT_INPUT_VARIANTS`). */\nconst AmountSettingDialog = observer(function AmountSettingDialog({\n beat,\n variant,\n}: ActionBlockProps & { variant?: string }) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const settingsStore = useSettingsStore()\n const { userInsightProfile } = useUserStore()\n const runHandler = useCtaHandler(beat, useBeatActions())\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const copy = insightsFeedCopy?.amount_input_modal\n const isLowBalance = variant === AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD\n\n const lowBalanceProfile = isLowBalance\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined\n const savedAmount = isLowBalance\n ? lowBalanceProfile?.threshold\n : userInsightProfile?.savings_opportunity_minimum_checking_account_balance\n\n // Mounting is the open, so profiles reload here and the threshold prefills as saved now.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(isLowBalance)\n // False once unmounted: a save that resolves after the user closed the dialog must not close\n // (or update) whatever action session is open by then.\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n React.useEffect(() => {\n if (!isLowBalance) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [isLowBalance, settingsStore])\n\n // `null` until the user types: the field shows the saved amount until then.\n const [typed, setTyped] = React.useState<string | null>(null)\n const [isSaving, setIsSaving] = React.useState(false)\n const [saveFailed, setSaveFailed] = React.useState(false)\n\n const value = typed ?? toInputValue(savedAmount)\n\n if (isLoadingProfiles) {\n return (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n }\n\n // Copy ships separately (see the doc's Rollout order), so check every string the form renders:\n // a partial ship falls to the error dialog instead of throwing mid-render.\n const variantCopy = isAmountInputVariant(variant) ? copy?.[variant] : undefined\n const hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!copy?.whole_number_error &&\n !!copy.save_error &&\n !!commonCopy?.save_button &&\n // Cancel renders for the low-balance variant only.\n (!isLowBalance || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = isLowBalance ? !!lowBalanceProfile : !!userInsightProfile\n\n if (!copy || !variantCopy || !hasCopy || !hasProfile) {\n // One message to the user; distinct warnings so a rollout problem can be traced to its cause.\n console.warn(\n `amount_input_modal_block: ${\n !copy\n ? 'copy namespace missing'\n : !isAmountInputVariant(variant)\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : isLowBalance\n ? 'no low-balance profile for the account'\n : 'user insight profile not set by the host'\n }`,\n )\n\n return (\n <StatusDialog\n closeAriaLabel={commonCopy?.close_aria}\n heading={commonCopy?.error_heading}\n onClose={closeActionDrawer}\n >\n <Text>{commonCopy?.error_message}</Text>\n </StatusDialog>\n )\n }\n\n // Trigger 4 — user dismissed without saving (close icon, Cancel button, backdrop). Pulse\n // parity: EditThreshold.js close button / EditSafetyNet.js cancel button.\n const handleDismiss = () => {\n fireAnalyticsEvent(\n isLowBalance\n ? ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED\n : ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n )\n closeActionDrawer()\n }\n\n const isEdit = !isLowBalance && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = isWholeAmount(value)\n const isInvalid = value !== '' && !isValid\n\n const handleSave = async () => {\n // Guarded here too, not only by the disabled button: Enter submits the dialog's form directly.\n if (!isValid || isSaving) return\n\n const amount = Number(value)\n\n setIsSaving(true)\n setSaveFailed(false)\n\n // Trigger 2: save analytics ride the handler run, fired only on success.\n const ok = isLowBalance\n ? await runHandler(\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE },\n )\n : await runHandler(\n 'updateUserInsightProfile',\n { fields: { savings_opportunity_minimum_checking_account_balance: amount } },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE },\n )\n\n if (!isMounted.current) return\n\n setIsSaving(false)\n\n if (ok) closeActionDrawer()\n else setSaveFailed(true)\n }\n\n return (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n // Only strings and the <strong> go in, so the result is renderable (the helper's type also\n // admits raw DOM nodes).\n content={\n buildDynamicCopy(\n (isEdit && variantCopy.description_edit) || variantCopy.description,\n <strong key=\"account\">{accountName}</strong>,\n ) as React.ReactNode\n }\n errorText={isInvalid ? copy.whole_number_error : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={\n // Pulse fires input-selected for the threshold dialog only (EditThreshold.js); the\n // safety-net dialog has no input event.\n isLowBalance\n ? () => fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED)\n : undefined\n }\n handleModalClose={handleDismiss}\n handlePrimaryAction={() => void handleSave()}\n handleSecondaryAction={handleDismiss}\n inputLabel={variantCopy.input_label}\n inputValue={value}\n isOpen={true}\n isPrimaryDisabled={isSaving || !isValid}\n primaryText={commonCopy.save_button}\n secondaryText={isLowBalance ? commonCopy.cancel_button : undefined}\n subtitle={\n isLowBalance && beat.primary_account ? (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n {/* Decorative: the account name is the visible text beside it. */}\n <InstitutionLogo\n alt=\"\"\n institutionGuid={beat.primary_account.institution_guid ?? ''}\n size={16}\n />\n <Text color=\"text.secondary\" uppercase={true} variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n ) : undefined\n }\n title={(isEdit && variantCopy.title_edit) || variantCopy.title}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,IAAM,IAAA,CAAgB,EACpB,UAAA,GACA,gBAAA,GACA,SAAA,GACA,SAAA,EAAA,MACiG;AACjG,QAAM,IAAY,EAAM,MAAM;AAE9B,SACE,gBAAA,EAAC,IAAD;AAAA,IACE,mBAAiB,IAAU,IAAY;AAAA,IACvC,UAAS;AAAA,IACA,SAAA;AAAA,IACT,MAAM;AAAA,IAEN,UAAA,gBAAA,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