@mx-cartographer/experiences 9.7.131 → 9.7.133
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 +9 -0
- package/dist/core/utils/NumberFormatting.d.ts +6 -0
- package/dist/core/utils/NumberFormatting.es.js +20 -16
- package/dist/core/utils/NumberFormatting.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js +17 -17
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js +38 -38
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationContent.es.js +14 -14
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationContent.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js +26 -26
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/SavingsCalculator.es.js +22 -22
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/SavingsCalculator.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.es.js +47 -47
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/OverdraftBlock/OverdraftBlock.es.js +18 -18
- package/dist/insights-v2/actionBlocks/OverdraftBlock/OverdraftBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js +28 -28
- package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js +57 -56
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +50 -50
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +2 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +52 -51
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js +17 -17
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js +20 -20
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js +25 -25
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js +17 -16
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js +34 -34
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleProgressBarBlock/ProgressBar.es.js +7 -7
- package/dist/insights-v2/blocks/ChartBlocks/DoubleProgressBarBlock/ProgressBar.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/WithText.es.js +13 -13
- package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/WithText.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +39 -39
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js +20 -20
- package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js +44 -44
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js +14 -14
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/GasPurchaseBlock/GasPurchaseBlock.es.js +8 -8
- package/dist/insights-v2/blocks/ComponentBlocks/GasPurchaseBlock/GasPurchaseBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/GoalsBlock/GoalsBlock.es.js +25 -25
- package/dist/insights-v2/blocks/ComponentBlocks/GoalsBlock/GoalsBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +39 -46
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/RepeatingTransactionBlock/RepeatingTransactionBlock.es.js +18 -18
- package/dist/insights-v2/blocks/ComponentBlocks/RepeatingTransactionBlock/RepeatingTransactionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js +19 -19
- package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.es.js +9 -9
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js +12 -12
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +58 -57
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/UpcomingSubscriptionBlock/UpcomingSubscriptionBlock.es.js +18 -18
- package/dist/insights-v2/blocks/ComponentBlocks/UpcomingSubscriptionBlock/UpcomingSubscriptionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js +10 -10
- package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ImageBlocks/ImageBlock.es.js +13 -13
- package/dist/insights-v2/blocks/ImageBlocks/ImageBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/slotReaders.d.ts +3 -1
- package/dist/insights-v2/blocks/slotReaders.es.js +17 -6
- package/dist/insights-v2/blocks/slotReaders.es.js.map +1 -1
- package/dist/insights-v2/components/CompactInsightCard.es.js +44 -43
- package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
- package/dist/insights-v2/components/SaveAnExtraCard.es.js +6 -6
- package/dist/insights-v2/components/SaveAnExtraCard.es.js.map +1 -1
- package/dist/insights-v2/components/WithdrawalCard.es.js +20 -20
- package/dist/insights-v2/components/WithdrawalCard.es.js.map +1 -1
- package/dist/recurringtransactions/components/RecurrenceRow.es.js +102 -92
- package/dist/recurringtransactions/components/RecurrenceRow.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import v from "../../../common/utils/AccountDisplayName.es.js";
|
|
2
2
|
import { useAccountStore as l, useGlobalCopyStore as h } from "../../../common/context/hooks.es.js";
|
|
3
|
-
import {
|
|
4
|
-
import { resolveOverdraftFacts as
|
|
5
|
-
import { ConfidenceMeter as
|
|
6
|
-
import { useEffect as
|
|
3
|
+
import { CURRENCY_FORMAT as x, formatCurrency as g } from "../../../core/utils/NumberFormatting.es.js";
|
|
4
|
+
import { resolveOverdraftFacts as y, resolvePrimaryAccount as _ } from "./layout.es.js";
|
|
5
|
+
import { ConfidenceMeter as b } from "./ConfidenceMeter.es.js";
|
|
6
|
+
import { useEffect as C } from "react";
|
|
7
7
|
import { observer as I } from "mobx-react-lite";
|
|
8
8
|
import o from "@mui/material/Stack";
|
|
9
|
-
import { InstitutionLogo as
|
|
10
|
-
import { Icon as
|
|
11
|
-
import { Fragment as
|
|
12
|
-
var
|
|
9
|
+
import { InstitutionLogo as A, Text as e } from "@mxenabled/mxui";
|
|
10
|
+
import { Icon as F } from "@mxenabled/mx-icons";
|
|
11
|
+
import { Fragment as O, jsx as r, jsxs as t } from "react/jsx-runtime";
|
|
12
|
+
var G = ({ beat: s }) => {
|
|
13
13
|
const { accountsLoaded: n, loadAccounts: i } = l();
|
|
14
|
-
|
|
14
|
+
C(() => {
|
|
15
15
|
!s.primary_account && !n && i();
|
|
16
16
|
}, []);
|
|
17
|
-
},
|
|
17
|
+
}, L = I(function({ beat: n }) {
|
|
18
18
|
const { common: i, insights_feed: u } = h(), { accounts: f } = l(), c = u?.transparent_overdraft;
|
|
19
19
|
if (!c) return /* @__PURE__ */ r(o, {
|
|
20
20
|
sx: { p: 24 },
|
|
21
21
|
children: /* @__PURE__ */ r(e, { children: i?.error_message })
|
|
22
22
|
});
|
|
23
|
-
const a =
|
|
23
|
+
const a = _(n, f), m = a ? v(a) : "", { amount: p, confidence: d } = y(n);
|
|
24
24
|
return /* @__PURE__ */ t(o, {
|
|
25
25
|
sx: {
|
|
26
26
|
bgcolor: "background.paper",
|
|
@@ -40,7 +40,7 @@ var P = ({ beat: s }) => {
|
|
|
40
40
|
flexDirection: "row",
|
|
41
41
|
gap: 12
|
|
42
42
|
},
|
|
43
|
-
children: [/* @__PURE__ */ r(
|
|
43
|
+
children: [/* @__PURE__ */ r(A, {
|
|
44
44
|
alt: "",
|
|
45
45
|
institutionGuid: a?.institution_guid ?? "",
|
|
46
46
|
size: 20
|
|
@@ -55,7 +55,7 @@ var P = ({ beat: s }) => {
|
|
|
55
55
|
bold: !0,
|
|
56
56
|
component: "p",
|
|
57
57
|
variant: "h1",
|
|
58
|
-
children:
|
|
58
|
+
children: g(p, x.cents)
|
|
59
59
|
}),
|
|
60
60
|
/* @__PURE__ */ t(o, {
|
|
61
61
|
sx: {
|
|
@@ -63,7 +63,7 @@ var P = ({ beat: s }) => {
|
|
|
63
63
|
flexDirection: "row",
|
|
64
64
|
gap: 4
|
|
65
65
|
},
|
|
66
|
-
children: [/* @__PURE__ */ r(
|
|
66
|
+
children: [/* @__PURE__ */ r(F, {
|
|
67
67
|
"aria-hidden": "true",
|
|
68
68
|
fill: !0,
|
|
69
69
|
name: "error",
|
|
@@ -76,7 +76,7 @@ var P = ({ beat: s }) => {
|
|
|
76
76
|
})]
|
|
77
77
|
})
|
|
78
78
|
]
|
|
79
|
-
}), d !== void 0 && /* @__PURE__ */ t(
|
|
79
|
+
}), d !== void 0 && /* @__PURE__ */ t(O, { children: [/* @__PURE__ */ r(e, {
|
|
80
80
|
bold: !0,
|
|
81
81
|
component: "h3",
|
|
82
82
|
sx: {
|
|
@@ -86,15 +86,15 @@ var P = ({ beat: s }) => {
|
|
|
86
86
|
},
|
|
87
87
|
variant: "caption",
|
|
88
88
|
children: c.confidence_level
|
|
89
|
-
}), /* @__PURE__ */ r(
|
|
89
|
+
}), /* @__PURE__ */ r(b, {
|
|
90
90
|
copy: c,
|
|
91
91
|
level: d
|
|
92
92
|
})] })]
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
95
|
export {
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
L as OverdraftBlock,
|
|
97
|
+
G as useOverdraftPrepare
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
//# sourceMappingURL=OverdraftBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OverdraftBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/OverdraftBlock/OverdraftBlock.tsx"],"sourcesContent":["import { useEffect } from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useAccountStore, useGlobalCopyStore } from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\nimport type { ActionBlockProps } from '../../mappings/blocks'\n\nimport { ConfidenceMeter } from './ConfidenceMeter'\nimport { resolvePrimaryAccount, resolveOverdraftFacts } from './layout'\n\n/** Loads accounts once per open when the host did not attach the beat's primary account. */\nexport const useOverdraftPrepare = ({ beat }: ActionBlockProps) => {\n const { accountsLoaded, loadAccounts } = useAccountStore()\n\n useEffect(() => {\n if (!beat.primary_account && !accountsLoaded) void loadAccounts()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n}\n\n/**\n * Transparent Overdraft's \"Learn more\" drawer (MEW2-3355): the account at risk, the projected\n * overdraft amount, when it is expected, and the confidence meter. Everything is on the beat; the\n * account store is read only to name the account when the host did not attach it.\n */\nexport const OverdraftBlock = observer(function OverdraftBlock({ beat }: ActionBlockProps) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { accounts } = useAccountStore()\n const copy = insightsFeedCopy?.transparent_overdraft\n\n if (!copy) {\n return (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy?.error_message}</Text>\n </Stack>\n )\n }\n\n const account = resolvePrimaryAccount(beat, accounts)\n const accountName = account ? getAccountDisplayName(account) : ''\n const { amount, confidence } = resolveOverdraftFacts(beat)\n\n return (\n <Stack sx={{ bgcolor: 'background.paper', pb: 24 }}>\n <Stack sx={{ alignItems: 'center', gap: 4, px: 24, py: 16 }}>\n {accountName && (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 12 }}>\n <InstitutionLogo alt=\"\" institutionGuid={account?.institution_guid ?? ''} size={20} />\n <Text bold={true} component=\"p\" variant=\"body1\">\n {accountName}\n </Text>\n </Stack>\n )}\n {amount !== undefined && (\n <Text bold={true} component=\"p\" variant=\"h1\">\n {formatCurrency(amount,
|
|
1
|
+
{"version":3,"file":"OverdraftBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/OverdraftBlock/OverdraftBlock.tsx"],"sourcesContent":["import { useEffect } from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useAccountStore, useGlobalCopyStore } from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport type { ActionBlockProps } from '../../mappings/blocks'\n\nimport { ConfidenceMeter } from './ConfidenceMeter'\nimport { resolvePrimaryAccount, resolveOverdraftFacts } from './layout'\n\n/** Loads accounts once per open when the host did not attach the beat's primary account. */\nexport const useOverdraftPrepare = ({ beat }: ActionBlockProps) => {\n const { accountsLoaded, loadAccounts } = useAccountStore()\n\n useEffect(() => {\n if (!beat.primary_account && !accountsLoaded) void loadAccounts()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n}\n\n/**\n * Transparent Overdraft's \"Learn more\" drawer (MEW2-3355): the account at risk, the projected\n * overdraft amount, when it is expected, and the confidence meter. Everything is on the beat; the\n * account store is read only to name the account when the host did not attach it.\n */\nexport const OverdraftBlock = observer(function OverdraftBlock({ beat }: ActionBlockProps) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { accounts } = useAccountStore()\n const copy = insightsFeedCopy?.transparent_overdraft\n\n if (!copy) {\n return (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy?.error_message}</Text>\n </Stack>\n )\n }\n\n const account = resolvePrimaryAccount(beat, accounts)\n const accountName = account ? getAccountDisplayName(account) : ''\n const { amount, confidence } = resolveOverdraftFacts(beat)\n\n return (\n <Stack sx={{ bgcolor: 'background.paper', pb: 24 }}>\n <Stack sx={{ alignItems: 'center', gap: 4, px: 24, py: 16 }}>\n {accountName && (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 12 }}>\n <InstitutionLogo alt=\"\" institutionGuid={account?.institution_guid ?? ''} size={20} />\n <Text bold={true} component=\"p\" variant=\"body1\">\n {accountName}\n </Text>\n </Stack>\n )}\n {amount !== undefined && (\n <Text bold={true} component=\"p\" variant=\"h1\">\n {formatCurrency(amount, CURRENCY_FORMAT.cents)}\n </Text>\n )}\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 4 }}>\n <Icon\n aria-hidden=\"true\"\n fill={true}\n name=\"error\"\n size={16}\n sx={{ color: 'warning.main' }}\n />\n <Text color=\"text.secondary\" variant=\"body2\">\n {copy.to_occur_within_the_next_seven_days}\n </Text>\n </Stack>\n </Stack>\n {confidence !== undefined && (\n <>\n <Text\n bold={true}\n component=\"h3\"\n sx={{ px: 24, py: 12, textTransform: 'uppercase' }}\n variant=\"caption\"\n >\n {copy.confidence_level}\n </Text>\n <ConfidenceMeter copy={copy} level={confidence} />\n </>\n )}\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;AAiBA,IAAa,IAAA,CAAuB,EAAE,MAAA,EAAA,MAA6B;AACjE,QAAM,EAAE,gBAAA,GAAgB,cAAA,EAAA,IAAiB,EAAgB;AAEzD,EAAA,EAAA,MAAgB;AACd,IAAI,CAAC,EAAK,mBAAmB,C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M,WAAU;AAAA,UAAI,SAAQ;AAAA,UACrC,UAAA,EAAe,GAAQ,EAAgB,KAAK;AAAA,QACzC,CAAA;AAAA,QAER,gBAAA,EAAC,GAAD;AAAA,UAAO,IAAI;AAAA,YAAE,YAAY;AAAA,YAAU,eAAe;AAAA,YAAO,KAAK;AAAA,UAAE;AAAA,UAAhE,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,YACE,eAAY;AAAA,YACZ,MAAM;AAAA,YACN,MAAK;AAAA,YACL,MAAM;AAAA,YACN,IAAI,EAAE,OAAO,eAAe;AAAA,UAC7B,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,YAAM,OAAM;AAAA,YAAiB,SAAQ;AAAA,YAClC,UAAA,EAAK;AAAA,UACF,CAAA,CACD;AAAA;MACF;AAAA,IACN,CAAA,GAAA,MAAe,UACd,gBAAA,EAAA,GAAA,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,MACE,MAAM;AAAA,MACN,WAAU;AAAA,MACV,IAAI;AAAA,QAAE,IAAI;AAAA,QAAI,IAAI;AAAA,QAAI,eAAe;AAAA,MAAY;AAAA,MACjD,SAAQ;AAAA,MAEP,UAAA,EAAK;AAAA,IACF,CAAA,GACN,gBAAA,EAAC,GAAD;AAAA,MAAuB,MAAA;AAAA,MAAM,OAAO;AAAA,IAAa,CAAA,CACjD,EAAA,CAAA,CAEC;AAAA;AAEX,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { buildPluralCopy as
|
|
2
|
-
import { formatCurrency as
|
|
3
|
-
import { RAISED_CARD_SHADOW as
|
|
4
|
-
import { PAYMENT_INCREMENTS as
|
|
5
|
-
import
|
|
1
|
+
import { buildPluralCopy as y } from "../../../core/utils/Localization.es.js";
|
|
2
|
+
import { CURRENCY_FORMAT as d, formatCurrency as m } from "../../../core/utils/NumberFormatting.es.js";
|
|
3
|
+
import { RAISED_CARD_SHADOW as v } from "../../components/shared/elevation.es.js";
|
|
4
|
+
import { PAYMENT_INCREMENTS as x } from "./layout.es.js";
|
|
5
|
+
import u from "@mui/material/Stack";
|
|
6
6
|
import { Text as t } from "@mxenabled/mxui";
|
|
7
|
-
import { Icon as
|
|
8
|
-
import { Fragment as
|
|
9
|
-
import
|
|
10
|
-
var
|
|
7
|
+
import { Icon as C } from "@mxenabled/mx-icons";
|
|
8
|
+
import { Fragment as _, jsx as r, jsxs as n } from "react/jsx-runtime";
|
|
9
|
+
import g from "@mui/material/Box";
|
|
10
|
+
var p = ({ label: o, tone: a, value: e }) => /* @__PURE__ */ n(u, {
|
|
11
11
|
sx: {
|
|
12
12
|
flexDirection: "row",
|
|
13
13
|
justifyContent: "space-between"
|
|
@@ -25,14 +25,14 @@ var m = ({ label: o, tone: a, value: e }) => /* @__PURE__ */ n(p, {
|
|
|
25
25
|
variant: "body1",
|
|
26
26
|
children: e
|
|
27
27
|
})]
|
|
28
|
-
}),
|
|
29
|
-
const e = !!a, i = e ? "text.primary" : "text.secondary",
|
|
28
|
+
}), N = ({ copy: o, rows: a }) => {
|
|
29
|
+
const e = !!a, i = e ? "text.primary" : "text.secondary", b = a ?? x.map(() => {
|
|
30
30
|
});
|
|
31
|
-
return /* @__PURE__ */ n(
|
|
31
|
+
return /* @__PURE__ */ n(g, {
|
|
32
32
|
sx: {
|
|
33
33
|
bgcolor: e ? "background.paper" : "background.default",
|
|
34
34
|
borderRadius: "4px",
|
|
35
|
-
boxShadow: e ?
|
|
35
|
+
boxShadow: e ? v : "none",
|
|
36
36
|
transition: "background-color 0.5s, box-shadow 0.5s"
|
|
37
37
|
},
|
|
38
38
|
children: [/* @__PURE__ */ r(t, {
|
|
@@ -46,43 +46,43 @@ var m = ({ label: o, tone: a, value: e }) => /* @__PURE__ */ n(p, {
|
|
|
46
46
|
},
|
|
47
47
|
variant: "h3",
|
|
48
48
|
children: o.your_results
|
|
49
|
-
}),
|
|
50
|
-
const c = f
|
|
51
|
-
return /* @__PURE__ */ n(
|
|
49
|
+
}), b.map((l, f) => {
|
|
50
|
+
const c = x[f], s = l?.result.paymentCount ?? 0, h = s >= 1 ? y(o.month, o.months, s, String(s)) : "-";
|
|
51
|
+
return /* @__PURE__ */ n(u, {
|
|
52
52
|
sx: {
|
|
53
|
-
borderBottom:
|
|
53
|
+
borderBottom: f === b.length - 1 ? 0 : 1,
|
|
54
54
|
borderColor: "divider",
|
|
55
55
|
gap: 16,
|
|
56
56
|
px: 16,
|
|
57
57
|
py: 24
|
|
58
58
|
},
|
|
59
59
|
children: [
|
|
60
|
-
/* @__PURE__ */ r(
|
|
61
|
-
label: /* @__PURE__ */ n(
|
|
60
|
+
/* @__PURE__ */ r(p, {
|
|
61
|
+
label: /* @__PURE__ */ n(_, { children: [o.monthly_payment, c > 0 && /* @__PURE__ */ r(t, {
|
|
62
62
|
bold: !0,
|
|
63
63
|
color: "success.main",
|
|
64
64
|
component: "span",
|
|
65
65
|
variant: "caption",
|
|
66
|
-
children: ` +${
|
|
66
|
+
children: ` +${m(c, d.cents)}`
|
|
67
67
|
})] }),
|
|
68
68
|
tone: i,
|
|
69
|
-
value:
|
|
69
|
+
value: m(l?.monthlyPayment ?? 0, d.cents)
|
|
70
70
|
}),
|
|
71
|
-
/* @__PURE__ */ r(
|
|
71
|
+
/* @__PURE__ */ r(p, {
|
|
72
72
|
label: o.time_to_payoff,
|
|
73
73
|
tone: i,
|
|
74
|
-
value:
|
|
74
|
+
value: h
|
|
75
75
|
}),
|
|
76
|
-
/* @__PURE__ */ r(
|
|
76
|
+
/* @__PURE__ */ r(p, {
|
|
77
77
|
label: o.total_interest_paid,
|
|
78
78
|
tone: i,
|
|
79
|
-
value:
|
|
79
|
+
value: m(l?.result.totalInterestPaid ?? 0, d.cents)
|
|
80
80
|
})
|
|
81
81
|
]
|
|
82
82
|
}, c);
|
|
83
83
|
})]
|
|
84
84
|
});
|
|
85
|
-
}, j = ({ copy: o }) => /* @__PURE__ */ n(
|
|
85
|
+
}, j = ({ copy: o }) => /* @__PURE__ */ n(u, {
|
|
86
86
|
role: "alert",
|
|
87
87
|
sx: {
|
|
88
88
|
alignItems: "center",
|
|
@@ -93,7 +93,7 @@ var m = ({ label: o, tone: a, value: e }) => /* @__PURE__ */ n(p, {
|
|
|
93
93
|
textAlign: "center"
|
|
94
94
|
},
|
|
95
95
|
children: [
|
|
96
|
-
/* @__PURE__ */ r(
|
|
96
|
+
/* @__PURE__ */ r(C, {
|
|
97
97
|
"aria-hidden": "true",
|
|
98
98
|
fill: !0,
|
|
99
99
|
name: "error",
|
|
@@ -119,7 +119,7 @@ var m = ({ label: o, tone: a, value: e }) => /* @__PURE__ */ n(p, {
|
|
|
119
119
|
});
|
|
120
120
|
export {
|
|
121
121
|
j as CalculationFailed,
|
|
122
|
-
|
|
122
|
+
N as PayoffResults
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
//# sourceMappingURL=PayoffResults.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayoffResults.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { Text } from '@mxenabled/mxui'\n\nimport { buildPluralCopy } from '../../../common'\nimport type { PayoffCalculatorCopy } from '../../../core'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\n\nimport { RAISED_CARD_SHADOW } from '../../components/shared/elevation'\n\nimport { PAYMENT_INCREMENTS, type PayoffRow } from './layout'\n\ninterface ResultLineProps {\n label: React.ReactNode\n tone: 'text.primary' | 'text.secondary'\n value: string\n}\n\nconst ResultLine = ({ label, tone, value }: ResultLineProps) => (\n <Stack sx={{ flexDirection: 'row', justifyContent: 'space-between' }}>\n <Text color=\"text.secondary\" component=\"span\" variant=\"caption\">\n {label}\n </Text>\n <Text\n bold={true}\n color={tone}\n component=\"span\"\n sx={{ transition: 'color 0.5s' }}\n variant=\"body1\"\n >\n {value}\n </Text>\n </Stack>\n)\n\ninterface PayoffResultsProps {\n copy: PayoffCalculatorCopy\n /** Undefined until the user has calculated: the rows then show placeholders. */\n rows?: PayoffRow[]\n}\n\nexport const PayoffResults = ({ copy, rows }: PayoffResultsProps) => {\n const isCalculated = !!rows\n const tone = isCalculated ? 'text.primary' : 'text.secondary'\n const shown: Array<PayoffRow | undefined> = rows ?? PAYMENT_INCREMENTS.map(() => undefined)\n\n return (\n <Box\n sx={{\n bgcolor: isCalculated ? 'background.paper' : 'background.default',\n borderRadius: '4px',\n boxShadow: isCalculated ? RAISED_CARD_SHADOW : 'none',\n transition: 'background-color 0.5s, box-shadow 0.5s',\n }}\n >\n <Text\n bold={true}\n color={tone}\n component=\"h3\"\n sx={{ borderBottom: 1, borderColor: 'divider', p: 16 }}\n variant=\"h3\"\n >\n {copy.your_results}\n </Text>\n {shown.map((row, index) => {\n const increment = PAYMENT_INCREMENTS[index]\n const paymentCount = row?.result.paymentCount ?? 0\n const timeToPayoff =\n paymentCount >= 1\n ? (buildPluralCopy(\n copy.month,\n copy.months,\n paymentCount,\n String(paymentCount),\n ) as string)\n : '-'\n\n return (\n <Stack\n key={increment}\n sx={{\n borderBottom: index === shown.length - 1 ? 0 : 1,\n borderColor: 'divider',\n gap: 16,\n px: 16,\n py: 24,\n }}\n >\n <ResultLine\n label={\n <>\n {copy.monthly_payment}\n {increment > 0 && (\n <Text bold={true} color=\"success.main\" component=\"span\" variant=\"caption\">\n {` +${formatCurrency(increment,
|
|
1
|
+
{"version":3,"file":"PayoffResults.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { Text } from '@mxenabled/mxui'\n\nimport { buildPluralCopy } from '../../../common'\nimport type { PayoffCalculatorCopy } from '../../../core'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\n\nimport { RAISED_CARD_SHADOW } from '../../components/shared/elevation'\n\nimport { PAYMENT_INCREMENTS, type PayoffRow } from './layout'\n\ninterface ResultLineProps {\n label: React.ReactNode\n tone: 'text.primary' | 'text.secondary'\n value: string\n}\n\nconst ResultLine = ({ label, tone, value }: ResultLineProps) => (\n <Stack sx={{ flexDirection: 'row', justifyContent: 'space-between' }}>\n <Text color=\"text.secondary\" component=\"span\" variant=\"caption\">\n {label}\n </Text>\n <Text\n bold={true}\n color={tone}\n component=\"span\"\n sx={{ transition: 'color 0.5s' }}\n variant=\"body1\"\n >\n {value}\n </Text>\n </Stack>\n)\n\ninterface PayoffResultsProps {\n copy: PayoffCalculatorCopy\n /** Undefined until the user has calculated: the rows then show placeholders. */\n rows?: PayoffRow[]\n}\n\nexport const PayoffResults = ({ copy, rows }: PayoffResultsProps) => {\n const isCalculated = !!rows\n const tone = isCalculated ? 'text.primary' : 'text.secondary'\n const shown: Array<PayoffRow | undefined> = rows ?? PAYMENT_INCREMENTS.map(() => undefined)\n\n return (\n <Box\n sx={{\n bgcolor: isCalculated ? 'background.paper' : 'background.default',\n borderRadius: '4px',\n boxShadow: isCalculated ? RAISED_CARD_SHADOW : 'none',\n transition: 'background-color 0.5s, box-shadow 0.5s',\n }}\n >\n <Text\n bold={true}\n color={tone}\n component=\"h3\"\n sx={{ borderBottom: 1, borderColor: 'divider', p: 16 }}\n variant=\"h3\"\n >\n {copy.your_results}\n </Text>\n {shown.map((row, index) => {\n const increment = PAYMENT_INCREMENTS[index]\n const paymentCount = row?.result.paymentCount ?? 0\n const timeToPayoff =\n paymentCount >= 1\n ? (buildPluralCopy(\n copy.month,\n copy.months,\n paymentCount,\n String(paymentCount),\n ) as string)\n : '-'\n\n return (\n <Stack\n key={increment}\n sx={{\n borderBottom: index === shown.length - 1 ? 0 : 1,\n borderColor: 'divider',\n gap: 16,\n px: 16,\n py: 24,\n }}\n >\n <ResultLine\n label={\n <>\n {copy.monthly_payment}\n {increment > 0 && (\n <Text bold={true} color=\"success.main\" component=\"span\" variant=\"caption\">\n {` +${formatCurrency(increment, CURRENCY_FORMAT.cents)}`}\n </Text>\n )}\n </>\n }\n tone={tone}\n value={formatCurrency(row?.monthlyPayment ?? 0, CURRENCY_FORMAT.cents)}\n />\n <ResultLine label={copy.time_to_payoff} tone={tone} value={timeToPayoff} />\n <ResultLine\n label={copy.total_interest_paid}\n tone={tone}\n value={formatCurrency(row?.result.totalInterestPaid ?? 0, CURRENCY_FORMAT.cents)}\n />\n </Stack>\n )\n })}\n </Box>\n )\n}\n\nexport const CalculationFailed = ({ copy }: { copy: PayoffCalculatorCopy }) => (\n <Stack\n role=\"alert\"\n sx={{\n alignItems: 'center',\n bgcolor: 'background.default',\n borderRadius: '4px',\n px: 32,\n py: 40,\n textAlign: 'center',\n }}\n >\n <Icon aria-hidden=\"true\" fill={true} name=\"error\" size={24} sx={{ color: 'primary.main' }} />\n <Text bold={true} component=\"p\" sx={{ pb: 8, pt: 16 }} variant=\"body1\">\n {copy.calculation_failed}\n </Text>\n <Text component=\"p\" variant=\"body2\">\n {copy.calculation_failed_description}\n </Text>\n </Stack>\n)\n"],"mappings":";;;;;;;;;AAoBA,IAAM,IAAA,CAAc,EAAE,OAAA,GAAO,MAAA,GAAM,OAAA,EAAA,MACjC,gBAAA,EAAC,GAAD;AAAA,EAAO,IAAI;AAAA,IAAE,eAAe;AAAA,IAAO,gBAAgB;AAAA,EAAgB;AAAA,EAAnE,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,IAAM,OAAM;AAAA,IAAiB,WAAU;AAAA,IAAO,SAAQ;AAAA,IACnD,UAAA;AAAA,EACG,CAAA,GACN,gBAAA,EAAC,GAAD;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,IACP,WAAU;AAAA,IACV,IAAI,EAAE,YAAY,aAAa;AAAA,IAC/B,SAAQ;AAAA,IAEP,UAAA;AAAA,EACG,CAAA,CACD;IASI,IAAA,CAAiB,EAAE,MAAA,GAAM,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K,kBAAkB,GAAG,EAAgB,KAAK;AAAA,UACtE,CAAA;AAAA,UACD,gBAAA,EAAC,GAAD;AAAA,YAAY,OAAO,EAAK;AAAA,YAAsB,MAAA;AAAA,YAAM,OAAO;AAAA,UAAe,CAAA;AAAA,UAC1E,gBAAA,EAAC,GAAD;AAAA,YACE,OAAO,EAAK;AAAA,YACN,MAAA;AAAA,YACN,OAAO,EAAe,GAAK,OAAO,qBAAqB,GAAG,EAAgB,KAAK;AAAA,UAChF,CAAA;AAAA,QACI;AAAA,MA7BA,GAAA,CA6BA;AAAA,IAEX,CAAC,CACE;AAAA;AAET,GAEa,IAAA,CAAqB,EAAE,MAAA,EAAA,MAClC,gBAAA,EAAC,GAAD;AAAA,EACE,MAAK;AAAA,EACL,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,cAAc;AAAA,IACd,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,WAAW;AAAA,EACb;AAAA,EATF,UAAA;AAAA,IAWE,gBAAA,EAAC,GAAD;AAAA,MAAM,eAAY;AAAA,MAAO,MAAM;AAAA,MAAM,MAAK;AAAA,MAAQ,MAAM;AAAA,MAAI,IAAI,EAAE,OAAO,eAAe;AAAA,IAAI,CAAA;AAAA,IAC5F,gBAAA,EAAC,GAAD;AAAA,MAAM,MAAM;AAAA,MAAM,WAAU;AAAA,MAAI,IAAI;AAAA,QAAE,IAAI;AAAA,QAAG,IAAI;AAAA,MAAG;AAAA,MAAG,SAAQ;AAAA,MAC5D,UAAA,EAAK;AAAA,IACF,CAAA;AAAA,IACN,gBAAA,EAAC,GAAD;AAAA,MAAM,WAAU;AAAA,MAAI,SAAQ;AAAA,MACzB,UAAA,EAAK;AAAA,IACF,CAAA;AAAA,EACD"}
|
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import { useGlobalCopyStore as z, useGlobalStore as X, useInsightsV2Store as $ } from "../../common/context/hooks.es.js";
|
|
2
2
|
import { slot as d } from "../../core/types/Insights.es.js";
|
|
3
|
-
import {
|
|
3
|
+
import { CURRENCY_FORMAT as q, formatCurrency as Y } from "../../core/utils/NumberFormatting.es.js";
|
|
4
4
|
import N from "../../common/components/dialog/Dialog.es.js";
|
|
5
5
|
import { useBeatActions as Z } from "../beatActions.es.js";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
6
|
+
import { asLogoRef as J } from "../blocks/slotReaders.es.js";
|
|
7
|
+
import { USER_RESPONSE as f, answerSubscription as K, repeatingTransactionOf as Q, reportSubscriptionMarkedIncorrect as tt } from "../ctaActions/subscriptionAnswer.es.js";
|
|
8
|
+
import ot from "../components/LogoFromGuid.es.js";
|
|
8
9
|
import "../components/celebrationGradients.es.js";
|
|
9
|
-
import { ELEVATION_SHADOW as
|
|
10
|
-
import
|
|
11
|
-
import { subscriptionFrequency as
|
|
12
|
-
import
|
|
13
|
-
import { getDynamicCtaBasedOnTriggers as
|
|
14
|
-
import { useEffect as
|
|
15
|
-
import { observer as
|
|
10
|
+
import { ELEVATION_SHADOW as rt } from "../components/shared/elevation.es.js";
|
|
11
|
+
import et from "../components/TransactionListCard.es.js";
|
|
12
|
+
import { subscriptionFrequency as st } from "../components/SubscriptionStatus/subscriptionFrequency.es.js";
|
|
13
|
+
import it from "../components/shared/StatusSnackbar.es.js";
|
|
14
|
+
import { getDynamicCtaBasedOnTriggers as nt } from "./util.es.js";
|
|
15
|
+
import { useEffect as at, useRef as k, useState as T } from "react";
|
|
16
|
+
import { observer as ct } from "mobx-react-lite";
|
|
16
17
|
import B from "@mui/material/Stack";
|
|
17
|
-
import { Text as
|
|
18
|
-
import { Icon as
|
|
19
|
-
import { Fragment as
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
var
|
|
18
|
+
import { Text as lt } from "@mxenabled/mxui";
|
|
19
|
+
import { Icon as ut } from "@mxenabled/mx-icons";
|
|
20
|
+
import { Fragment as mt, jsx as r, jsxs as w } from "react/jsx-runtime";
|
|
21
|
+
import pt from "@mui/material/Divider";
|
|
22
|
+
import dt from "@mui/material/ButtonBase";
|
|
23
|
+
var ft = 32, G = {
|
|
23
24
|
backgroundColor: "background.paper",
|
|
24
25
|
borderRadius: 1,
|
|
25
|
-
boxShadow:
|
|
26
|
+
boxShadow: rt[16]
|
|
26
27
|
}, L = {
|
|
27
28
|
"& .MuiDialog-paper": G,
|
|
28
29
|
"& .MuiDialogContent-root": { p: 0 },
|
|
@@ -30,32 +31,32 @@ var pt = 32, G = {
|
|
|
30
31
|
px: 16,
|
|
31
32
|
py: 12
|
|
32
33
|
}
|
|
33
|
-
},
|
|
34
|
+
}, _t = [
|
|
34
35
|
["never_subscribed", f.NEVER_SUBSCRIBED],
|
|
35
36
|
["cancelled", f.CANCELLED],
|
|
36
37
|
["one_time_purchase", f.ONE_TIME_PURCHASE]
|
|
37
|
-
],
|
|
38
|
-
const P = X(), { insights_feed: _, recurring:
|
|
39
|
-
const p =
|
|
38
|
+
], o = (n) => typeof n == "string" && n.trim() ? n : void 0, Ft = ct(function({ beat: x }) {
|
|
39
|
+
const P = X(), { insights_feed: _, recurring: F } = z(), { actionDrawer: W, closeActionDrawer: g } = $(), U = Z(), [E, b] = T("answers"), [e, a] = T(null), c = k(!1), y = k(!1), t = _?.subscription_status_modal, l = x.insights_payload, S = _t.flatMap(([s, m]) => {
|
|
40
|
+
const p = o(t?.[s]);
|
|
40
41
|
return p ? [{
|
|
41
42
|
label: p,
|
|
42
43
|
userResponse: m
|
|
43
44
|
}] : [];
|
|
44
|
-
}),
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
}, [
|
|
48
|
-
const h =
|
|
49
|
-
beat:
|
|
45
|
+
}), O = !!o(t?.title) && !!o(t?.subscribed_answer) && !!o(t?.not_subscribed_answer) && S.length > 0, D = !!_ && !O;
|
|
46
|
+
if (at(() => {
|
|
47
|
+
D && (console.warn("[SubscriptionStatusModalBlock] subscription_status_modal is missing its title, answers or reasons; closing."), g());
|
|
48
|
+
}, [D, g]), !l || !t || !O) return null;
|
|
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: x,
|
|
50
51
|
stores: P,
|
|
51
|
-
hostActions:
|
|
52
|
-
}, u =
|
|
52
|
+
hostActions: U
|
|
53
|
+
}, u = nt(W, l.primary_cta, l.secondary_cta, l.in_description_cta)?.drilldown_data ?? {}, I = J(d(u, "logo")), A = d(u, "primary_text"), M = d(u, "amount"), C = async (s) => {
|
|
53
54
|
if (!y.current) {
|
|
54
55
|
y.current = !0, a(null), b("saving");
|
|
55
56
|
try {
|
|
56
|
-
await
|
|
57
|
+
await K(v, s), o(t.success_message) ? a({ severity: "success" }) : i();
|
|
57
58
|
} catch {
|
|
58
|
-
|
|
59
|
+
o(t.error_message) ? a({
|
|
59
60
|
severity: "error",
|
|
60
61
|
retry: s
|
|
61
62
|
}) : i();
|
|
@@ -66,10 +67,10 @@ var pt = 32, G = {
|
|
|
66
67
|
}
|
|
67
68
|
}, i = () => {
|
|
68
69
|
a(null), g();
|
|
69
|
-
},
|
|
70
|
-
c.current = !0,
|
|
70
|
+
}, H = () => {
|
|
71
|
+
c.current = !0, tt(v), b("reasons");
|
|
71
72
|
}, j = () => {
|
|
72
|
-
c.current = !0,
|
|
73
|
+
c.current = !0, C(f.CONFIRMED);
|
|
73
74
|
}, V = () => {
|
|
74
75
|
if (c.current) {
|
|
75
76
|
c.current = !1;
|
|
@@ -77,8 +78,8 @@ var pt = 32, G = {
|
|
|
77
78
|
}
|
|
78
79
|
i();
|
|
79
80
|
};
|
|
80
|
-
return /* @__PURE__ */
|
|
81
|
-
/* @__PURE__ */
|
|
81
|
+
return /* @__PURE__ */ w(mt, { children: [
|
|
82
|
+
/* @__PURE__ */ r(N, {
|
|
82
83
|
copy: {
|
|
83
84
|
title: t.title,
|
|
84
85
|
close_aria: h
|
|
@@ -87,26 +88,26 @@ var pt = 32, G = {
|
|
|
87
88
|
isOpen: E === "answers",
|
|
88
89
|
onClose: V,
|
|
89
90
|
onPrimaryAction: j,
|
|
90
|
-
onSecondaryAction:
|
|
91
|
+
onSecondaryAction: H,
|
|
91
92
|
primaryText: t.subscribed_answer,
|
|
92
93
|
secondaryText: t.not_subscribed_answer,
|
|
93
94
|
sx: L,
|
|
94
|
-
children: typeof A == "string" && A && /* @__PURE__ */
|
|
95
|
+
children: typeof A == "string" && A && /* @__PURE__ */ r(et, {
|
|
95
96
|
background: "linear-gradient(201deg, rgba(255, 170, 0, 0.25) 1.86%, rgba(255, 68, 0, 0.25) 101.54%)",
|
|
96
97
|
elevated: !0,
|
|
97
98
|
rows: [{
|
|
98
|
-
amount: typeof
|
|
99
|
-
amountCaption:
|
|
100
|
-
leading:
|
|
101
|
-
logo:
|
|
102
|
-
size:
|
|
99
|
+
amount: typeof M == "number" ? Y(M, q.cents) : "",
|
|
100
|
+
amountCaption: st(F, Q(v)),
|
|
101
|
+
leading: I ? /* @__PURE__ */ r(ot, {
|
|
102
|
+
logo: I,
|
|
103
|
+
size: ft
|
|
103
104
|
}) : void 0,
|
|
104
105
|
subtitle: d(u, "secondary_text") ?? "",
|
|
105
106
|
title: A
|
|
106
107
|
}]
|
|
107
108
|
})
|
|
108
109
|
}),
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
+
/* @__PURE__ */ r(N, {
|
|
110
111
|
copy: {
|
|
111
112
|
title: t.title,
|
|
112
113
|
close_aria: h
|
|
@@ -122,9 +123,9 @@ var pt = 32, G = {
|
|
|
122
123
|
pb: 16
|
|
123
124
|
}
|
|
124
125
|
},
|
|
125
|
-
children: /* @__PURE__ */
|
|
126
|
+
children: /* @__PURE__ */ r(B, { children: S.map(({ label: s, userResponse: m }, p) => /* @__PURE__ */ w(B, { children: [/* @__PURE__ */ w(dt, {
|
|
126
127
|
onClick: () => {
|
|
127
|
-
|
|
128
|
+
C(m);
|
|
128
129
|
},
|
|
129
130
|
sx: {
|
|
130
131
|
gap: 12,
|
|
@@ -135,26 +136,26 @@ var pt = 32, G = {
|
|
|
135
136
|
textAlign: "left",
|
|
136
137
|
width: "100%"
|
|
137
138
|
},
|
|
138
|
-
children: [/* @__PURE__ */
|
|
139
|
+
children: [/* @__PURE__ */ r(lt, {
|
|
139
140
|
variant: "body1",
|
|
140
141
|
children: s
|
|
141
|
-
}), /* @__PURE__ */
|
|
142
|
+
}), /* @__PURE__ */ r(ut, {
|
|
142
143
|
"aria-hidden": !0,
|
|
143
144
|
name: "chevron_right",
|
|
144
145
|
size: 24,
|
|
145
146
|
sx: { color: "action.active" }
|
|
146
147
|
})]
|
|
147
|
-
}), p < S.length - 1 && /* @__PURE__ */
|
|
148
|
+
}), p < S.length - 1 && /* @__PURE__ */ r(pt, { sx: {
|
|
148
149
|
ml: 24,
|
|
149
150
|
mt: "-1px"
|
|
150
151
|
} })] }, m)) })
|
|
151
152
|
}),
|
|
152
|
-
e &&
|
|
153
|
-
actionText: e.retry ?
|
|
154
|
-
closeAriaLabel:
|
|
155
|
-
message:
|
|
153
|
+
e && R && /* @__PURE__ */ r(it, {
|
|
154
|
+
actionText: e.retry ? o(t.try_again) : void 0,
|
|
155
|
+
closeAriaLabel: o(t.toast_close_aria) ?? h,
|
|
156
|
+
message: R,
|
|
156
157
|
onActionClick: e.retry ? () => {
|
|
157
|
-
|
|
158
|
+
C(e.retry);
|
|
158
159
|
} : void 0,
|
|
159
160
|
onClose: i,
|
|
160
161
|
open: !0,
|
|
@@ -164,8 +165,8 @@ var pt = 32, G = {
|
|
|
164
165
|
] });
|
|
165
166
|
});
|
|
166
167
|
export {
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
Ft as SubscriptionStatusModalBlock,
|
|
169
|
+
Ft as default
|
|
169
170
|
};
|
|
170
171
|
|
|
171
172
|
//# sourceMappingURL=SubscriptionStatusModalBlock.es.js.map
|
|
@@ -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 type { LogoRef } from '../../core'\nimport { 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 { 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 = slot<LogoRef>(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: typeof amount === 'number' ? formatCurrency(amount, '0,0.00') : '',\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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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
|
+
{"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,EAAw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