@mx-cartographer/experiences 9.7.154 → 9.7.156
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 +13 -0
- package/dist/insights-v2/actionBlocks/AccountDetailsBlock/AccountDetailsBlock.es.js +19 -22
- package/dist/insights-v2/actionBlocks/AccountDetailsBlock/AccountDetailsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js +43 -48
- package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js +30 -34
- 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/BlockErrorMessage.d.ts +4 -0
- package/dist/insights-v2/actionBlocks/BlockErrorMessage.es.js +17 -0
- package/dist/insights-v2/actionBlocks/BlockErrorMessage.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js +131 -135
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/ContactSupportActionBlock.es.js +14 -18
- package/dist/insights-v2/actionBlocks/ContactSupportActionBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.es.js +19 -25
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js +26 -28
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/HelpBlock/HelpBlock.es.js +11 -14
- package/dist/insights-v2/actionBlocks/HelpBlock/HelpBlock.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/OverdraftBlock/OverdraftBlock.es.js +28 -30
- package/dist/insights-v2/actionBlocks/OverdraftBlock/OverdraftBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js +53 -55
- package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesBlock.es.js +26 -31
- package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesBlock.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/RemainingCashBlock/RemainingCashBlock.es.js +38 -41
- package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.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/TransactionDetailsBlock.es.js +11 -16
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/TransactionDetailsBlock.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/TransactionDrillDown.es.js +39 -42
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +102 -104
- 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/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaceholderActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/PlaceholderActionBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { H3, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useActionContext
|
|
1
|
+
{"version":3,"file":"PlaceholderActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/PlaceholderActionBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { H3, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useActionContext } from '../../common'\nimport type { Beat, DrilldownPayload } from '../../core'\n\nimport { createVariantBlock } from '../blocks/createVariantBlock'\nimport { type ActionBlockProps } from '../mappings/blocks'\nimport { useOpenedCta } from './useOpenedCta'\n\n// This block doubles as the reference example for the two building blocks a real\n// action block uses:\n// 1. useActionContext<T>() — read the drawer's opaque, block-specific context.\n// 2. createVariantBlock — dispatch to a per-variant component with a fallback.\n// Register a block with variants exactly like `PlaceholderVariants` below, then\n// wire it into src/insights-v2/mappings/blocks.ts. ActionBlockLayer mounts it once\n// copy has loaded; render `BlockErrorMessage` when its copy or data is missing.\n\ninterface PlaceholderVariantProps {\n beat: Beat\n}\n\n/** Default variant — also the fallback for unknown/absent variants.\n * Wrapped in `observer` because it reads the drawer's observable context via\n * useActionContext; without it a memoized ancestor would stop it re-rendering.\n * This is the copy-paste template for real blocks, so it must model the rule. */\nconst DefaultPlaceholder = observer(({ beat }: PlaceholderVariantProps) => {\n // Chart drilldowns put { chartBarIndex, tabIndex } on the drawer context; a\n // CTA open carries none, so default to 0.\n const { chartBarIndex = 0, tabIndex = 0 } = useActionContext<DrilldownPayload>() ?? {}\n\n return (\n <Stack sx={{ alignItems: 'center', gap: 8, p: 24, textAlign: 'center' }}>\n <H3>Action Block Layer Drilldown</H3>\n <Text>\n This is a placeholder action block. Replace it with your own implementation by registering\n your block in src/insights-v2/mappings/blocks.ts.\n </Text>\n <Text>Beat: {beat.guid}</Text>\n <Text>\n Drilldown: chartBarIndex {chartBarIndex}, tabIndex {tabIndex}\n </Text>\n </Stack>\n )\n})\n\n/** A second sample variant, to show registry dispatch with more than one entry. */\nconst CompactPlaceholder = ({ beat }: PlaceholderVariantProps) => (\n <Stack sx={{ alignItems: 'center', gap: 8, p: 24, textAlign: 'center' }}>\n <H3>Action Block Layer Drilldown (compact)</H3>\n <Text>Beat: {beat.guid}</Text>\n </Stack>\n)\n\n// Register one component per backend `variant`; unknown/absent variants fall\n// back to DefaultPlaceholder.\nconst PlaceholderVariants = createVariantBlock<PlaceholderVariantProps>({\n variants: {\n default: DefaultPlaceholder,\n compact: CompactPlaceholder,\n },\n fallback: DefaultPlaceholder,\n name: 'Placeholder',\n})\n\nexport const PlaceholderActionBlock = observer(function PlaceholderActionBlock({\n beat,\n}: ActionBlockProps) {\n const cta = useOpenedCta(beat)\n\n return <PlaceholderVariants beat={beat} variant={cta?.variant} />\n})\n"],"mappings":";;;;;;;AA4BA,IAAM,IAAqB,EAAA,CAAU,EAAE,MAAA,EAAA,MAAoC;AAGzE,QAAM,EAAE,eAAA,IAAgB,GAAG,UAAA,IAAW,EAAA,IAAM,EAAmC,KAAK,CAAC;AAErF,SACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI;AAAA,MAAE,YAAY;AAAA,MAAU,KAAK;AAAA,MAAG,GAAG;AAAA,MAAI,WAAW;AAAA,IAAS;AAAA,IAAtE,UAAA;AAAA,MACE,gBAAA,EAAC,GAAD,EAAA,UAAI,+BAAgC,CAAA;AAAA,MACpC,gBAAA,EAAC,GAAD,EAAA,UAAM,+IAGA,CAAA;AAAA,MACN,gBAAA,EAAC,GAAD,EAAA,UAAA,CAAM,UAAO,EAAK,IAAW,EAAA,CAAA;AAAA,MAC7B,gBAAA,EAAC,GAAD,EAAA,UAAA;AAAA,QAAM;AAAA,QACsB;AAAA,QAAc;AAAA,QAAY;AAAA,MAChD,EAAA,CAAA;AAAA,IACD;AAAA;AAEX,CAAC,GAGK,IAAA,CAAsB,EAAE,MAAA,EAAA,MAC5B,gBAAA,EAAC,GAAD;AAAA,EAAO,IAAI;AAAA,IAAE,YAAY;AAAA,IAAU,KAAK;AAAA,IAAG,GAAG;AAAA,IAAI,WAAW;AAAA,EAAS;AAAA,EAAtE,UAAA,CACE,gBAAA,EAAC,GAAD,EAAA,UAAI,yCAA0C,CAAA,GAC9C,gBAAA,EAAC,GAAD,EAAA,UAAA,CAAM,UAAO,EAAK,IAAW,EAAA,CAAA,CACxB;IAKH,IAAsB,EAA4C;AAAA,EACtE,UAAU;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,EACX;AAAA,EACA,UAAU;AAAA,EACV,MAAM;AACR,CAAC,GAEY,IAAyB,EAAS,SAAgC,EAC7E,MAAA,EAAA,GACmB;AACnB,QAAM,IAAM,EAAa,CAAI;AAE7B,SAAO,gBAAA,EAAC,GAAD;AAAA,IAA2B,MAAA;AAAA,IAAM,SAAS,GAAK;AAAA,EAAU,CAAA;AAClE,CAAC"}
|
|
@@ -1,47 +1,44 @@
|
|
|
1
|
-
import { CategoryGuids as
|
|
2
|
-
import { DEFAULT_INSTITUTION_LOGO_URL as
|
|
3
|
-
import
|
|
4
|
-
import { useAccountStore as
|
|
1
|
+
import { CategoryGuids as f } from "../../../core/constants/Category.es.js";
|
|
2
|
+
import { DEFAULT_INSTITUTION_LOGO_URL as h } from "../../../core/constants/InstitutionLogo.es.js";
|
|
3
|
+
import _ from "../../../common/utils/AccountDisplayName.es.js";
|
|
4
|
+
import { useAccountStore as y, useAppConfig as C, useCashflowStore as x, useGlobalCopyStore as G } from "../../../common/context/hooks.es.js";
|
|
5
5
|
import { getAccountStartingBalance as R } from "../../../core/utils/AccountUtils.es.js";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import A from "./
|
|
12
|
-
import
|
|
13
|
-
import O from "
|
|
14
|
-
import { InstitutionLogo as
|
|
15
|
-
import { jsx as
|
|
16
|
-
var
|
|
17
|
-
const {
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (!d || !p || !e) return /* @__PURE__ */ n(L, {});
|
|
24
|
-
const l = a(t.selectedCashAccounts.map((o) => ({
|
|
25
|
-
amount: R(o, c.display_available_balance_in_accounts),
|
|
6
|
+
import T from "../../../common/components/Loader.es.js";
|
|
7
|
+
import { BlockErrorMessage as E } from "../BlockErrorMessage.es.js";
|
|
8
|
+
import i from "../../components/CategoryTile.es.js";
|
|
9
|
+
import { ErrorCard as L } from "../../components/ErrorCard.es.js";
|
|
10
|
+
import { useRecurringExpensesLoadState as U } from "../RecurringTransactionBlock/useRecurringTransactionPrepare.es.js";
|
|
11
|
+
import { foldOtherRows as r, getCaption as A } from "./layout.es.js";
|
|
12
|
+
import I from "./RemainingCashContent.es.js";
|
|
13
|
+
import { observer as O } from "mobx-react-lite";
|
|
14
|
+
import { InstitutionLogo as a } from "@mxenabled/mxui";
|
|
15
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
16
|
+
var J = O(function(b) {
|
|
17
|
+
const { insights_feed: s } = G(), { config: m } = C(), { uiStore: n } = x(), { accountsLoaded: c } = y(), { failed: u, ready: p, retry: d } = U(), e = s?.remaining_cash;
|
|
18
|
+
if (!e) return /* @__PURE__ */ t(E, {});
|
|
19
|
+
if (u) return /* @__PURE__ */ t(L, { onRetry: d });
|
|
20
|
+
if (!p || !c) return /* @__PURE__ */ t(T, {});
|
|
21
|
+
const g = r(n.selectedCashAccounts.map((o) => ({
|
|
22
|
+
amount: R(o, m.display_available_balance_in_accounts),
|
|
26
23
|
key: o.guid,
|
|
27
|
-
leading: /* @__PURE__ */
|
|
24
|
+
leading: /* @__PURE__ */ t(a, {
|
|
28
25
|
alt: "",
|
|
29
26
|
institutionGuid: o.institution_guid ?? "",
|
|
30
27
|
size: 32
|
|
31
28
|
}),
|
|
32
|
-
name:
|
|
29
|
+
name: _(o)
|
|
33
30
|
})), {
|
|
34
31
|
multi: e.other_accounts,
|
|
35
32
|
one: e.other_accounts_one
|
|
36
|
-
}, /* @__PURE__ */
|
|
33
|
+
}, /* @__PURE__ */ t(a, {
|
|
37
34
|
alt: "",
|
|
38
35
|
institutionGuid: "",
|
|
39
|
-
logoUrl:
|
|
36
|
+
logoUrl: h,
|
|
40
37
|
size: 32
|
|
41
|
-
})),
|
|
38
|
+
})), l = r(n.expensesTilNextIncome.map((o) => ({
|
|
42
39
|
amount: o.amount,
|
|
43
40
|
key: `${o.repeatingTransactionGuid}-${o.expectedDate.getTime()}`,
|
|
44
|
-
leading: /* @__PURE__ */
|
|
41
|
+
leading: /* @__PURE__ */ t(i, {
|
|
45
42
|
categoryGuid: o.categoryGuid,
|
|
46
43
|
size: 32
|
|
47
44
|
}),
|
|
@@ -49,33 +46,33 @@ var Q = I(function(N) {
|
|
|
49
46
|
})), {
|
|
50
47
|
multi: e.other_expenses,
|
|
51
48
|
one: e.other_expenses_one
|
|
52
|
-
}, /* @__PURE__ */
|
|
53
|
-
categoryGuid:
|
|
49
|
+
}, /* @__PURE__ */ t(i, {
|
|
50
|
+
categoryGuid: f.UNCATEGORIZED,
|
|
54
51
|
size: 32
|
|
55
52
|
}));
|
|
56
|
-
return /* @__PURE__ */
|
|
53
|
+
return /* @__PURE__ */ t(I, {
|
|
57
54
|
accounts: {
|
|
58
55
|
header: e.accounts_header,
|
|
59
|
-
rows:
|
|
56
|
+
rows: g
|
|
60
57
|
},
|
|
61
58
|
expenses: {
|
|
62
59
|
header: e.recurring_expenses_header,
|
|
63
|
-
rows:
|
|
60
|
+
rows: l
|
|
64
61
|
},
|
|
65
62
|
summary: {
|
|
66
|
-
remaining:
|
|
67
|
-
amount:
|
|
68
|
-
caption:
|
|
63
|
+
remaining: n.hasUpcomingPayday ? {
|
|
64
|
+
amount: n.remainingUntilPayday,
|
|
65
|
+
caption: A(e, n.daysUntilNextIncome)
|
|
69
66
|
} : void 0,
|
|
70
|
-
cashOnHand:
|
|
67
|
+
cashOnHand: n.selectedCashBalance,
|
|
71
68
|
cashOnHandLabel: e.cash_on_hand,
|
|
72
|
-
upcomingExpenses:
|
|
69
|
+
upcomingExpenses: n.upcomingExpensesTotal,
|
|
73
70
|
upcomingExpensesLabel: e.upcoming_expenses
|
|
74
71
|
}
|
|
75
72
|
});
|
|
76
73
|
});
|
|
77
74
|
export {
|
|
78
|
-
|
|
75
|
+
J as RemainingCashBlock
|
|
79
76
|
};
|
|
80
77
|
|
|
81
78
|
//# sourceMappingURL=RemainingCashBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemainingCashBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"RemainingCashBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.tsx"],"sourcesContent":["import { InstitutionLogo } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Loader,\n useAccountStore,\n useAppConfig,\n useCashflowStore,\n useGlobalCopyStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { CategoryGuids } from '../../../core/constants/Category'\nimport { DEFAULT_INSTITUTION_LOGO_URL } from '../../../core/constants/InstitutionLogo'\nimport { getAccountStartingBalance } from '../../../core/utils/AccountUtils'\nimport CategoryTile from '../../components/CategoryTile'\nimport { ErrorCard } from '../../components/ErrorCard'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { BlockErrorMessage } from '../BlockErrorMessage'\nimport { useRecurringExpensesLoadState } from '../RecurringTransactionBlock'\n\nimport { foldOtherRows, getCaption } from './layout'\nimport RemainingCashContent from './RemainingCashContent'\n\n/** Remaining Cash drawer: today's figures from CashflowStore, not the card's (see docs/action-blocks/remaining-cash-block.md). */\nexport const RemainingCashBlock = observer(function RemainingCashBlock(_props: ActionBlockProps) {\n const { insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { config } = useAppConfig()\n const { uiStore } = useCashflowStore()\n const { accountsLoaded } = useAccountStore()\n const { failed, ready, retry } = useRecurringExpensesLoadState()\n const copy = insightsFeedCopy?.remaining_cash\n\n if (!copy) return <BlockErrorMessage />\n\n if (failed) return <ErrorCard onRetry={retry} />\n\n // `accountsLoaded` / `ready` cover another widget's request still in flight.\n if (!ready || !accountsLoaded) return <Loader />\n\n const accountRows = foldOtherRows(\n uiStore.selectedCashAccounts.map((account) => ({\n amount: getAccountStartingBalance(account, config.display_available_balance_in_accounts),\n key: account.guid,\n // Decorative: the row's visible name already says which account it is.\n leading: (\n <InstitutionLogo alt=\"\" institutionGuid={account.institution_guid ?? ''} size={32} />\n ),\n name: getAccountDisplayName(account),\n })),\n { multi: copy.other_accounts, one: copy.other_accounts_one },\n <InstitutionLogo alt=\"\" institutionGuid=\"\" logoUrl={DEFAULT_INSTITUTION_LOGO_URL} size={32} />,\n )\n const expenseRows = foldOtherRows(\n uiStore.expensesTilNextIncome.map((expense) => ({\n amount: expense.amount,\n key: `${expense.repeatingTransactionGuid}-${expense.expectedDate.getTime()}`,\n leading: <CategoryTile categoryGuid={expense.categoryGuid} size={32} />,\n name: expense.name,\n })),\n { multi: copy.other_expenses, one: copy.other_expenses_one },\n <CategoryTile categoryGuid={CategoryGuids.UNCATEGORIZED} size={32} />,\n )\n\n return (\n <RemainingCashContent\n accounts={{ header: copy.accounts_header, rows: accountRows }}\n expenses={{ header: copy.recurring_expenses_header, rows: expenseRows }}\n summary={{\n remaining: uiStore.hasUpcomingPayday\n ? {\n amount: uiStore.remainingUntilPayday,\n caption: getCaption(copy, uiStore.daysUntilNextIncome),\n }\n : undefined,\n cashOnHand: uiStore.selectedCashBalance,\n cashOnHandLabel: copy.cash_on_hand,\n upcomingExpenses: uiStore.upcomingExpensesTotal,\n upcomingExpensesLabel: copy.upcoming_expenses,\n }}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,IAAa,IAAqB,EAAS,SAA4B,GAA0B;AAC/F,QAAM,EAAE,eAAe,EAAA,IAAqB,EAAmB,GACzD,EAAE,QAAA,EAAA,IAAW,EAAa,GAC1B,EAAE,SAAA,EAAA,IAAY,EAAiB,GAC/B,EAAE,gBAAA,EAAA,IAAmB,EAAgB,GACrC,EAAE,QAAA,GAAQ,OAAA,GAAO,OAAA,EAAA,IAAU,EAA8B,GACzD,IAAO,GAAkB;AAE/B,MAAI,CAAC,EAAM,QAAO,gBAAA,EAAC,GAAD,CAAoB,CAAA;AAEtC,MAAI,EAAQ,QAAO,gBAAA,EAAC,GAAD,EAAW,SAAS,EAAQ,CAAA;AAG/C,MAAI,CAAC,KAAS,CAAC,EAAgB,QAAO,gBAAA,EAAC,GAAD,CAAS,CAAA;AAE/C,QAAM,IAAc,EAClB,EAAQ,qBAAqB,IAAA,CAAK,OAAa;AAAA,IAC7C,QAAQ,EAA0B,GAAS,EAAO,qCAAqC;AAAA,IACvF,KAAK,EAAQ;AAAA,IAEb,SACE,gBAAA,EAAC,GAAD;AAAA,MAAiB,KAAI;AAAA,MAAG,iBAAiB,EAAQ,oBAAoB;AAAA,MAAI,MAAM;AAAA,IAAK,CAAA;AAAA,IAEtF,MAAM,EAAsB,CAAO;AAAA,EACrC,EAAE,GACF;AAAA,IAAE,OAAO,EAAK;AAAA,IAAgB,KAAK,EAAK;AAAA,EAAmB,GAC3D,gBAAA,EAAC,GAAD;AAAA,IAAiB,KAAI;AAAA,IAAG,iBAAgB;AAAA,IAAG,SAAS;AAAA,IAA8B,MAAM;AAAA,EAAK,CAAA,CAC/F,GACM,IAAc,EAClB,EAAQ,sBAAsB,IAAA,CAAK,OAAa;AAAA,IAC9C,QAAQ,EAAQ;AAAA,IAChB,KAAK,GAAG,EAAQ,wBAAA,IAA4B,EAAQ,aAAa,QAAQ,CAAA;AAAA,IACzE,SAAS,gBAAA,EAAC,GAAD;AAAA,MAAc,cAAc,EAAQ;AAAA,MAAc,MAAM;AAAA,IAAK,CAAA;AAAA,IACtE,MAAM,EAAQ;AAAA,EAChB,EAAE,GACF;AAAA,IAAE,OAAO,EAAK;AAAA,IAAgB,KAAK,EAAK;AAAA,EAAmB,GAC3D,gBAAA,EAAC,GAAD;AAAA,IAAc,cAAc,EAAc;AAAA,IAAe,MAAM;AAAA,EAAK,CAAA,CACtE;AAEA,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,UAAU;AAAA,MAAE,QAAQ,EAAK;AAAA,MAAiB,MAAM;AAAA,IAAY;AAAA,IAC5D,UAAU;AAAA,MAAE,QAAQ,EAAK;AAAA,MAA2B,MAAM;AAAA,IAAY;AAAA,IACtE,SAAS;AAAA,MACP,WAAW,EAAQ,oBACf;AAAA,QACE,QAAQ,EAAQ;AAAA,QAChB,SAAS,EAAW,GAAM,EAAQ,mBAAmB;AAAA,MACvD,IACA;AAAA,MACJ,YAAY,EAAQ;AAAA,MACpB,iBAAiB,EAAK;AAAA,MACtB,kBAAkB,EAAQ;AAAA,MAC1B,uBAAuB,EAAK;AAAA,IAC9B;AAAA,EACD,CAAA;AAEL,CAAC"}
|
|
@@ -1,91 +1,91 @@
|
|
|
1
1
|
import { useGlobalCopyStore as z, useGlobalStore as X, useInsightsV2Store as $ } from "../../common/context/hooks.es.js";
|
|
2
|
-
import { slot as
|
|
2
|
+
import { slot as p } from "../../core/types/Insights.es.js";
|
|
3
3
|
import { CURRENCY_FORMAT as q, formatCurrency as Y } from "../../core/utils/NumberFormatting.es.js";
|
|
4
|
-
import
|
|
4
|
+
import D from "../../common/components/dialog/Dialog.es.js";
|
|
5
5
|
import { useBeatActions as Z } from "../beatActions.es.js";
|
|
6
6
|
import { asLogoRef as J } from "../blocks/slotReaders.es.js";
|
|
7
|
-
import { USER_RESPONSE as
|
|
7
|
+
import { USER_RESPONSE as d, answerSubscription as K, repeatingTransactionOf as Q, reportSubscriptionMarkedIncorrect as tt } from "../ctaActions/subscriptionAnswer.es.js";
|
|
8
8
|
import ot from "../components/LogoFromGuid.es.js";
|
|
9
9
|
import "../components/celebrationGradients.es.js";
|
|
10
10
|
import { ELEVATION_SHADOW as rt } from "../components/shared/elevation.es.js";
|
|
11
11
|
import et from "../components/TransactionListCard.es.js";
|
|
12
12
|
import { subscriptionFrequency as st } from "../components/SubscriptionStatus/subscriptionFrequency.es.js";
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import { useEffect as at, useRef as
|
|
13
|
+
import nt from "../components/shared/StatusSnackbar.es.js";
|
|
14
|
+
import { useOpenedCta as it } from "./useOpenedCta.es.js";
|
|
15
|
+
import { useEffect as at, useRef as N, useState as k } from "react";
|
|
16
16
|
import { observer as ct } from "mobx-react-lite";
|
|
17
|
-
import
|
|
17
|
+
import T from "@mui/material/Stack";
|
|
18
18
|
import { Text as lt } from "@mxenabled/mxui";
|
|
19
19
|
import { Icon as ut } from "@mxenabled/mx-icons";
|
|
20
20
|
import { Fragment as mt, jsx as r, jsxs as w } from "react/jsx-runtime";
|
|
21
21
|
import pt from "@mui/material/Divider";
|
|
22
22
|
import dt from "@mui/material/ButtonBase";
|
|
23
|
-
var ft = 32,
|
|
23
|
+
var ft = 32, B = {
|
|
24
24
|
backgroundColor: "background.paper",
|
|
25
25
|
borderRadius: 1,
|
|
26
26
|
boxShadow: rt[16]
|
|
27
27
|
}, L = {
|
|
28
|
-
"& .MuiDialog-paper":
|
|
28
|
+
"& .MuiDialog-paper": B,
|
|
29
29
|
"& .MuiDialogContent-root": { p: 0 },
|
|
30
30
|
"& .MuiDialogContent-root ~ .MuiStack-root .MuiButton-root": {
|
|
31
31
|
px: 16,
|
|
32
32
|
py: 12
|
|
33
33
|
}
|
|
34
34
|
}, _t = [
|
|
35
|
-
["never_subscribed",
|
|
36
|
-
["cancelled",
|
|
37
|
-
["one_time_purchase",
|
|
38
|
-
], o = (
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
return
|
|
42
|
-
label:
|
|
43
|
-
userResponse:
|
|
35
|
+
["never_subscribed", d.NEVER_SUBSCRIBED],
|
|
36
|
+
["cancelled", d.CANCELLED],
|
|
37
|
+
["one_time_purchase", d.ONE_TIME_PURCHASE]
|
|
38
|
+
], o = (i) => typeof i == "string" && i.trim() ? i : void 0, Ft = ct(function({ beat: f }) {
|
|
39
|
+
const G = X(), { insights_feed: _, recurring: P } = z(), { closeActionDrawer: g } = $(), F = it(f), W = Z(), [x, b] = k("answers"), [e, a] = k(null), c = N(!1), y = N(!1), t = _?.subscription_status_modal, U = f.insights_payload, S = _t.flatMap(([s, u]) => {
|
|
40
|
+
const m = o(t?.[s]);
|
|
41
|
+
return m ? [{
|
|
42
|
+
label: m,
|
|
43
|
+
userResponse: u
|
|
44
44
|
}] : [];
|
|
45
|
-
}),
|
|
45
|
+
}), E = !!o(t?.title) && !!o(t?.subscribed_answer) && !!o(t?.not_subscribed_answer) && S.length > 0, O = !!_ && !E;
|
|
46
46
|
if (at(() => {
|
|
47
|
-
|
|
48
|
-
}, [
|
|
47
|
+
O && (console.warn("[SubscriptionStatusModalBlock] subscription_status_modal is missing its title, answers or reasons; closing."), g());
|
|
48
|
+
}, [O, g]), !U || !t || !E) return null;
|
|
49
49
|
const h = o(t.close_aria) ?? o(t.toast_close_aria) ?? o(_?.settings_menu?.close) ?? "", R = e && o(e.severity === "success" ? t.success_message : t.error_message), v = {
|
|
50
|
-
beat:
|
|
51
|
-
stores:
|
|
52
|
-
hostActions:
|
|
53
|
-
},
|
|
50
|
+
beat: f,
|
|
51
|
+
stores: G,
|
|
52
|
+
hostActions: W
|
|
53
|
+
}, l = F?.drilldown_data ?? {}, I = J(p(l, "logo")), A = p(l, "primary_text"), M = p(l, "amount"), C = async (s) => {
|
|
54
54
|
if (!y.current) {
|
|
55
55
|
y.current = !0, a(null), b("saving");
|
|
56
56
|
try {
|
|
57
|
-
await K(v, s), o(t.success_message) ? a({ severity: "success" }) :
|
|
57
|
+
await K(v, s), o(t.success_message) ? a({ severity: "success" }) : n();
|
|
58
58
|
} catch {
|
|
59
59
|
o(t.error_message) ? a({
|
|
60
60
|
severity: "error",
|
|
61
61
|
retry: s
|
|
62
|
-
}) :
|
|
62
|
+
}) : n();
|
|
63
63
|
} finally {
|
|
64
64
|
y.current = !1;
|
|
65
65
|
}
|
|
66
66
|
b("done");
|
|
67
67
|
}
|
|
68
|
-
},
|
|
68
|
+
}, n = () => {
|
|
69
69
|
a(null), g();
|
|
70
70
|
}, H = () => {
|
|
71
71
|
c.current = !0, tt(v), b("reasons");
|
|
72
72
|
}, j = () => {
|
|
73
|
-
c.current = !0, C(
|
|
73
|
+
c.current = !0, C(d.CONFIRMED);
|
|
74
74
|
}, V = () => {
|
|
75
75
|
if (c.current) {
|
|
76
76
|
c.current = !1;
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
n();
|
|
80
80
|
};
|
|
81
81
|
return /* @__PURE__ */ w(mt, { children: [
|
|
82
|
-
/* @__PURE__ */ r(
|
|
82
|
+
/* @__PURE__ */ r(D, {
|
|
83
83
|
copy: {
|
|
84
84
|
title: t.title,
|
|
85
85
|
close_aria: h
|
|
86
86
|
},
|
|
87
87
|
fullWidth: !0,
|
|
88
|
-
isOpen:
|
|
88
|
+
isOpen: x === "answers",
|
|
89
89
|
onClose: V,
|
|
90
90
|
onPrimaryAction: j,
|
|
91
91
|
onSecondaryAction: H,
|
|
@@ -97,35 +97,35 @@ var ft = 32, G = {
|
|
|
97
97
|
elevated: !0,
|
|
98
98
|
rows: [{
|
|
99
99
|
amount: typeof M == "number" ? Y(M, q.cents) : "",
|
|
100
|
-
amountCaption: st(
|
|
100
|
+
amountCaption: st(P, Q(v)),
|
|
101
101
|
leading: I ? /* @__PURE__ */ r(ot, {
|
|
102
102
|
logo: I,
|
|
103
103
|
size: ft
|
|
104
104
|
}) : void 0,
|
|
105
|
-
subtitle:
|
|
105
|
+
subtitle: p(l, "secondary_text") ?? "",
|
|
106
106
|
title: A
|
|
107
107
|
}]
|
|
108
108
|
})
|
|
109
109
|
}),
|
|
110
|
-
/* @__PURE__ */ r(
|
|
110
|
+
/* @__PURE__ */ r(D, {
|
|
111
111
|
copy: {
|
|
112
112
|
title: t.title,
|
|
113
113
|
close_aria: h
|
|
114
114
|
},
|
|
115
115
|
fullWidth: !0,
|
|
116
|
-
isOpen:
|
|
117
|
-
onClose:
|
|
116
|
+
isOpen: x === "reasons",
|
|
117
|
+
onClose: n,
|
|
118
118
|
showActions: !1,
|
|
119
119
|
sx: {
|
|
120
120
|
...L,
|
|
121
121
|
"& .MuiDialog-paper": {
|
|
122
|
-
...
|
|
122
|
+
...B,
|
|
123
123
|
pb: 16
|
|
124
124
|
}
|
|
125
125
|
},
|
|
126
|
-
children: /* @__PURE__ */ r(
|
|
126
|
+
children: /* @__PURE__ */ r(T, { children: S.map(({ label: s, userResponse: u }, m) => /* @__PURE__ */ w(T, { children: [/* @__PURE__ */ w(dt, {
|
|
127
127
|
onClick: () => {
|
|
128
|
-
C(
|
|
128
|
+
C(u);
|
|
129
129
|
},
|
|
130
130
|
sx: {
|
|
131
131
|
gap: 12,
|
|
@@ -145,19 +145,19 @@ var ft = 32, G = {
|
|
|
145
145
|
size: 24,
|
|
146
146
|
sx: { color: "action.active" }
|
|
147
147
|
})]
|
|
148
|
-
}),
|
|
148
|
+
}), m < S.length - 1 && /* @__PURE__ */ r(pt, { sx: {
|
|
149
149
|
ml: 24,
|
|
150
150
|
mt: "-1px"
|
|
151
|
-
} })] },
|
|
151
|
+
} })] }, u)) })
|
|
152
152
|
}),
|
|
153
|
-
e && R && /* @__PURE__ */ r(
|
|
153
|
+
e && R && /* @__PURE__ */ r(nt, {
|
|
154
154
|
actionText: e.retry ? o(t.try_again) : void 0,
|
|
155
155
|
closeAriaLabel: o(t.toast_close_aria) ?? h,
|
|
156
156
|
message: R,
|
|
157
157
|
onActionClick: e.retry ? () => {
|
|
158
158
|
C(e.retry);
|
|
159
159
|
} : void 0,
|
|
160
|
-
onClose:
|
|
160
|
+
onClose: n,
|
|
161
161
|
open: !0,
|
|
162
162
|
severity: e.severity,
|
|
163
163
|
variant: "strong"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionStatusModalBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/SubscriptionStatusModalBlock.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport ButtonBase from '@mui/material/ButtonBase'\nimport Divider from '@mui/material/Divider'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { Text } from '@mxenabled/mxui'\n\nimport { Dialog, useGlobalCopyStore, useGlobalStore, useInsightsV2Store } from '../../common'\nimport { slot } from '../../core'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../core/utils/NumberFormatting'\nimport { useBeatActions } from '../beatActions'\nimport { WARNING_WASH_GRADIENT } from '../components/celebrationGradients'\nimport LogoFromGuid from '../components/LogoFromGuid'\nimport { ELEVATION_SHADOW } from '../components/shared/elevation'\nimport StatusSnackbar from '../components/shared/StatusSnackbar'\nimport { subscriptionFrequency } from '../components/SubscriptionStatus/subscriptionFrequency'\nimport TransactionListCard from '../components/TransactionListCard'\nimport {\n answerSubscription,\n repeatingTransactionOf,\n reportSubscriptionMarkedIncorrect,\n USER_RESPONSE,\n} from '../ctaActions/subscriptionAnswer'\nimport type { ActionBlockProps } from '../mappings/blocks'\nimport { asLogoRef } from '../blocks/slotReaders'\nimport { getDynamicCtaBasedOnTriggers } from './util'\n\nconst ROW_LOGO_SIZE = 32\n\n// Figma dialog: paper, 4px radius, elevation/16.\nconst DIALOG_PAPER_SX = {\n backgroundColor: 'background.paper',\n borderRadius: 1,\n boxShadow: ELEVATION_SHADOW[16],\n}\nconst SUBSCRIPTION_DIALOG_SX = {\n '& .MuiDialog-paper': DIALOG_PAPER_SX,\n '& .MuiDialogContent-root': { p: 0 },\n '& .MuiDialogContent-root ~ .MuiStack-root .MuiButton-root': { px: 16, py: 12 },\n}\n\n// The reasons in Figma order; a reason with no word drops its row.\nconst REASONS = [\n ['never_subscribed', USER_RESPONSE.NEVER_SUBSCRIBED],\n ['cancelled', USER_RESPONSE.CANCELLED],\n ['one_time_purchase', USER_RESPONSE.ONE_TIME_PURCHASE],\n] as const\n\n/** A non-empty word, or undefined. */\nconst word = (value?: string): string | undefined =>\n typeof value === 'string' && value.trim() ? value : undefined\n\ntype Phase = 'answers' | 'reasons' | 'saving' | 'done'\ninterface Notice {\n severity: 'success' | 'error'\n retry?: string\n}\n\n/** Unexpected Subscription Payment's Subscription Status modal. */\nexport const SubscriptionStatusModalBlock = observer(function SubscriptionStatusModalBlock({\n beat,\n}: ActionBlockProps) {\n const stores = useGlobalStore()\n const { insights_feed, recurring } = useGlobalCopyStore()\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n const beatActions = useBeatActions()\n const [phase, setPhase] = useState<Phase>('answers')\n const [notice, setNotice] = useState<Notice | null>(null)\n // The Dialog calls onClose after its actions; keep the flow open.\n const actionTaken = useRef(false)\n // One save at a time: a double tap (a closing dialog is still clickable) or Try Again sends one PUT.\n const saving = useRef(false)\n\n const copy = insights_feed?.subscription_status_modal\n const payload = beat.insights_payload\n // Only the words needed to answer: the title, both answers and at least one reason. The rest\n // (snackbar words, close labels, reviewed_title, a key added later) never block the modal.\n const reasons = REASONS.flatMap(([key, userResponse]) => {\n const label = word(copy?.[key])\n\n return label ? [{ label, userResponse }] : []\n })\n const ready =\n !!word(copy?.title) &&\n !!word(copy?.subscribed_answer) &&\n !!word(copy?.not_subscribed_answer) &&\n reasons.length > 0\n // Copy loaded (insights_feed is there) but incomplete: say so and close, not a silent open drawer.\n const incomplete = !!insights_feed && !ready\n\n useEffect(() => {\n if (!incomplete) return\n console.warn(\n '[SubscriptionStatusModalBlock] subscription_status_modal is missing its title, answers or reasons; closing.',\n )\n closeActionDrawer()\n }, [incomplete, closeActionDrawer])\n\n if (!payload || !copy || !ready) return null\n\n const closeLabel =\n word(copy.close_aria) ??\n word(copy.toast_close_aria) ??\n word(insights_feed?.settings_menu?.close) ??\n ''\n const noticeMessage =\n notice && word(notice.severity === 'success' ? copy.success_message : copy.error_message)\n\n const ctx = { beat, stores, hostActions: beatActions }\n const cta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n payload.primary_cta,\n payload.secondary_cta,\n payload.in_description_cta,\n )\n const row = cta?.drilldown_data ?? {}\n const logo = asLogoRef(slot(row, 'logo'))\n const title = slot<string>(row, 'primary_text')\n const amount = slot<number>(row, 'amount')\n\n const save = async (userResponse: string) => {\n if (saving.current) return\n saving.current = true\n setNotice(null)\n setPhase('saving')\n try {\n await answerSubscription(ctx, userResponse)\n // No snackbar word: the save stands, the flow just ends without the snackbar.\n if (word(copy.success_message)) setNotice({ severity: 'success' })\n else finish()\n } catch {\n if (word(copy.error_message)) setNotice({ severity: 'error', retry: userResponse })\n else finish()\n } finally {\n saving.current = false\n }\n setPhase('done')\n }\n\n const finish = () => {\n setNotice(null)\n closeActionDrawer()\n }\n\n const chooseNotSubscribed = () => {\n actionTaken.current = true\n reportSubscriptionMarkedIncorrect(ctx)\n setPhase('reasons')\n }\n\n const chooseSubscribed = () => {\n actionTaken.current = true\n void save(USER_RESPONSE.CONFIRMED)\n }\n\n const closeAnswers = () => {\n if (actionTaken.current) {\n actionTaken.current = false\n return\n }\n finish()\n }\n\n return (\n <>\n <Dialog\n copy={{ title: copy.title, close_aria: closeLabel }}\n fullWidth={true}\n isOpen={phase === 'answers'}\n onClose={closeAnswers}\n onPrimaryAction={chooseSubscribed}\n onSecondaryAction={chooseNotSubscribed}\n primaryText={copy.subscribed_answer}\n secondaryText={copy.not_subscribed_answer}\n // Full-bleed wash between title and actions.\n sx={SUBSCRIPTION_DIALOG_SX}\n >\n {typeof title === 'string' && title && (\n <TransactionListCard\n background={WARNING_WASH_GRADIENT}\n elevated={true}\n rows={[\n {\n amount:\n typeof amount === 'number' ? formatCurrency(amount, CURRENCY_FORMAT.cents) : '',\n amountCaption: subscriptionFrequency(recurring, repeatingTransactionOf(ctx)),\n leading: logo ? <LogoFromGuid logo={logo} size={ROW_LOGO_SIZE} /> : undefined,\n subtitle: slot<string>(row, 'secondary_text') ?? '',\n title,\n },\n ]}\n />\n )}\n </Dialog>\n\n <Dialog\n copy={{ title: copy.title, close_aria: closeLabel }}\n fullWidth={true}\n isOpen={phase === 'reasons'}\n onClose={finish}\n showActions={false}\n // Space under the list.\n sx={{ ...SUBSCRIPTION_DIALOG_SX, '& .MuiDialog-paper': { ...DIALOG_PAPER_SX, pb: 16 } }}\n >\n <Stack>\n {reasons.map(({ label, userResponse }, index) => (\n <Stack key={userResponse}>\n <ButtonBase\n onClick={() => void save(userResponse)}\n sx={{\n gap: 12,\n justifyContent: 'space-between',\n minHeight: 44,\n px: 24,\n py: 8,\n textAlign: 'left',\n width: '100%',\n }}\n >\n <Text variant=\"body1\">{label}</Text>\n <Icon\n aria-hidden={true}\n name=\"chevron_right\"\n size={24}\n sx={{ color: 'action.active' }}\n />\n </ButtonBase>\n {/* Between rows only, drawn over the row edge (as Figma) so rows stay 44px apart. */}\n {index < reasons.length - 1 && <Divider sx={{ ml: 24, mt: '-1px' }} />}\n </Stack>\n ))}\n </Stack>\n </Dialog>\n\n {notice && noticeMessage && (\n <StatusSnackbar\n actionText={notice.retry ? word(copy.try_again) : undefined}\n closeAriaLabel={word(copy.toast_close_aria) ?? closeLabel}\n message={noticeMessage}\n onActionClick={notice.retry ? () => void save(notice.retry as string) : undefined}\n onClose={finish}\n open={true}\n severity={notice.severity}\n variant=\"strong\"\n />\n )}\n </>\n )\n})\n\nexport default SubscriptionStatusModalBlock\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAM,KAAgB,IAGhB,IAAkB;AAAA,EACtB,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,WAAW,GAAiB,EAAA;AAC9B,GACM,IAAyB;AAAA,EAC7B,sBAAsB;AAAA,EACtB,4BAA4B,EAAE,GAAG,EAAE;AAAA,EACnC,6DAA6D;AAAA,IAAE,IAAI;AAAA,IAAI,IAAI;AAAA,EAAG;AAChF,GAGM,KAAU;AAAA,EACd,CAAC,oBAAoB,EAAc,gBAAgB;AAAA,EACnD,CAAC,aAAa,EAAc,SAAS;AAAA,EACrC,CAAC,qBAAqB,EAAc,iBAAiB;AACvD,GAGM,IAAA,CAAQ,MACZ,OAAO,KAAU,YAAY,EAAM,KAAK,IAAI,IAAQ,QASzC,KAA+B,GAAS,SAAsC,EACzF,MAAA,EAAA,GACmB;AACnB,QAAM,IAAS,EAAe,GACxB,EAAE,eAAA,GAAe,WAAA,EAAA,IAAc,EAAmB,GAClD,EAAE,cAAA,GAAc,mBAAA,EAAA,IAAsB,EAAmB,GACzD,IAAc,EAAe,GAC7B,CAAC,GAAO,CAAA,IAAY,EAAgB,SAAS,GAC7C,CAAC,GAAQ,CAAA,IAAa,EAAwB,IAAI,GAElD,IAAc,EAAO,EAAK,GAE1B,IAAS,EAAO,EAAK,GAErB,IAAO,GAAe,2BACtB,IAAU,EAAK,kBAGf,IAAU,GAAQ,QAAA,CAAS,CAAC,GAAK,CAAA,MAAkB;AACvD,UAAM,IAAQ,EAAK,IAAO,CAAA,CAAI;AAE9B,WAAO,IAAQ,CAAC;AAAA,MAAE,OAAA;AAAA,MAAO,cAAA;AAAA,IAAa,CAAC,IAAI,CAAC;AAAA,EAC9C,CAAC,GACK,IACJ,CAAC,CAAC,EAAK,GAAM,KAAK,KAClB,CAAC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O;AAAA,MACjB,SAAQ;AAAA,IACT,CAAA;AAAA,EAEH,EAAA,CAAA;AAEN,CAAC"}
|
|
1
|
+
{"version":3,"file":"SubscriptionStatusModalBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/SubscriptionStatusModalBlock.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport ButtonBase from '@mui/material/ButtonBase'\nimport Divider from '@mui/material/Divider'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { Text } from '@mxenabled/mxui'\n\nimport { Dialog, useGlobalCopyStore, useGlobalStore, useInsightsV2Store } from '../../common'\nimport { slot } from '../../core'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../core/utils/NumberFormatting'\nimport { useBeatActions } from '../beatActions'\nimport { WARNING_WASH_GRADIENT } from '../components/celebrationGradients'\nimport LogoFromGuid from '../components/LogoFromGuid'\nimport { ELEVATION_SHADOW } from '../components/shared/elevation'\nimport StatusSnackbar from '../components/shared/StatusSnackbar'\nimport { subscriptionFrequency } from '../components/SubscriptionStatus/subscriptionFrequency'\nimport TransactionListCard from '../components/TransactionListCard'\nimport {\n answerSubscription,\n repeatingTransactionOf,\n reportSubscriptionMarkedIncorrect,\n USER_RESPONSE,\n} from '../ctaActions/subscriptionAnswer'\nimport type { ActionBlockProps } from '../mappings/blocks'\nimport { asLogoRef } from '../blocks/slotReaders'\nimport { useOpenedCta } from './useOpenedCta'\n\nconst ROW_LOGO_SIZE = 32\n\n// Figma dialog: paper, 4px radius, elevation/16.\nconst DIALOG_PAPER_SX = {\n backgroundColor: 'background.paper',\n borderRadius: 1,\n boxShadow: ELEVATION_SHADOW[16],\n}\nconst SUBSCRIPTION_DIALOG_SX = {\n '& .MuiDialog-paper': DIALOG_PAPER_SX,\n '& .MuiDialogContent-root': { p: 0 },\n '& .MuiDialogContent-root ~ .MuiStack-root .MuiButton-root': { px: 16, py: 12 },\n}\n\n// The reasons in Figma order; a reason with no word drops its row.\nconst REASONS = [\n ['never_subscribed', USER_RESPONSE.NEVER_SUBSCRIBED],\n ['cancelled', USER_RESPONSE.CANCELLED],\n ['one_time_purchase', USER_RESPONSE.ONE_TIME_PURCHASE],\n] as const\n\n/** A non-empty word, or undefined. */\nconst word = (value?: string): string | undefined =>\n typeof value === 'string' && value.trim() ? value : undefined\n\ntype Phase = 'answers' | 'reasons' | 'saving' | 'done'\ninterface Notice {\n severity: 'success' | 'error'\n retry?: string\n}\n\n/** Unexpected Subscription Payment's Subscription Status modal. */\nexport const SubscriptionStatusModalBlock = observer(function SubscriptionStatusModalBlock({\n beat,\n}: ActionBlockProps) {\n const stores = useGlobalStore()\n const { insights_feed, recurring } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const cta = useOpenedCta(beat)\n const beatActions = useBeatActions()\n const [phase, setPhase] = useState<Phase>('answers')\n const [notice, setNotice] = useState<Notice | null>(null)\n // The Dialog calls onClose after its actions; keep the flow open.\n const actionTaken = useRef(false)\n // One save at a time: a double tap (a closing dialog is still clickable) or Try Again sends one PUT.\n const saving = useRef(false)\n\n const copy = insights_feed?.subscription_status_modal\n const payload = beat.insights_payload\n // Only the words needed to answer: the title, both answers and at least one reason. The rest\n // (snackbar words, close labels, reviewed_title, a key added later) never block the modal.\n const reasons = REASONS.flatMap(([key, userResponse]) => {\n const label = word(copy?.[key])\n\n return label ? [{ label, userResponse }] : []\n })\n const ready =\n !!word(copy?.title) &&\n !!word(copy?.subscribed_answer) &&\n !!word(copy?.not_subscribed_answer) &&\n reasons.length > 0\n // Copy loaded (insights_feed is there) but incomplete: say so and close, not a silent open drawer.\n const incomplete = !!insights_feed && !ready\n\n useEffect(() => {\n if (!incomplete) return\n console.warn(\n '[SubscriptionStatusModalBlock] subscription_status_modal is missing its title, answers or reasons; closing.',\n )\n closeActionDrawer()\n }, [incomplete, closeActionDrawer])\n\n if (!payload || !copy || !ready) return null\n\n const closeLabel =\n word(copy.close_aria) ??\n word(copy.toast_close_aria) ??\n word(insights_feed?.settings_menu?.close) ??\n ''\n const noticeMessage =\n notice && word(notice.severity === 'success' ? copy.success_message : copy.error_message)\n\n const ctx = { beat, stores, hostActions: beatActions }\n const row = cta?.drilldown_data ?? {}\n const logo = asLogoRef(slot(row, 'logo'))\n const title = slot<string>(row, 'primary_text')\n const amount = slot<number>(row, 'amount')\n\n const save = async (userResponse: string) => {\n if (saving.current) return\n saving.current = true\n setNotice(null)\n setPhase('saving')\n try {\n await answerSubscription(ctx, userResponse)\n // No snackbar word: the save stands, the flow just ends without the snackbar.\n if (word(copy.success_message)) setNotice({ severity: 'success' })\n else finish()\n } catch {\n if (word(copy.error_message)) setNotice({ severity: 'error', retry: userResponse })\n else finish()\n } finally {\n saving.current = false\n }\n setPhase('done')\n }\n\n const finish = () => {\n setNotice(null)\n closeActionDrawer()\n }\n\n const chooseNotSubscribed = () => {\n actionTaken.current = true\n reportSubscriptionMarkedIncorrect(ctx)\n setPhase('reasons')\n }\n\n const chooseSubscribed = () => {\n actionTaken.current = true\n void save(USER_RESPONSE.CONFIRMED)\n }\n\n const closeAnswers = () => {\n if (actionTaken.current) {\n actionTaken.current = false\n return\n }\n finish()\n }\n\n return (\n <>\n <Dialog\n copy={{ title: copy.title, close_aria: closeLabel }}\n fullWidth={true}\n isOpen={phase === 'answers'}\n onClose={closeAnswers}\n onPrimaryAction={chooseSubscribed}\n onSecondaryAction={chooseNotSubscribed}\n primaryText={copy.subscribed_answer}\n secondaryText={copy.not_subscribed_answer}\n // Full-bleed wash between title and actions.\n sx={SUBSCRIPTION_DIALOG_SX}\n >\n {typeof title === 'string' && title && (\n <TransactionListCard\n background={WARNING_WASH_GRADIENT}\n elevated={true}\n rows={[\n {\n amount:\n typeof amount === 'number' ? formatCurrency(amount, CURRENCY_FORMAT.cents) : '',\n amountCaption: subscriptionFrequency(recurring, repeatingTransactionOf(ctx)),\n leading: logo ? <LogoFromGuid logo={logo} size={ROW_LOGO_SIZE} /> : undefined,\n subtitle: slot<string>(row, 'secondary_text') ?? '',\n title,\n },\n ]}\n />\n )}\n </Dialog>\n\n <Dialog\n copy={{ title: copy.title, close_aria: closeLabel }}\n fullWidth={true}\n isOpen={phase === 'reasons'}\n onClose={finish}\n showActions={false}\n // Space under the list.\n sx={{ ...SUBSCRIPTION_DIALOG_SX, '& .MuiDialog-paper': { ...DIALOG_PAPER_SX, pb: 16 } }}\n >\n <Stack>\n {reasons.map(({ label, userResponse }, index) => (\n <Stack key={userResponse}>\n <ButtonBase\n onClick={() => void save(userResponse)}\n sx={{\n gap: 12,\n justifyContent: 'space-between',\n minHeight: 44,\n px: 24,\n py: 8,\n textAlign: 'left',\n width: '100%',\n }}\n >\n <Text variant=\"body1\">{label}</Text>\n <Icon\n aria-hidden={true}\n name=\"chevron_right\"\n size={24}\n sx={{ color: 'action.active' }}\n />\n </ButtonBase>\n {/* Between rows only, drawn over the row edge (as Figma) so rows stay 44px apart. */}\n {index < reasons.length - 1 && <Divider sx={{ ml: 24, mt: '-1px' }} />}\n </Stack>\n ))}\n </Stack>\n </Dialog>\n\n {notice && noticeMessage && (\n <StatusSnackbar\n actionText={notice.retry ? word(copy.try_again) : undefined}\n closeAriaLabel={word(copy.toast_close_aria) ?? closeLabel}\n message={noticeMessage}\n onActionClick={notice.retry ? () => void save(notice.retry as string) : undefined}\n onClose={finish}\n open={true}\n severity={notice.severity}\n variant=\"strong\"\n />\n )}\n </>\n )\n})\n\nexport default SubscriptionStatusModalBlock\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAM,KAAgB,IAGhB,IAAkB;AAAA,EACtB,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,WAAW,GAAiB,EAAA;AAC9B,GACM,IAAyB;AAAA,EAC7B,sBAAsB;AAAA,EACtB,4BAA4B,EAAE,GAAG,EAAE;AAAA,EACnC,6DAA6D;AAAA,IAAE,IAAI;AAAA,IAAI,IAAI;AAAA,EAAG;AAChF,GAGM,KAAU;A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A,UACJ,IAAI;AAAA,UACJ,WAAW;AAAA,UACX,OAAO;AAAA,QACT;AAAA,QAVF,UAAA,CAYE,gBAAA,EAAC,IAAD;AAAA,UAAM,SAAQ;AAAA,UAAS,UAAA;AAAA,QAAY,CAAA,GACnC,gBAAA,EAAC,IAAD;AAAA,UACE,eAAa;AAAA,UACb,MAAK;AAAA,UACL,MAAM;AAAA,UACN,IAAI,EAAE,OAAO,gBAAgB;AAAA,QAC9B,CAAA,CACS;AAAA,MAEX,CAAA,GAAA,IAAQ,EAAQ,SAAS,KAAK,gBAAA,EAAC,IAAD,EAAS,IAAI;AAAA,QAAE,IAAI;AAAA,QAAI,IAAI;AAAA,MAAO,EAAI,CAAA,CAChE,EAAA,GAvBK,CAuBL,CACR,EACI,CAAA;AAAA,IACD,CAAA;AAAA,IAEP,KAAU,KACT,gBAAA,EAAC,IAAD;AAAA,MACE,YAAY,EAAO,QAAQ,EAAK,EAAK,SAAS,IAAI;AAAA,MAClD,gBAAgB,EAAK,EAAK,gBAAgB,KAAK;AAAA,MAC/C,SAAS;AAAA,MACT,eAAe,EAAO,QAAA,MAAA;AAAc,QAAK,EAAK,EAAO,KAAe;AAAA,UAAI;AAAA,MACxE,SAAS;AAAA,MACT,MAAM;AAAA,MACN,UAAU,EAAO;AAAA,MACjB,SAAQ;AAAA,IACT,CAAA;AAAA,EAEH,EAAA,CAAA;AAEN,CAAC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { useGlobalCopyStore as
|
|
2
|
-
import { useBeatActions as
|
|
3
|
-
import { resolveStep as
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { observer as
|
|
7
|
-
import { jsx as
|
|
8
|
-
var
|
|
9
|
-
const {
|
|
10
|
-
if (!
|
|
11
|
-
const
|
|
12
|
-
beat:
|
|
1
|
+
import { useGlobalCopyStore as b, useGlobalStore as v, useInsightsV2Store as y } from "../../common/context/hooks.es.js";
|
|
2
|
+
import { useBeatActions as _ } from "../beatActions.es.js";
|
|
3
|
+
import { resolveStep as d } from "../ctaActions/runCtaAction.es.js";
|
|
4
|
+
import g from "../components/SurveyModal.es.js";
|
|
5
|
+
import { useOpenedCta as S } from "./useOpenedCta.es.js";
|
|
6
|
+
import { observer as f } from "mobx-react-lite";
|
|
7
|
+
import { jsx as h } from "react/jsx-runtime";
|
|
8
|
+
var T = f(function({ beat: s }) {
|
|
9
|
+
const { closeActionDrawer: n } = y(), t = S(s), r = _(), a = b(), l = v(), i = s.insights_payload, e = a.insights_feed?.survey_modal;
|
|
10
|
+
if (!i || !e) return null;
|
|
11
|
+
const o = t && d({ cta: t }).surveyAnswer?.({
|
|
12
|
+
beat: s,
|
|
13
13
|
stores: l,
|
|
14
14
|
hostActions: r
|
|
15
|
-
}, e),
|
|
15
|
+
}, e), c = {
|
|
16
16
|
title: e.title,
|
|
17
17
|
options: [{
|
|
18
18
|
overline: e.yes_overline,
|
|
@@ -26,30 +26,30 @@ var B = h(function({ beat: t }) {
|
|
|
26
26
|
submitText: e.submit,
|
|
27
27
|
closeAriaLabel: e.close_aria,
|
|
28
28
|
reasonsTitle: e.reasons_title,
|
|
29
|
-
reasonOptions:
|
|
29
|
+
reasonOptions: o?.reasonOptions ?? Object.values(e.reason_options ?? {}),
|
|
30
30
|
backText: e.back,
|
|
31
31
|
characterLimitLabel: e.character_limit,
|
|
32
32
|
successMessage: e.success_message,
|
|
33
33
|
errorMessage: e.error_message,
|
|
34
34
|
tryAgainText: e.try_again,
|
|
35
35
|
toastCloseAriaLabel: e.toast_close_aria
|
|
36
|
-
},
|
|
37
|
-
beatGuid:
|
|
36
|
+
}, u = o?.onSubmit ?? ((m, p) => r.onSubmitFeedback?.({
|
|
37
|
+
beatGuid: i.guid,
|
|
38
38
|
source: "cta",
|
|
39
|
-
option:
|
|
40
|
-
detail:
|
|
39
|
+
option: m,
|
|
40
|
+
detail: p
|
|
41
41
|
}));
|
|
42
|
-
return /* @__PURE__ */
|
|
43
|
-
copy:
|
|
42
|
+
return /* @__PURE__ */ h(g, {
|
|
43
|
+
copy: c,
|
|
44
44
|
isOpen: !0,
|
|
45
45
|
onClose: () => n(),
|
|
46
|
-
onReasonsOpen:
|
|
47
|
-
onSubmit:
|
|
48
|
-
showDetailField:
|
|
46
|
+
onReasonsOpen: o?.onReasonsOpen,
|
|
47
|
+
onSubmit: u,
|
|
48
|
+
showDetailField: o?.showDetailField
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
51
|
export {
|
|
52
|
-
|
|
52
|
+
T as SurveyModalActionBlock
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
//# sourceMappingURL=SurveyModalActionBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SurveyModalActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/SurveyModalActionBlock.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport { useGlobalCopyStore, useGlobalStore, useInsightsV2Store } from '../../common'\nimport SurveyModal, { type SurveyModalContent } from '../components/SurveyModal'\nimport { useBeatActions } from '../beatActions'\nimport { resolveStep } from '../ctaActions'\nimport type { ActionBlockProps } from '../mappings/blocks'\nimport {
|
|
1
|
+
{"version":3,"file":"SurveyModalActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/SurveyModalActionBlock.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport { useGlobalCopyStore, useGlobalStore, useInsightsV2Store } from '../../common'\nimport SurveyModal, { type SurveyModalContent } from '../components/SurveyModal'\nimport { useBeatActions } from '../beatActions'\nimport { resolveStep } from '../ctaActions'\nimport type { ActionBlockProps } from '../mappings/blocks'\nimport { useOpenedCta } from './useOpenedCta'\n\n/**\n * `survey_modal_block` — the \"Does this look right?\" confirmation survey\n * (Figma `1941:212640`). Registered like any other drawer block; its content\n * is a MODAL (the dialog portals over the drawer).\n *\n * The survey has no action buttons — its rows act: the positive row submits\n * to the host via `beatActions.onSubmitFeedback` (source `cta`) and shows the\n * status snackbar; the negative row opens the FeedbackModal reasons dialog.\n * The session ends when the flow does (snackbar dismissed or dialogs closed).\n *\n * Copy comes from `insights_feed.survey_modal` in GlobalCopy.\n */\nexport const SurveyModalActionBlock = observer(function SurveyModalActionBlock({\n beat,\n}: ActionBlockProps) {\n const { closeActionDrawer } = useInsightsV2Store()\n const cta = useOpenedCta(beat)\n const beatActions = useBeatActions()\n const copyStore = useGlobalCopyStore()\n const stores = useGlobalStore()\n\n const insights_payload = beat.insights_payload\n const surveyCopy = copyStore.insights_feed?.survey_modal\n\n if (!insights_payload || !surveyCopy) return null\n\n const survey =\n cta &&\n resolveStep({ cta }).surveyAnswer?.({ beat, stores, hostActions: beatActions }, surveyCopy)\n\n const copy: SurveyModalContent = {\n title: surveyCopy.title,\n options: [\n { overline: surveyCopy.yes_overline, label: surveyCopy.yes_label, tone: 'positive' },\n { overline: surveyCopy.no_overline, label: surveyCopy.no_label, tone: 'negative' },\n ],\n submitText: surveyCopy.submit,\n\n closeAriaLabel: surveyCopy.close_aria,\n reasonsTitle: surveyCopy.reasons_title,\n reasonOptions: survey?.reasonOptions ?? Object.values(surveyCopy.reason_options ?? {}),\n backText: surveyCopy.back,\n characterLimitLabel: surveyCopy.character_limit,\n successMessage: surveyCopy.success_message,\n errorMessage: surveyCopy.error_message,\n tryAgainText: surveyCopy.try_again,\n toastCloseAriaLabel: surveyCopy.toast_close_aria,\n }\n\n // Returned (not just fired): a host promise rejection drives the modal's\n // error snackbar + Try Again retry. The session closes when the flow ends\n // (snackbar dismissed), not on submit.\n\n //TODO: Need to update the onSubmit functionality as per pulse. This function is mis-matching with the current approach of switchdirectdeposit and setupdirectdeposit\n const handleSubmit =\n survey?.onSubmit ??\n ((option: string, detail?: string) =>\n beatActions.onSubmitFeedback?.({\n beatGuid: insights_payload.guid,\n source: 'cta',\n option,\n detail,\n }))\n\n return (\n <SurveyModal\n copy={copy}\n isOpen={true}\n onClose={() => closeActionDrawer()}\n onReasonsOpen={survey?.onReasonsOp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Q,MAAA;AAAA,IACN,QAAQ;AAAA,IACR,SAAA,MAAe,EAAkB;AAAA,IACjC,eAAe,GAAQ;AAAA,IACvB,UAAU;AAAA,IACV,iBAAiB,GAAQ;AAAA,EAC1B,CAAA;AAEL,CAAC"}
|
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { useTransactionDetailsBlock as
|
|
4
|
-
import
|
|
1
|
+
import n from "../../../common/components/Loader.es.js";
|
|
2
|
+
import { BlockErrorMessage as e } from "../BlockErrorMessage.es.js";
|
|
3
|
+
import { useTransactionDetailsBlock as m } from "./useTransactionDetailsBlock.es.js";
|
|
4
|
+
import c from "../../../transactions/components/shared/TransactionDetails.es.js";
|
|
5
5
|
import { observer as f } from "mobx-react-lite";
|
|
6
|
-
import p from "@mui/material/Stack";
|
|
7
|
-
import { Text as d } from "@mxenabled/mxui";
|
|
8
6
|
import { jsx as o } from "react/jsx-runtime";
|
|
9
|
-
var
|
|
10
|
-
const {
|
|
11
|
-
return
|
|
12
|
-
bottomActions:
|
|
7
|
+
var T = f(function({ beat: t }) {
|
|
8
|
+
const { bottomActions: i, isLoading: a, topActions: s, transaction: r } = m(t);
|
|
9
|
+
return a ? /* @__PURE__ */ o(n, {}) : r ? /* @__PURE__ */ o(c, {
|
|
10
|
+
bottomActions: i,
|
|
13
11
|
shouldShowEmbeddedCard: !1,
|
|
14
|
-
topActions:
|
|
12
|
+
topActions: s,
|
|
15
13
|
transaction: r
|
|
16
|
-
}) : /* @__PURE__ */ o(
|
|
17
|
-
sx: { p: 24 },
|
|
18
|
-
children: /* @__PURE__ */ o(d, { children: i.error_message })
|
|
19
|
-
});
|
|
14
|
+
}) : /* @__PURE__ */ o(e, {});
|
|
20
15
|
});
|
|
21
16
|
export {
|
|
22
|
-
|
|
17
|
+
T as TransactionDetailsBlock
|
|
23
18
|
};
|
|
24
19
|
|
|
25
20
|
//# sourceMappingURL=TransactionDetailsBlock.es.js.map
|
package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/TransactionDetailsBlock.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionDetailsBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionDetailsBlock/TransactionDetailsBlock.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"TransactionDetailsBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionDetailsBlock/TransactionDetailsBlock.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport { Loader } from '../../../common'\nimport TransactionDetails from '../../../transactions/components/shared/TransactionDetails'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { BlockErrorMessage } from '../BlockErrorMessage'\n\nimport { useTransactionDetailsBlock } from './useTransactionDetailsBlock'\n\n/**\n * Single-transaction drawer content. The detail rendering and inline editing (category picker, date,\n * memo, tags, split/hide/merchant-budget) all live in the shared `TransactionDetails` component from\n * the transactions module — this block's job is only to resolve *which* transaction and *which*\n * actions, then hand off.\n *\n * `observer` is required: the resolved transaction comes from TransactionStore, and `usePrepare` may\n * still be loading it when this first renders. Without it the drawer would stay on the loader.\n */\nexport const TransactionDetailsBlock = observer(function TransactionDetailsBlock({\n beat,\n}: ActionBlockProps) {\n const { bottomActions, isLoading, topActions, transaction } = useTransactionDetailsBlock(beat)\n\n if (isLoading) return <Loader />\n\n // Stale beat: its transaction was deleted or is out of window.\n if (!transaction) {\n return <BlockErrorMessage />\n }\n\n return (\n <TransactionDetails\n bottomActions={bottomActions}\n // Embedded insight card is a PFM-only concern (TransactionDetails defaults to true); this beat's own drawer must not show a redundant embedded card of itself.\n shouldShowEmbeddedCard={false}\n topActions={topActions}\n transaction={transaction}\n />\n )\n})\n"],"mappings":";;;;;;AAkBA,IAAa,IAA0B,EAAS,SAAiC,EAC/E,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,eAAA,GAAe,WAAA,GAAW,YAAA,GAAY,aAAA,EAAA,IAAgB,EAA2B,CAAI;AAE7F,SAAI,IAAkB,gBAAA,EAAC,GAAD,CAAS,CAAA,IAG1B,IAKH,gBAAA,EAAC,GAAD;AAAA,IACiB,eAAA;AAAA,IAEf,wBAAwB;AAAA,IACZ,YAAA;AAAA,IACC,aAAA;AAAA,EACd,CAAA,IAVM,gBAAA,EAAC,GAAD,CAAoB,CAAA;AAY/B,CAAC"}
|