@mx-cartographer/experiences 9.7.29 → 9.7.31

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/core/types/localization/InsightsFeedCopy.d.ts +51 -0
  3. package/dist/core/types/localization/index.d.ts +1 -1
  4. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.d.ts +4 -0
  5. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js +80 -0
  6. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js.map +1 -0
  7. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/SavingsCalculator.d.ts +8 -0
  8. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/SavingsCalculator.es.js +138 -0
  9. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/SavingsCalculator.es.js.map +1 -0
  10. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/index.d.ts +1 -0
  11. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/layout.d.ts +52 -0
  12. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/layout.es.js +72 -0
  13. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/layout.es.js.map +1 -0
  14. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.d.ts +11 -0
  15. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js +132 -0
  16. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js.map +1 -0
  17. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.d.ts +12 -0
  18. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js +124 -0
  19. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js.map +1 -0
  20. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/index.d.ts +1 -0
  21. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/layout.d.ts +26 -0
  22. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/layout.es.js +64 -0
  23. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/layout.es.js.map +1 -0
  24. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/payoff.d.ts +8 -0
  25. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/payoff.es.js +26 -0
  26. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/payoff.es.js.map +1 -0
  27. package/dist/insights-v2/mappings/actionBlocksKey.d.ts +2 -0
  28. package/dist/insights-v2/mappings/actionBlocksKey.es.js +3 -1
  29. package/dist/insights-v2/mappings/actionBlocksKey.es.js.map +1 -1
  30. package/dist/insights-v2/mappings/blocks.es.js +85 -73
  31. package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
  32. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [9.7.31] - 10-22-2026
2
+
3
+ - **ADDED** - `emergency_savings_block` action block (savings calculator drawer) for Monthly Emergency Savings Reminder (MEW2-3352)
4
+
5
+ ## [9.7.30] - 10-22-2026
6
+
7
+ - **ADDED** - `payoff_calculator_block` action block: the credit card payoff calculator drawer behind Monthly Credit Card Interest Summary's "Learn how to save", ported from pulse. Prefills the beat account's balance, interest rate and minimum payment, validates the inputs and compares the payoff at that payment, $10 more and $20 more, with a failure state. Copy under the new `insights_feed.payoff_calculator` namespace; fixture, stories, tests and `docs/action-blocks/payoff-calculator-block.md` (MEW2-3357)
8
+
1
9
  ## [9.7.29] - 10-22-2026
2
10
 
3
11
  - **ADDED** - Designate Emergency Savings Account on Insights 2.0. `ctaConfig` gains the two backend-named actions: `select_savings_account` ("Save") designates the account picked in the card through `updateUserInsightProfile`, stays disabled until a pick is made, refreshes the beat and fires `EMERGENCY_SAVINGS_ACCT_SAVED`; `open_savings_account` ("Open a Savings Account") fires `EMERGENCY_SAVINGS_ACCT_CREATED` while `ctaPostMessages.DesignateEmergencySavingsAccount` sends `beat/cta` op_1 — now keyed on the CTA's `action_key` (`open_savings_account`) instead of re-deriving pulse's data rule (no designation, no savings accounts), so it holds on every widget. The analytics catalogue gains `EMERGENCY_SAVINGS_ACCT_SELECTED` / `_SAVED` / `_CREATED` with pulse's strings (WEC-1859)
@@ -247,6 +247,31 @@ export interface AmountInputModalCopy {
247
247
  /** Shown in the dialog when the save request fails; the value stays so Save can be retried. */
248
248
  save_error: string;
249
249
  }
250
+ export interface EmergencySavingsCopy {
251
+ total_savings_balance: string;
252
+ savings_goal: string;
253
+ how_to_get_there: string;
254
+ adjust_the_inputs_below_to_find_a_comfortable_amount: string;
255
+ how_often_can_you_contribute: string;
256
+ once_per_week: string;
257
+ every_other_week: string;
258
+ once_per_month: string;
259
+ every_three_months: string;
260
+ meet_your_goal_within: string;
261
+ days: string;
262
+ weeks: string;
263
+ months: string;
264
+ estimated_contribution: string;
265
+ week: string;
266
+ every_other_week_period: string;
267
+ month: string;
268
+ three_month_period: string;
269
+ calculate: string;
270
+ amount_in_savings: string;
271
+ step_one: string;
272
+ step_two: string;
273
+ final_step: string;
274
+ }
250
275
  /** Labels for the Debts component block; the values come pre-formatted off `instance_slot`. */
251
276
  export interface DebtsBlockCopy {
252
277
  balance_label: string;
@@ -265,12 +290,36 @@ export interface GoalsBlockCopy {
265
290
  total_saved_label: string;
266
291
  complete_label: string;
267
292
  }
293
+ /** The credit card payoff calculator drawer (`payoff_calculator_block`). */
294
+ export interface PayoffCalculatorCopy {
295
+ /** Drawer title, e.g. "Credit card payoff calculator". */
296
+ title: string;
297
+ description: string;
298
+ credit_card_balance: string;
299
+ interest_rate: string;
300
+ monthly_payment: string;
301
+ calculate: string;
302
+ your_results: string;
303
+ time_to_payoff: string;
304
+ total_interest_paid: string;
305
+ /** Time to payoff, `_1{number}` months: singular and plural. */
306
+ month: string;
307
+ months: string;
308
+ calculation_failed: string;
309
+ calculation_failed_description: string;
310
+ /** Validation messages; `_1{value}` is the field label and `_2{amount}` the bound. */
311
+ value_is_required: string;
312
+ value_must_be_a_number: string;
313
+ value_must_be_greater_than_or_equal_to: string;
314
+ value_must_be_less_than_or_equal_to: string;
315
+ }
268
316
  export interface InsightsFeedCopy {
269
317
  general: GeneralInsightsFeedCopy;
270
318
  settings_menu: SettingsMenuCopy;
271
319
  make_transfer: MakeTransferCopy;
272
320
  /** Optional until the localized-content service ships it; the drawer shows an error without it. */
273
321
  remaining_cash?: RemainingCashCopy;
322
+ emergency_savings?: EmergencySavingsCopy;
274
323
  overflow_menu: OverflowMenuCopy;
275
324
  transaction_history_block: TransactionHistoryBlock;
276
325
  hidden_confirmation: HiddenConfirmationCopy;
@@ -290,5 +339,7 @@ export interface InsightsFeedCopy {
290
339
  debts_block?: DebtsBlockCopy;
291
340
  /** Optional until the localized-content service ships the namespace. */
292
341
  goals_block?: GoalsBlockCopy;
342
+ /** Optional until the localized-content service ships the namespace. */
343
+ payoff_calculator?: PayoffCalculatorCopy;
293
344
  }
294
345
  export {};
@@ -13,7 +13,7 @@ export type { DebtsCopy } from './DebtsCopy';
13
13
  export type { FinstrongCopy } from './FinstrongCopy';
14
14
  export type { GoalsCopy } from './GoalsCopy';
15
15
  export type { HelpCopy, HelpByCategoryList } from './HelpCopy';
16
- export type { AmountInputModalCopy, AmountInputModalVariantCopy, InsightsFeedCopy, MakeTransferCopy, RemainingCashCopy, OverflowMenuCopy, DismissInsightCopy, DismissInsightOptionCopy, HiddenConfirmationCopy, HideFeedbackCopy, FeedbackCopy, FeedbackBarCopy, } from './InsightsFeedCopy';
16
+ export type { AmountInputModalCopy, AmountInputModalVariantCopy, EmergencySavingsCopy, InsightsFeedCopy, MakeTransferCopy, PayoffCalculatorCopy, RemainingCashCopy, OverflowMenuCopy, DismissInsightCopy, DismissInsightOptionCopy, HiddenConfirmationCopy, HideFeedbackCopy, FeedbackCopy, FeedbackBarCopy, } from './InsightsFeedCopy';
17
17
  export type { InvestmentsCopy } from './InvestmentsCopy';
18
18
  export type { MicroInsightsCopy } from './MicroInsightsCopy';
19
19
  export type { NetWorthCopy } from './NetWorthCopy';
@@ -0,0 +1,4 @@
1
+ import { ActionBlockProps } from '../../mappings/blocks';
2
+ export declare const EmergencySavingsBlock: (({ beat, }: ActionBlockProps) => import("react/jsx-runtime").JSX.Element) & {
3
+ displayName: string;
4
+ };
@@ -0,0 +1,80 @@
1
+ import { buildDynamicCopy as x } from "../../../core/utils/Localization.es.js";
2
+ import { useGlobalCopyStore as v } from "../../../common/context/hooks.es.js";
3
+ import { formatCurrency as c } from "../../../core/utils/NumberFormatting.es.js";
4
+ import { variants as _ } from "../../blocks/ChartBlocks/StepChartBlock/index.es.js";
5
+ import { stepForBalance as y } from "./layout.es.js";
6
+ import { SavingsCalculator as h } from "./SavingsCalculator.es.js";
7
+ import { observer as C } from "mobx-react-lite";
8
+ import e from "@mui/material/Stack";
9
+ import { Text as p } from "@mxenabled/mxui";
10
+ import { jsx as o, jsxs as n } from "react/jsx-runtime";
11
+ var m = ({ label: i, value: a }) => /* @__PURE__ */ n(e, {
12
+ "aria-label": i,
13
+ role: "group",
14
+ sx: {
15
+ border: "1px solid",
16
+ borderColor: "divider",
17
+ borderRadius: "8px",
18
+ flex: 1,
19
+ gap: 4,
20
+ p: 12
21
+ },
22
+ children: [/* @__PURE__ */ o(p, {
23
+ color: "text.secondary",
24
+ variant: "caption",
25
+ children: i
26
+ }), /* @__PURE__ */ o(p, {
27
+ bold: !0,
28
+ component: "p",
29
+ variant: "h3",
30
+ children: a
31
+ })]
32
+ }), A = C(function({ beat: a }) {
33
+ const { common: d, insights_feed: g } = v(), r = g?.emergency_savings;
34
+ if (!r) return /* @__PURE__ */ o(e, {
35
+ sx: { p: 24 },
36
+ children: /* @__PURE__ */ o(p, { children: d?.error_message })
37
+ });
38
+ const t = a.insights_payload?.drilldown_data?.savings_account_balance, l = typeof t == "number" && Number.isFinite(t) ? t : 0, { goal: s, index: u, labelKey: b } = y(l), { WithText: f } = _;
39
+ return /* @__PURE__ */ n(e, {
40
+ sx: {
41
+ bgcolor: "background.default",
42
+ gap: 24,
43
+ p: 24
44
+ },
45
+ children: [/* @__PURE__ */ n(e, {
46
+ sx: {
47
+ bgcolor: "background.paper",
48
+ borderRadius: "8px",
49
+ gap: 16,
50
+ p: 16
51
+ },
52
+ children: [/* @__PURE__ */ o(f, { slotData: {
53
+ completed_steps: u,
54
+ label_1: r[b].toUpperCase(),
55
+ label_2: x(r.amount_in_savings, c(s, "0"))
56
+ } }), /* @__PURE__ */ n(e, {
57
+ sx: {
58
+ flexDirection: "row",
59
+ gap: 12
60
+ },
61
+ children: [/* @__PURE__ */ o(m, {
62
+ label: r.total_savings_balance,
63
+ value: c(l, "0,0.00")
64
+ }), /* @__PURE__ */ o(m, {
65
+ label: r.savings_goal,
66
+ value: c(s, "0,0")
67
+ })]
68
+ })]
69
+ }), /* @__PURE__ */ o(h, {
70
+ balance: l,
71
+ copy: r,
72
+ goal: s
73
+ }, a.guid)]
74
+ });
75
+ });
76
+ export {
77
+ A as EmergencySavingsBlock
78
+ };
79
+
80
+ //# sourceMappingURL=EmergencySavingsBlock.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmergencySavingsBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useGlobalCopyStore } from '../../../common'\nimport { buildDynamicCopy } from '../../../core'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { variants as stepChartVariants } from '../../blocks/ChartBlocks/StepChartBlock'\nimport type { ActionBlockProps } from '../../mappings/blocks'\n\nimport { SavingsCalculator } from './SavingsCalculator'\nimport { stepForBalance } from './layout'\n\nconst AmountBox = ({ label, value }: { label: string; value: string }) => (\n <Stack\n aria-label={label}\n role=\"group\"\n sx={{\n border: '1px solid',\n borderColor: 'divider',\n borderRadius: '8px',\n flex: 1,\n gap: 4,\n p: 12,\n }}\n >\n <Text color=\"text.secondary\" variant=\"caption\">\n {label}\n </Text>\n <Text bold={true} component=\"p\" variant=\"h3\">\n {value}\n </Text>\n </Stack>\n)\n\nexport const EmergencySavingsBlock = observer(function EmergencySavingsBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const copy = insightsFeedCopy?.emergency_savings\n\n if (!copy) {\n return (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy?.error_message}</Text>\n </Stack>\n )\n }\n\n const raw = beat.insights_payload?.drilldown_data?.savings_account_balance\n const balance = typeof raw === 'number' && Number.isFinite(raw) ? raw : 0\n const { goal, index, labelKey } = stepForBalance(balance)\n const { WithText: Stepper } = stepChartVariants\n\n return (\n <Stack sx={{ bgcolor: 'background.default', gap: 24, p: 24 }}>\n <Stack sx={{ bgcolor: 'background.paper', borderRadius: '8px', gap: 16, p: 16 }}>\n <Stepper\n slotData={{\n completed_steps: index,\n label_1: copy[labelKey].toUpperCase(),\n label_2: buildDynamicCopy(copy.amount_in_savings, formatCurrency(goal, '0')) as string,\n }}\n />\n <Stack sx={{ flexDirection: 'row', gap: 12 }}>\n <AmountBox label={copy.total_savings_balance} value={formatCurrency(balance, '0,0.00')} />\n <AmountBox label={copy.savings_goal} value={formatCurrency(goal, '0,0')} />\n </Stack>\n </Stack>\n <SavingsCalculator balance={balance} copy={copy} goal={goal} key={beat.guid} />\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;AAcA,IAAM,IAAA,CAAa,EAAE,OAAA,GAAO,OAAA,EAAA,MAC1B,gBAAA,EAAC,GAAD;AAAA,EACE,cAAY;AAAA,EACZ,MAAK;AAAA,EACL,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,cAAc;AAAA,IACd,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AAA,MAC7E,EACD,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,QAAO,IAAI;AAAA,UAAE,eAAe;AAAA,UAAO,KAAK;AAAA,QAAG;AAAA,QAA3C,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,UAAW,OAAO,EAAK;AAAA,UAAuB,OAAO,EAAe,GAAS,QAAQ;AAAA,QAAI,CAAA,GACzF,gBAAA,EAAC,GAAD;AAAA,UAAW,OAAO,EAAK;AAAA,UAAc,OAAO,EAAe,GAAM,KAAK;AAAA,QAAI,CAAA,CACrE;AAAA,MACF,CAAA,CAAA;AAAA,IACP,CAAA,GAAA,gBAAA,EAAC,GAAD;AAAA,MAA4B,SAAA;AAAA,MAAe,MAAA;AAAA,MAAY,MAAA;AAAA,IAAuB,GAAZ,EAAK,IAAO,CACzE;AAAA;AAEX,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { EmergencySavingsCopy } from '../../../core';
2
+ interface SavingsCalculatorProps {
3
+ balance: number;
4
+ goal: number;
5
+ copy: EmergencySavingsCopy;
6
+ }
7
+ export declare const SavingsCalculator: ({ balance, copy, goal }: SavingsCalculatorProps) => import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,138 @@
1
+ import { formatCurrency as E } from "../../../core/utils/NumberFormatting.es.js";
2
+ import { Select as g } from "../../../common/components/Select.es.js";
3
+ import { CADENCES as v, DEADLINE_UNITS as _, calculateContribution as A } from "./layout.es.js";
4
+ import i from "react";
5
+ import l from "@mui/material/Stack";
6
+ import { Text as d } from "@mxenabled/mxui";
7
+ import L from "@mui/material/Button";
8
+ import { jsx as a, jsxs as r } from "react/jsx-runtime";
9
+ import f from "@mui/material/TextField";
10
+ var U = 2, j = 2, M = "6", x = (o) => {
11
+ const [e, ...s] = o.replace(/[^0-9.]/g, "").split(".");
12
+ return s.length ? `${e}.${s.join("")}` : e;
13
+ }, S = (o) => o === "" ? NaN : Number(o), I = { htmlInput: {
14
+ inputMode: "decimal",
15
+ pattern: "[0-9]*[.]?[0-9]*"
16
+ } }, O = ({ balance: o, copy: e, goal: s }) => {
17
+ const [c, C] = i.useState(String(s)), [m, N] = i.useState(U), [p, D] = i.useState(j), [h, w] = i.useState(M), [u, T] = i.useState();
18
+ return /* @__PURE__ */ r(l, {
19
+ component: "form",
20
+ onSubmit: (t) => {
21
+ t.preventDefault();
22
+ const n = v[m], b = A({
23
+ balance: o,
24
+ goal: S(c),
25
+ cadence: n,
26
+ deadline: _[p],
27
+ deadlineQuantity: S(h)
28
+ });
29
+ T(b === void 0 ? void 0 : {
30
+ amount: b,
31
+ period: e[n.periodKey]
32
+ });
33
+ },
34
+ sx: {
35
+ bgcolor: "background.paper",
36
+ borderRadius: "8px",
37
+ gap: 24,
38
+ p: 16
39
+ },
40
+ children: [
41
+ /* @__PURE__ */ r(l, {
42
+ sx: { gap: 8 },
43
+ children: [/* @__PURE__ */ a(d, {
44
+ component: "h3",
45
+ variant: "h3",
46
+ children: e.how_to_get_there
47
+ }), /* @__PURE__ */ a(d, {
48
+ color: "text.secondary",
49
+ truncate: !1,
50
+ variant: "body2",
51
+ children: e.adjust_the_inputs_below_to_find_a_comfortable_amount
52
+ })]
53
+ }),
54
+ /* @__PURE__ */ a(f, {
55
+ fullWidth: !0,
56
+ label: e.savings_goal,
57
+ onChange: (t) => C(x(t.target.value)),
58
+ slotProps: I,
59
+ value: c
60
+ }),
61
+ /* @__PURE__ */ a(g, {
62
+ label: e.how_often_can_you_contribute,
63
+ onChange: N,
64
+ options: v.map(({ labelKey: t }, n) => ({
65
+ id: n,
66
+ label: e[t]
67
+ })),
68
+ value: m
69
+ }),
70
+ /* @__PURE__ */ r(l, {
71
+ sx: {
72
+ flexDirection: "row",
73
+ gap: 8
74
+ },
75
+ children: [/* @__PURE__ */ a(f, {
76
+ fullWidth: !0,
77
+ label: e.meet_your_goal_within,
78
+ onChange: (t) => w(x(t.target.value)),
79
+ slotProps: I,
80
+ value: h
81
+ }), /* @__PURE__ */ a(g, {
82
+ inputProps: { "aria-label": e.meet_your_goal_within },
83
+ label: "",
84
+ onChange: D,
85
+ options: _.map(({ labelKey: t }, n) => ({
86
+ id: n,
87
+ label: e[t]
88
+ })),
89
+ sx: { minWidth: 128 },
90
+ value: p
91
+ })]
92
+ }),
93
+ u && /* @__PURE__ */ r(l, {
94
+ role: "status",
95
+ sx: {
96
+ alignItems: "center",
97
+ border: "1px solid",
98
+ borderColor: "divider",
99
+ borderRadius: "8px",
100
+ gap: 4,
101
+ p: 12
102
+ },
103
+ children: [/* @__PURE__ */ a(d, {
104
+ bold: !0,
105
+ variant: "body1",
106
+ children: e.estimated_contribution
107
+ }), /* @__PURE__ */ r(l, {
108
+ sx: {
109
+ alignItems: "baseline",
110
+ flexDirection: "row",
111
+ gap: 8
112
+ },
113
+ children: [/* @__PURE__ */ a(d, {
114
+ bold: !0,
115
+ color: "success.main",
116
+ component: "p",
117
+ variant: "h2",
118
+ children: E(u.amount, "0,0.00")
119
+ }), /* @__PURE__ */ r(d, {
120
+ variant: "body1",
121
+ children: ["/ ", u.period.toLowerCase()]
122
+ })]
123
+ })]
124
+ }),
125
+ /* @__PURE__ */ a(L, {
126
+ fullWidth: !0,
127
+ type: "submit",
128
+ variant: "contained",
129
+ children: e.calculate
130
+ })
131
+ ]
132
+ });
133
+ };
134
+ export {
135
+ O as SavingsCalculator
136
+ };
137
+
138
+ //# sourceMappingURL=SavingsCalculator.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SavingsCalculator.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/EmergencySavingsBlock/SavingsCalculator.tsx"],"sourcesContent":["import React from 'react'\n\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { Select } from '../../../common'\nimport type { EmergencySavingsCopy } from '../../../core'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\n\nimport { CADENCES, DEADLINE_UNITS, calculateContribution } from './layout'\n\nconst MONTHLY = 2\nconst MONTHS = 2\nconst DEFAULT_DEADLINE_QUANTITY = '6'\n\nconst toDecimalInput = (value: string) => {\n const [whole, ...fraction] = value.replace(/[^0-9.]/g, '').split('.')\n\n return fraction.length ? `${whole}.${fraction.join('')}` : whole\n}\n\nconst toNumber = (input: string) => (input === '' ? Number.NaN : Number(input))\n\nconst NUMERIC_INPUT = { htmlInput: { inputMode: 'decimal', pattern: '[0-9]*[.]?[0-9]*' } } as const\n\ninterface SavingsCalculatorProps {\n balance: number\n goal: number\n copy: EmergencySavingsCopy\n}\n\ninterface Solution {\n amount: number\n period: string\n}\n\nexport const SavingsCalculator = ({ balance, copy, goal }: SavingsCalculatorProps) => {\n const [savingsGoal, setSavingsGoal] = React.useState(String(goal))\n const [cadenceIndex, setCadenceIndex] = React.useState(MONTHLY)\n const [deadlineIndex, setDeadlineIndex] = React.useState(MONTHS)\n const [deadlineQuantity, setDeadlineQuantity] = React.useState(DEFAULT_DEADLINE_QUANTITY)\n const [solution, setSolution] = React.useState<Solution>()\n\n const handleSubmit = (event: React.FormEvent) => {\n event.preventDefault()\n\n const cadence = CADENCES[cadenceIndex]\n const amount = calculateContribution({\n balance,\n goal: toNumber(savingsGoal),\n cadence,\n deadline: DEADLINE_UNITS[deadlineIndex],\n deadlineQuantity: toNumber(deadlineQuantity),\n })\n\n setSolution(amount === undefined ? undefined : { amount, period: copy[cadence.periodKey] })\n }\n\n return (\n <Stack\n component=\"form\"\n onSubmit={handleSubmit}\n sx={{ bgcolor: 'background.paper', borderRadius: '8px', gap: 24, p: 16 }}\n >\n <Stack sx={{ gap: 8 }}>\n <Text component=\"h3\" variant=\"h3\">\n {copy.how_to_get_there}\n </Text>\n <Text color=\"text.secondary\" truncate={false} variant=\"body2\">\n {copy.adjust_the_inputs_below_to_find_a_comfortable_amount}\n </Text>\n </Stack>\n <TextField\n fullWidth={true}\n label={copy.savings_goal}\n onChange={(event) => setSavingsGoal(toDecimalInput(event.target.value))}\n slotProps={NUMERIC_INPUT}\n value={savingsGoal}\n />\n <Select\n label={copy.how_often_can_you_contribute}\n onChange={setCadenceIndex}\n options={CADENCES.map(({ labelKey }, id) => ({ id, label: copy[labelKey] }))}\n value={cadenceIndex}\n />\n <Stack sx={{ flexDirection: 'row', gap: 8 }}>\n <TextField\n fullWidth={true}\n label={copy.meet_your_goal_within}\n onChange={(event) => setDeadlineQuantity(toDecimalInput(event.target.value))}\n slotProps={NUMERIC_INPUT}\n value={deadlineQuantity}\n />\n <Select\n inputProps={{ 'aria-label': copy.meet_your_goal_within }}\n label=\"\"\n onChange={setDeadlineIndex}\n options={DEADLINE_UNITS.map(({ labelKey }, id) => ({ id, label: copy[labelKey] }))}\n sx={{ minWidth: 128 }}\n value={deadlineIndex}\n />\n </Stack>\n {solution && (\n <Stack\n role=\"status\"\n sx={{\n alignItems: 'center',\n border: '1px solid',\n borderColor: 'divider',\n borderRadius: '8px',\n gap: 4,\n p: 12,\n }}\n >\n <Text bold={true} variant=\"body1\">\n {copy.estimated_contribution}\n </Text>\n <Stack sx={{ alignItems: 'baseline', flexDirection: 'row', gap: 8 }}>\n <Text bold={true} color=\"success.main\" component=\"p\" variant=\"h2\">\n {formatCurrency(solution.amount, '0,0.00')}\n </Text>\n <Text variant=\"body1\">/ {solution.period.toLowerCase()}</Text>\n </Stack>\n </Stack>\n )}\n <Button fullWidth={true} type=\"submit\" variant=\"contained\">\n {copy.calculate}\n </Button>\n </Stack>\n )\n}\n"],"mappings":";;;;;;;;;AAcA,IAAM,IAAU,GACV,IAAS,GACT,IAA4B,KAE5B,IAAA,CAAkB,MAAkB;AACxC,QAAM,CAAC,GAAO,GAAG,CAAA,IAAY,EAAM,QAAQ,YAAY,EAAE,EAAE,MAAM,GAAG;AAEpE,SAAO,EAAS,SAAS,GAAG,CAAA,IAAS,EAAS,KAAK,EAAE,CAAA,KAAM;AAC7D,GAEM,IAAA,CAAY,MAAmB,MAAU,KAAK,MAAa,OAAO,CAAK,GAEvE,IAAgB,EAAE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AAAA,QACL;AAAA,QATF,UAAA,CAWE,gBAAA,EAAC,GAAD;AAAA,UAAM,MAAM;AAAA,UAAM,SAAQ;AAAA,UACvB,UAAA,EAAK;AAAA,QACF,CAAA,GACN,gBAAA,EAAC,GAAD;AAAA,UAAO,IAAI;AAAA,YAAE,YAAY;AAAA,YAAY,eAAe;AAAA,YAAO,KAAK;AAAA,UAAE;AAAA,UAAlE,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,YAAM,MAAM;AAAA,YAAM,OAAM;AAAA,YAAe,WAAU;AAAA,YAAI,SAAQ;AAAA,YAC1D,UAAA,EAAe,EAAS,QAAQ,QAAQ;AAAA,UACrC,CAAA,GACN,gBAAA,EAAC,GAAD;AAAA,YAAM,SAAQ;AAAA,YAAd,UAAA,CAAsB,MAAG,EAAS,OAAO,YAAY,CAAQ;AAAA,UACxD,CAAA,CAAA;AAAA,QACF,CAAA,CAAA;AAAA;MAET,gBAAA,EAAC,GAAD;AAAA,QAAQ,WAAW;AAAA,QAAM,MAAK;AAAA,QAAS,SAAQ;AAAA,QAC5C,UAAA,EAAK;AAAA,MACA,CAAA;AAAA,IACH;AAAA;AAEX"}
@@ -0,0 +1 @@
1
+ export { EmergencySavingsBlock } from './EmergencySavingsBlock';
@@ -0,0 +1,52 @@
1
+ export declare const stepForBalance: (balance: number) => {
2
+ below: 100;
3
+ goal: 100;
4
+ labelKey: "step_one";
5
+ index: number;
6
+ } | {
7
+ below: 500;
8
+ goal: 500;
9
+ labelKey: "step_two";
10
+ index: number;
11
+ } | {
12
+ below: number;
13
+ goal: 1000;
14
+ labelKey: "final_step";
15
+ index: number;
16
+ };
17
+ export declare const CADENCES: readonly [{
18
+ readonly labelKey: "once_per_week";
19
+ readonly periodKey: "week";
20
+ readonly months: 0.25;
21
+ }, {
22
+ readonly labelKey: "every_other_week";
23
+ readonly periodKey: "every_other_week_period";
24
+ readonly months: 0.5;
25
+ }, {
26
+ readonly labelKey: "once_per_month";
27
+ readonly periodKey: "month";
28
+ readonly months: 1;
29
+ }, {
30
+ readonly labelKey: "every_three_months";
31
+ readonly periodKey: "three_month_period";
32
+ readonly months: 3;
33
+ }];
34
+ export declare const DEADLINE_UNITS: readonly [{
35
+ readonly labelKey: "days";
36
+ readonly months: 0.0323;
37
+ }, {
38
+ readonly labelKey: "weeks";
39
+ readonly months: 0.25;
40
+ }, {
41
+ readonly labelKey: "months";
42
+ readonly months: 1;
43
+ }];
44
+ interface ContributionInput {
45
+ balance: number;
46
+ goal: number;
47
+ cadence: (typeof CADENCES)[number];
48
+ deadline: (typeof DEADLINE_UNITS)[number];
49
+ deadlineQuantity: number;
50
+ }
51
+ export declare const calculateContribution: ({ balance, goal, cadence, deadline, deadlineQuantity, }: ContributionInput) => number | undefined;
52
+ export {};
@@ -0,0 +1,72 @@
1
+ var a = [
2
+ {
3
+ below: 100,
4
+ goal: 100,
5
+ labelKey: "step_one"
6
+ },
7
+ {
8
+ below: 500,
9
+ goal: 500,
10
+ labelKey: "step_two"
11
+ },
12
+ {
13
+ below: 1 / 0,
14
+ goal: 1e3,
15
+ labelKey: "final_step"
16
+ }
17
+ ], m = (t) => {
18
+ const e = a.findIndex(({ below: n }) => t < n);
19
+ return {
20
+ index: e,
21
+ ...a[e]
22
+ };
23
+ }, y = [
24
+ {
25
+ labelKey: "once_per_week",
26
+ periodKey: "week",
27
+ months: 0.25
28
+ },
29
+ {
30
+ labelKey: "every_other_week",
31
+ periodKey: "every_other_week_period",
32
+ months: 0.5
33
+ },
34
+ {
35
+ labelKey: "once_per_month",
36
+ periodKey: "month",
37
+ months: 1
38
+ },
39
+ {
40
+ labelKey: "every_three_months",
41
+ periodKey: "three_month_period",
42
+ months: 3
43
+ }
44
+ ], h = [
45
+ {
46
+ labelKey: "days",
47
+ months: 0.0323
48
+ },
49
+ {
50
+ labelKey: "weeks",
51
+ months: 0.25
52
+ },
53
+ {
54
+ labelKey: "months",
55
+ months: 1
56
+ }
57
+ ], b = ({ balance: t, goal: e, cadence: n, deadline: l, deadlineQuantity: i }) => {
58
+ const o = e - t;
59
+ if (Number.isNaN(o)) return;
60
+ if (o <= 0) return 0;
61
+ const s = i * l.months / n.months, r = Number((o / s).toFixed(2));
62
+ if (!Number.isNaN(r))
63
+ return Math.min(r, Number(o.toFixed(2)));
64
+ };
65
+ export {
66
+ y as CADENCES,
67
+ h as DEADLINE_UNITS,
68
+ b as calculateContribution,
69
+ m as stepForBalance
70
+ };
71
+
72
+ //# sourceMappingURL=layout.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/EmergencySavingsBlock/layout.ts"],"sourcesContent":["const STEPS = [\n { below: 100, goal: 100, labelKey: 'step_one' },\n { below: 500, goal: 500, labelKey: 'step_two' },\n { below: Infinity, goal: 1000, labelKey: 'final_step' },\n] as const\n\nexport const stepForBalance = (balance: number) => {\n const index = STEPS.findIndex(({ below }) => balance < below)\n\n return { index, ...STEPS[index] }\n}\n\nexport const CADENCES = [\n { labelKey: 'once_per_week', periodKey: 'week', months: 0.25 },\n { labelKey: 'every_other_week', periodKey: 'every_other_week_period', months: 0.5 },\n { labelKey: 'once_per_month', periodKey: 'month', months: 1 },\n { labelKey: 'every_three_months', periodKey: 'three_month_period', months: 3 },\n] as const\n\nexport const DEADLINE_UNITS = [\n { labelKey: 'days', months: 0.0323 },\n { labelKey: 'weeks', months: 0.25 },\n { labelKey: 'months', months: 1 },\n] as const\n\ninterface ContributionInput {\n balance: number\n goal: number\n cadence: (typeof CADENCES)[number]\n deadline: (typeof DEADLINE_UNITS)[number]\n deadlineQuantity: number\n}\n\nexport const calculateContribution = ({\n balance,\n goal,\n cadence,\n deadline,\n deadlineQuantity,\n}: ContributionInput): number | undefined => {\n const remainingToSave = goal - balance\n\n if (Number.isNaN(remainingToSave)) return undefined\n if (remainingToSave <= 0) return 0\n\n const periods = (deadlineQuantity * deadline.months) / cadence.months\n const payment = Number((remainingToSave / periods).toFixed(2))\n\n if (Number.isNaN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AAG,QAAO;AAEjC,QAAM,IAAW,IAAmB,EAAS,SAAU,EAAQ,QACzD,IAAU,QAAQ,IAAkB,GAAS,QAAQ,CAAC,CAAC;AAE7D,MAAI,QAAO,MAAM,CAAO;AAExB,WAAO,KAAK,IAAI,GAAS,OAAO,EAAgB,QAAQ,CAAC,CAAC,CAAC;AAC7D"}
@@ -0,0 +1,11 @@
1
+ import { ActionBlockProps } from '../../mappings/blocks';
2
+ /** Loads accounts once per open when the host did not attach the beat's primary account. */
3
+ export declare const usePayoffCalculatorPrepare: ({ beat }: ActionBlockProps) => void;
4
+ /**
5
+ * Monthly Credit Card Interest Summary's "Learn how to save" drawer: the credit card payoff
6
+ * calculator. The beat's account prefills the balance, interest rate and minimum payment; the
7
+ * user edits them and compares the payoff at that payment, $10 more and $20 more.
8
+ */
9
+ export declare const PayoffCalculatorBlock: (({ beat, }: ActionBlockProps) => import("react/jsx-runtime").JSX.Element) & {
10
+ displayName: string;
11
+ };
@@ -0,0 +1,132 @@
1
+ import I from "../../../common/utils/AccountDisplayName.es.js";
2
+ import { useAccountStore as g, useGlobalCopyStore as S } from "../../../common/context/hooks.es.js";
3
+ import A from "../../../common/components/Loader.es.js";
4
+ import { isPayoffPossible as w } from "./payoff.es.js";
5
+ import { buildPayoffRows as F, initialPayoffInputs as R, parsePayoffInputs as k, resolvePrimaryAccount as D, validatePayoffInputs as L } from "./layout.es.js";
6
+ import { CalculationFailed as $, PayoffResults as j } from "./PayoffResults.es.js";
7
+ import l from "react";
8
+ import { observer as B } from "mobx-react-lite";
9
+ import c from "@mui/material/Stack";
10
+ import { InstitutionLogo as E, Text as h, TextField as T } from "@mxenabled/mxui";
11
+ import G from "@mui/material/Button";
12
+ import { jsx as o, jsxs as d } from "react/jsx-runtime";
13
+ import N from "@mui/material/InputAdornment";
14
+ var tt = ({ beat: i }) => {
15
+ const { accountsLoaded: t, loadAccounts: s } = g();
16
+ l.useEffect(() => {
17
+ !i.primary_account && !t && s();
18
+ }, []);
19
+ }, O = ({ account: i, copy: t }) => {
20
+ const s = l.useId(), [a, f] = l.useState(() => R(i)), [u, m] = l.useState({}), [p, v] = l.useState({ status: "idle" }), b = i ? I(i) : "", _ = (e) => (n) => f((r) => ({
21
+ ...r,
22
+ [e]: n.target.value
23
+ })), C = (e) => {
24
+ e.preventDefault();
25
+ const n = L(a, t);
26
+ if (m(n), Object.keys(n).length > 0) return;
27
+ const { balance: r, interestRate: x, monthlyPayment: P } = k(a);
28
+ v(w(x, r, P) ? {
29
+ status: "calculated",
30
+ rows: F(x, r, P)
31
+ } : { status: "failed" });
32
+ }, y = (e, n, r) => /* @__PURE__ */ o(T, {
33
+ error: !!u[e],
34
+ fullWidth: !0,
35
+ helperText: u[e],
36
+ id: `${s}-${e}`,
37
+ label: n,
38
+ onChange: _(e),
39
+ slotProps: {
40
+ htmlInput: { inputMode: "decimal" },
41
+ input: { [r.position === "start" ? "startAdornment" : "endAdornment"]: /* @__PURE__ */ o(N, {
42
+ "aria-hidden": "true",
43
+ position: r.position,
44
+ children: r.symbol
45
+ }) }
46
+ },
47
+ value: a[e]
48
+ });
49
+ return /* @__PURE__ */ d(c, {
50
+ component: "form",
51
+ noValidate: !0,
52
+ onSubmit: C,
53
+ sx: { p: 16 },
54
+ children: [
55
+ b && /* @__PURE__ */ d(c, {
56
+ sx: {
57
+ alignItems: "center",
58
+ flexDirection: "row",
59
+ gap: 8
60
+ },
61
+ children: [/* @__PURE__ */ o(E, {
62
+ alt: "",
63
+ institutionGuid: i?.institution_guid ?? "",
64
+ size: 24
65
+ }), /* @__PURE__ */ o(h, {
66
+ component: "p",
67
+ variant: "body2",
68
+ children: b
69
+ })]
70
+ }),
71
+ /* @__PURE__ */ o(h, {
72
+ color: "text.secondary",
73
+ component: "p",
74
+ sx: { mt: 16 },
75
+ variant: "body2",
76
+ children: t.description
77
+ }),
78
+ /* @__PURE__ */ d(c, {
79
+ sx: {
80
+ gap: 24,
81
+ pb: 24,
82
+ pt: 32
83
+ },
84
+ children: [y("balance", t.credit_card_balance, {
85
+ position: "start",
86
+ symbol: "$"
87
+ }), /* @__PURE__ */ d(c, {
88
+ sx: {
89
+ flexDirection: "row",
90
+ gap: 16
91
+ },
92
+ children: [y("interestRate", t.interest_rate, {
93
+ position: "end",
94
+ symbol: "%"
95
+ }), y("monthlyPayment", t.monthly_payment, {
96
+ position: "start",
97
+ symbol: "$"
98
+ })]
99
+ })]
100
+ }),
101
+ /* @__PURE__ */ o(G, {
102
+ fullWidth: !0,
103
+ sx: {
104
+ mb: 24,
105
+ mt: 8
106
+ },
107
+ type: "submit",
108
+ variant: "contained",
109
+ children: t.calculate
110
+ }),
111
+ p.status === "failed" ? /* @__PURE__ */ o($, { copy: t }) : /* @__PURE__ */ o(j, {
112
+ copy: t,
113
+ rows: p.status === "calculated" ? p.rows : void 0
114
+ })
115
+ ]
116
+ });
117
+ }, ot = B(function({ beat: t }) {
118
+ const { common: s, insights_feed: a } = S(), { accounts: f, accountsLoaded: u } = g(), m = a?.payoff_calculator;
119
+ return m ? !t.primary_account && !u ? /* @__PURE__ */ o(A, {}) : /* @__PURE__ */ o(O, {
120
+ account: D(t, f),
121
+ copy: m
122
+ }, t.guid) : /* @__PURE__ */ o(c, {
123
+ sx: { p: 24 },
124
+ children: /* @__PURE__ */ o(h, { children: s?.error_message })
125
+ });
126
+ });
127
+ export {
128
+ ot as PayoffCalculatorBlock,
129
+ tt as usePayoffCalculatorPrepare
130
+ };
131
+
132
+ //# sourceMappingURL=PayoffCalculatorBlock.es.js.map