@mx-cartographer/experiences 9.7.155 → 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.
Files changed (36) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/dist/insights-v2/actionBlocks/AccountDetailsBlock/AccountDetailsBlock.es.js +19 -22
  3. package/dist/insights-v2/actionBlocks/AccountDetailsBlock/AccountDetailsBlock.es.js.map +1 -1
  4. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js +44 -49
  5. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js.map +1 -1
  6. package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js +37 -41
  7. package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js.map +1 -1
  8. package/dist/insights-v2/actionBlocks/BlockErrorMessage.d.ts +4 -0
  9. package/dist/insights-v2/actionBlocks/BlockErrorMessage.es.js +17 -0
  10. package/dist/insights-v2/actionBlocks/BlockErrorMessage.es.js.map +1 -0
  11. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js +116 -120
  12. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js.map +1 -1
  13. package/dist/insights-v2/actionBlocks/ContactSupportActionBlock.es.js +14 -18
  14. package/dist/insights-v2/actionBlocks/ContactSupportActionBlock.es.js.map +1 -1
  15. package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.es.js +19 -25
  16. package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.es.js.map +1 -1
  17. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js +26 -28
  18. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js.map +1 -1
  19. package/dist/insights-v2/actionBlocks/HelpBlock/HelpBlock.es.js +11 -14
  20. package/dist/insights-v2/actionBlocks/HelpBlock/HelpBlock.es.js.map +1 -1
  21. package/dist/insights-v2/actionBlocks/OverdraftBlock/OverdraftBlock.es.js +28 -30
  22. package/dist/insights-v2/actionBlocks/OverdraftBlock/OverdraftBlock.es.js.map +1 -1
  23. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js +53 -55
  24. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js.map +1 -1
  25. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesBlock.es.js +26 -31
  26. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesBlock.es.js.map +1 -1
  27. package/dist/insights-v2/actionBlocks/PlaceholderActionBlock.es.js.map +1 -1
  28. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js +38 -41
  29. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js.map +1 -1
  30. package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/TransactionDetailsBlock.es.js +11 -16
  31. package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/TransactionDetailsBlock.es.js.map +1 -1
  32. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +39 -42
  33. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
  34. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +76 -78
  35. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
  36. package/package.json +1 -1
@@ -1,128 +1,124 @@
1
1
  import { buildDynamicCopy as P } from "../../../core/utils/Localization.es.js";
2
- import { DATE_FORMATS_INTL as se, formatDate as ae } from "../../../core/constants/DateFormats.es.js";
3
- import { useBudgetsStore as ce, useCategoryStore as le, useGlobalCopyStore as de, useGlobalStore as ue, useInsightsV2Store as me, useTransactionStore as ge } from "../../../common/context/hooks.es.js";
4
- import pe from "../../../common/components/drawer/Drawer.es.js";
5
- import { getLocalizedCategoryName as _e } from "../../../core/utils/CategoryUtil.es.js";
6
- import { exportTransactionsToCSV as fe } from "../../../core/utils/TransactionUtils.es.js";
7
- import ye from "../../../common/components/Loader.es.js";
8
- import he from "../../../common/components/CurrencyDialog.es.js";
9
- import be from "../../../transactions/components/shared/TransactionList.es.js";
10
- import { budgetMonthRange as Te, daysLeftInBudgetMonth as Ce, isPositiveAmount as ve, recordedActiveAtOf as De, resolveBudgetDetailsLayout as xe, resolveBudgetFacts as Se } from "./layout.es.js";
11
- import { ANALYTICS_EVENTS_CONFIG as T } from "../../analytics/analyticsEventsConfig.es.js";
12
- import { useAnalyticsEvent as Be } from "../../analytics/useAnalyticsEvent.es.js";
13
- import Ae from "../../components/CategoryTile.es.js";
14
- import Ee from "../../components/LogoMark.es.js";
15
- import ke from "../../components/shared/StatusSnackbar.es.js";
16
- import { useOpenedCta as Ge } from "../useOpenedCta.es.js";
17
- import { TransactionDetailsBlock as Le } from "../TransactionDetailsBlock/TransactionDetailsBlock.es.js";
18
- import { BudgetSummary as Ie } from "./BudgetSummary.es.js";
19
- import { useRef as we, useState as C } from "react";
20
- import { observer as Me } from "mobx-react-lite";
21
- import f from "@mui/material/Stack";
22
- import { Text as G } from "@mxenabled/mxui";
23
- import L from "@mui/material/Button";
24
- import { Icon as Ne } from "@mxenabled/mx-icons";
25
- import { jsx as t, jsxs as v } from "react/jsx-runtime";
26
- import Oe from "@mui/material/Box";
27
- var dt = Me(function({ beat: n }) {
28
- const { copyStore: H, emitUpdate: Y } = ue(), { budgets: o, categories: $, common: d, insights_feed: D, transactions: W } = de(), u = ce(), q = le(), I = ge(), m = me(), y = Be(), [r, x] = C(null), [g, h] = C(""), [s, p] = C(null), [J, w] = C(!1), S = we(!1), M = D?.budget_details, { categories: K } = q, i = Se(n), N = De(m, n), Q = Te(n, N), X = Ge(n)?.variant, { showPeriodLine: Z } = xe(X);
29
- if (!H.isInitialized) return /* @__PURE__ */ t(ye, {});
30
- if (!M) return /* @__PURE__ */ t(f, {
31
- sx: { p: 24 },
32
- children: /* @__PURE__ */ t(G, { children: d?.error_message })
33
- });
34
- const O = i.categoryGuid ? K.find(({ guid: e }) => e === i.categoryGuid) : void 0, a = i.categoryGuid ? u.budgets.find(({ category_guid: e }) => e === i.categoryGuid) : void 0, c = !i.categoryGuid && i.merchantGuid ? u.getMerchantBudgetByMerchantGuid(i.merchantGuid) : void 0, R = (O && _e(O, $)) ?? c?.merchant_name ?? n.payload?.merchant_name ?? "", V = a?.amount ?? c?.amount ?? i.budgeted ?? 0, ee = i.spent ?? a?.transaction_total ?? c?.transaction_total ?? 0, te = i.categoryGuid ? /* @__PURE__ */ t(Ae, {
2
+ import { DATE_FORMATS_INTL as ne, formatDate as se } from "../../../core/constants/DateFormats.es.js";
3
+ import { useBudgetsStore as ae, useCategoryStore as ce, useGlobalCopyStore as le, useGlobalStore as de, useInsightsV2Store as ue, useTransactionStore as me } from "../../../common/context/hooks.es.js";
4
+ import ge from "../../../common/components/drawer/Drawer.es.js";
5
+ import { getLocalizedCategoryName as pe } from "../../../core/utils/CategoryUtil.es.js";
6
+ import { exportTransactionsToCSV as _e } from "../../../core/utils/TransactionUtils.es.js";
7
+ import fe from "../../../common/components/CurrencyDialog.es.js";
8
+ import ye from "../../../transactions/components/shared/TransactionList.es.js";
9
+ import { BlockErrorMessage as he } from "../BlockErrorMessage.es.js";
10
+ import { budgetMonthRange as be, daysLeftInBudgetMonth as Te, isPositiveAmount as Ce, recordedActiveAtOf as ve, resolveBudgetDetailsLayout as De, resolveBudgetFacts as Be } from "./layout.es.js";
11
+ import { ANALYTICS_EVENTS_CONFIG as b } from "../../analytics/analyticsEventsConfig.es.js";
12
+ import { useAnalyticsEvent as xe } from "../../analytics/useAnalyticsEvent.es.js";
13
+ import Se from "../../components/CategoryTile.es.js";
14
+ import Ae from "../../components/LogoMark.es.js";
15
+ import Ee from "../../components/shared/StatusSnackbar.es.js";
16
+ import { useOpenedCta as ke } from "../useOpenedCta.es.js";
17
+ import { TransactionDetailsBlock as Ge } from "../TransactionDetailsBlock/TransactionDetailsBlock.es.js";
18
+ import { BudgetSummary as Le } from "./BudgetSummary.es.js";
19
+ import { useRef as we, useState as T } from "react";
20
+ import { observer as Ie } from "mobx-react-lite";
21
+ import C from "@mui/material/Stack";
22
+ import { Text as z } from "@mxenabled/mxui";
23
+ import G from "@mui/material/Button";
24
+ import { Icon as Me } from "@mxenabled/mx-icons";
25
+ import { jsx as o, jsxs as v } from "react/jsx-runtime";
26
+ import Ne from "@mui/material/Box";
27
+ var lt = Ie(function({ beat: n }) {
28
+ const { emitUpdate: H } = de(), { budgets: t, categories: Y, common: u, insights_feed: D, transactions: $ } = le(), d = ae(), W = ce(), L = me(), m = ue(), f = xe(), [r, B] = T(null), [g, y] = T(""), [s, p] = T(null), [q, w] = T(!1), x = we(!1), I = D?.budget_details, { categories: J } = W, i = Be(n), M = ve(m, n), K = be(n, M), Q = ke(n)?.variant, { showPeriodLine: X } = De(Q);
29
+ if (!I) return /* @__PURE__ */ o(he, {});
30
+ const N = i.categoryGuid ? J.find(({ guid: e }) => e === i.categoryGuid) : void 0, a = i.categoryGuid ? d.budgets.find(({ category_guid: e }) => e === i.categoryGuid) : void 0, c = !i.categoryGuid && i.merchantGuid ? d.getMerchantBudgetByMerchantGuid(i.merchantGuid) : void 0, O = (N && pe(N, Y)) ?? c?.merchant_name ?? n.payload?.merchant_name ?? "", R = a?.amount ?? c?.amount ?? i.budgeted ?? 0, Z = i.spent ?? a?.transaction_total ?? c?.transaction_total ?? 0, ee = i.categoryGuid ? /* @__PURE__ */ o(Se, {
35
31
  categoryGuid: i.categoryGuid,
36
32
  size: 44,
37
33
  tint: 0.15
38
- }) : /* @__PURE__ */ t(Ee, {
34
+ }) : /* @__PURE__ */ o(Ae, {
39
35
  logo: { merchant_guid: i.merchantGuid },
40
36
  size: 44
41
- }), j = I.sortedTransactionsWithSplits, F = (e) => {
42
- e === "delete" && y(T.BUDGET_DELETE_START), h(e === "edit" ? String(V) : ""), x(e);
37
+ }), V = L.sortedTransactionsWithSplits, j = (e) => {
38
+ e === "delete" && f(b.BUDGET_DELETE_START), y(e === "edit" ? String(R) : ""), B(e);
39
+ }, F = () => {
40
+ B(null), y("");
43
41
  }, U = () => {
44
- x(null), h("");
45
- }, z = () => {
46
- r === "delete" && y(T.BUDGET_DELETE_CANCEL), U();
47
- }, l = (e) => P(e, R), B = (e) => l({
48
- edit: o.error_alert_edit_merchant_budget,
49
- delete: o.error_alert_delete_merchant_budget
50
- }[e]), oe = async (e, _) => {
42
+ r === "delete" && f(b.BUDGET_DELETE_CANCEL), F();
43
+ }, l = (e) => P(e, O), S = (e) => l({
44
+ edit: t.error_alert_edit_merchant_budget,
45
+ delete: t.error_alert_delete_merchant_budget
46
+ }[e]), te = async (e, _) => {
51
47
  if (c) {
52
48
  if (e === "delete") {
53
- const { isSuccess: b } = await u.deleteMerchantBudget(c.guid);
49
+ const { isSuccess: h } = await d.deleteMerchantBudget(c.guid);
54
50
  return {
55
- ok: b,
56
- success: l(o.success_alert_delete_merchant_budget),
57
- failure: l(o.error_alert_delete_merchant_budget)
51
+ ok: h,
52
+ success: l(t.success_alert_delete_merchant_budget),
53
+ failure: l(t.error_alert_delete_merchant_budget)
58
54
  };
59
55
  }
60
- const { isSuccess: k } = await u.updateMerchantBudget({
56
+ const { isSuccess: k } = await d.updateMerchantBudget({
61
57
  ...c,
62
58
  amount: _
63
59
  });
64
60
  return {
65
61
  ok: k,
66
- success: l(o.success_alert_edit_merchant_budget),
67
- failure: l(o.error_alert_edit_merchant_budget)
62
+ success: l(t.success_alert_edit_merchant_budget),
63
+ failure: l(t.error_alert_edit_merchant_budget)
68
64
  };
69
65
  }
70
66
  return e === "delete" && a ? {
71
- ok: await u.deleteBudget(a.guid),
72
- success: l(o.alert_budget_deleted),
73
- failure: B(e)
67
+ ok: await d.deleteBudget(a.guid),
68
+ success: l(t.alert_budget_deleted),
69
+ failure: S(e)
74
70
  } : e === "edit" && a ? {
75
- ok: await u.updateBudget({
71
+ ok: await d.updateBudget({
76
72
  ...a,
77
73
  amount: _
78
74
  }),
79
- success: l(o.alert_budget_updated),
80
- failure: B(e)
75
+ success: l(t.alert_budget_updated),
76
+ failure: S(e)
81
77
  } : {
82
78
  ok: !1,
83
79
  success: ""
84
80
  };
85
- }, re = async () => {
86
- if (S.current || !r) return;
81
+ }, oe = async () => {
82
+ if (x.current || !r) return;
87
83
  const e = Number(g);
88
- if (r !== "delete" && !ve(g)) return;
89
- S.current = !0;
84
+ if (r !== "delete" && !Ce(g)) return;
85
+ x.current = !0;
90
86
  const _ = {
91
87
  action: r,
92
88
  amount: g
93
89
  };
94
90
  try {
95
- const { ok: k, success: b, failure: ne } = await oe(r, e);
91
+ const { ok: k, success: h, failure: ie } = await te(r, e);
96
92
  if (k) {
97
- if (Y({ staleBeatGuid: n.guid }), r === "edit" && y({
98
- ...T.BUDGET_EDIT_SAVE,
93
+ if (H({ staleBeatGuid: n.guid }), r === "edit" && f({
94
+ ...b.BUDGET_EDIT_SAVE,
99
95
  value: g
100
96
  }), r === "delete") {
101
- y(T.BUDGET_DELETE_END), m.setActionNotice(n.guid, {
102
- message: b,
97
+ f(b.BUDGET_DELETE_END), m.setActionNotice(n.guid, {
98
+ message: h,
103
99
  severity: "success"
104
100
  }), m.closeActionDrawer();
105
101
  return;
106
102
  }
107
103
  p({
108
- message: b,
104
+ message: h,
109
105
  severity: "success"
110
106
  });
111
107
  } else p({
112
- message: ne ?? d.error_message,
108
+ message: ie ?? u.error_message,
113
109
  severity: "error",
114
110
  retry: _
115
111
  });
116
112
  } catch {
117
113
  p({
118
- message: B(r),
114
+ message: S(r),
119
115
  severity: "error",
120
116
  retry: _
121
117
  });
122
118
  } finally {
123
- S.current = !1, U();
119
+ x.current = !1, F();
124
120
  }
125
- }, ie = !!(a ?? c) && /* @__PURE__ */ v(f, {
121
+ }, re = !!(a ?? c) && /* @__PURE__ */ v(C, {
126
122
  sx: {
127
123
  bgcolor: "background.paper",
128
124
  borderTop: 1,
@@ -136,110 +132,110 @@ var dt = Me(function({ beat: n }) {
136
132
  px: 24,
137
133
  py: 16
138
134
  },
139
- children: [/* @__PURE__ */ t(L, {
135
+ children: [/* @__PURE__ */ o(G, {
140
136
  color: "error",
141
- onClick: () => F("delete"),
137
+ onClick: () => j("delete"),
142
138
  variant: "outlined",
143
- children: o.details_delete_button
144
- }), /* @__PURE__ */ t(L, {
145
- onClick: () => F("edit"),
139
+ children: t.details_delete_button
140
+ }), /* @__PURE__ */ o(G, {
141
+ onClick: () => j("edit"),
146
142
  variant: "contained",
147
- children: o.details_edit_button
143
+ children: t.details_edit_button
148
144
  })]
149
145
  }), A = r === "delete", E = {
150
146
  edit: {
151
- content: o.edit_budget_content,
152
- primaryText: o.add_save_button,
153
- title: o.details_edit_title
147
+ content: t.edit_budget_content,
148
+ primaryText: t.add_save_button,
149
+ title: t.details_edit_title
154
150
  },
155
151
  delete: {
156
- content: o.delete_description,
157
- primaryText: o.details_delete_button,
158
- title: o.delete_title
152
+ content: t.delete_description,
153
+ primaryText: t.details_delete_button,
154
+ title: t.delete_title
159
155
  }
160
156
  };
161
- return /* @__PURE__ */ v(f, {
157
+ return /* @__PURE__ */ v(C, {
162
158
  sx: { minHeight: "100%" },
163
159
  children: [
164
- /* @__PURE__ */ v(f, {
160
+ /* @__PURE__ */ v(C, {
165
161
  sx: {
166
162
  bgcolor: "background.paper",
167
163
  gap: 16,
168
164
  p: 24
169
165
  },
170
- children: [/* @__PURE__ */ v(f, {
166
+ children: [/* @__PURE__ */ v(C, {
171
167
  sx: {
172
168
  alignItems: "center",
173
169
  flexDirection: "row",
174
170
  justifyContent: "space-between"
175
171
  },
176
- children: [/* @__PURE__ */ t(G, {
172
+ children: [/* @__PURE__ */ o(z, {
177
173
  bold: !0,
178
174
  variant: "body1",
179
- children: ae(Q.start, se.MONTH_YEAR)
180
- }), j.length > 0 && /* @__PURE__ */ t(L, {
181
- onClick: () => fe(j, I.tags),
182
- startIcon: /* @__PURE__ */ t(Ne, { name: "ios_share" }),
175
+ children: se(K.start, ne.MONTH_YEAR)
176
+ }), V.length > 0 && /* @__PURE__ */ o(G, {
177
+ onClick: () => _e(V, L.tags),
178
+ startIcon: /* @__PURE__ */ o(Me, { name: "ios_share" }),
183
179
  sx: { height: 28 },
184
- children: /* @__PURE__ */ t(G, {
180
+ children: /* @__PURE__ */ o(z, {
185
181
  bold: !0,
186
182
  variant: "body2",
187
- children: W.export_csv_btn
183
+ children: $.export_csv_btn
188
184
  })
189
185
  })]
190
- }), /* @__PURE__ */ t(Ie, {
191
- budgetsCopy: o,
192
- copy: M,
193
- daysLeft: Ce(n, void 0, N),
194
- icon: te,
195
- limit: V,
196
- showPeriodLine: Z,
197
- spent: ee
186
+ }), /* @__PURE__ */ o(Le, {
187
+ budgetsCopy: t,
188
+ copy: I,
189
+ daysLeft: Te(n, void 0, M),
190
+ icon: ee,
191
+ limit: R,
192
+ showPeriodLine: X,
193
+ spent: Z
198
194
  })]
199
195
  }),
200
- /* @__PURE__ */ t(Oe, {
196
+ /* @__PURE__ */ o(Ne, {
201
197
  sx: {
202
198
  bgcolor: "background.default",
203
199
  flexGrow: 1
204
200
  },
205
- children: /* @__PURE__ */ t(be, { onClick: (e) => {
201
+ children: /* @__PURE__ */ o(ye, { onClick: (e) => {
206
202
  m.setActionContext({ transaction_guid: e }), w(!0);
207
203
  } })
208
204
  }),
209
- ie,
210
- r && /* @__PURE__ */ t(he, {
211
- closeAriaLabel: d.close_aria,
212
- content: P(E[r].content, /* @__PURE__ */ t("b", { children: R })),
213
- handleInputChange: h,
214
- handleModalClose: z,
205
+ re,
206
+ r && /* @__PURE__ */ o(fe, {
207
+ closeAriaLabel: u.close_aria,
208
+ content: P(E[r].content, /* @__PURE__ */ o("b", { children: O })),
209
+ handleInputChange: y,
210
+ handleModalClose: U,
215
211
  handlePrimaryAction: () => {
216
- re();
212
+ oe();
217
213
  },
218
- handleSecondaryAction: z,
219
- inputLabel: A ? void 0 : o.add_label,
214
+ handleSecondaryAction: U,
215
+ inputLabel: A ? void 0 : t.add_label,
220
216
  inputValue: g,
221
217
  isOpen: !0,
222
218
  primaryColor: A ? "error" : "primary",
223
219
  primaryText: E[r].primaryText,
224
220
  secondaryColor: A ? "inherit" : "primary",
225
- secondaryText: d.cancel_button,
221
+ secondaryText: u.cancel_button,
226
222
  title: E[r].title
227
223
  }),
228
- /* @__PURE__ */ t(pe, {
229
- ariaLabelClose: d.close_aria,
230
- isOpen: J,
224
+ /* @__PURE__ */ o(ge, {
225
+ ariaLabelClose: u.close_aria,
226
+ isOpen: q,
231
227
  onClose: () => {
232
228
  w(!1), m.setActionContext({ transaction_guid: void 0 });
233
229
  },
234
230
  title: D.general.transaction_details_title,
235
- children: /* @__PURE__ */ t(Le, { beat: n })
231
+ children: /* @__PURE__ */ o(Ge, { beat: n })
236
232
  }),
237
- /* @__PURE__ */ t(ke, {
233
+ /* @__PURE__ */ o(Ee, {
238
234
  actionText: s?.retry ? D?.general?.try_again : void 0,
239
- closeAriaLabel: d.close_aria,
235
+ closeAriaLabel: u.close_aria,
240
236
  message: s?.message ?? "",
241
237
  onActionClick: () => {
242
- s?.retry && (h(s.retry.amount), x(s.retry.action), p(null));
238
+ s?.retry && (y(s.retry.amount), B(s.retry.action), p(null));
243
239
  },
244
240
  onClose: () => p(null),
245
241
  open: !!s,
@@ -249,7 +245,7 @@ var dt = Me(function({ beat: n }) {
249
245
  });
250
246
  });
251
247
  export {
252
- dt as BudgetDetailsBlock
248
+ lt as BudgetDetailsBlock
253
249
  };
254
250
 
255
251
  //# sourceMappingURL=BudgetDetailsBlock.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BudgetDetailsBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.tsx"],"sourcesContent":["import { useRef, useState, type ReactNode } from 'react'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { CurrencyDialog, Drawer } from '../../../common/components'\nimport {\n Loader,\n useBudgetsStore,\n useCategoryStore,\n useGlobalCopyStore,\n useGlobalStore,\n useInsightsV2Store,\n useTransactionStore,\n} from '../../../common'\nimport { TransactionDetailsBlock } from '../TransactionDetailsBlock'\nimport { useOpenedCta } from '../useOpenedCta'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport { buildDynamicCopy } from '../../../core/utils/Localization'\nimport { exportTransactionsToCSV } from '../../../core/utils/TransactionUtils'\nimport { getLocalizedCategoryName } from '../../../core/utils/CategoryUtil'\nimport type { Budget, MerchantBudget } from '../../../core'\nimport { TransactionList } from '../../../transactions'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport CategoryTile from '../../components/CategoryTile'\nimport LogoMark from '../../components/LogoMark'\nimport StatusSnackbar from '../../components/shared/StatusSnackbar'\nimport type { ActionBlockProps } from '../../mappings/blocks'\n\nimport { BudgetSummary } from './BudgetSummary'\nimport {\n budgetMonthRange,\n daysLeftInBudgetMonth,\n isPositiveAmount,\n recordedActiveAtOf,\n resolveBudgetDetailsLayout,\n resolveBudgetFacts,\n} from './layout'\n\n// Figma's Budget Details offers Edit and Delete only: the drawer opens on an existing budget.\ntype DialogAction = 'edit' | 'delete'\n\ninterface Toast {\n message: string\n severity: 'success' | 'error'\n /** A failed write's dialog and amount, reopened by the snackbar's Try Again. */\n retry?: { action: DialogAction; amount: string }\n}\n\nexport const BudgetDetailsBlock = observer(function BudgetDetailsBlock({ beat }: ActionBlockProps) {\n const { copyStore, emitUpdate } = useGlobalStore()\n const {\n budgets: budgetsCopy,\n categories: categoriesCopy,\n common: commonCopy,\n insights_feed: insightsFeedCopy,\n transactions: transactionsCopy,\n } = useGlobalCopyStore()\n const budgetsStore = useBudgetsStore()\n const categoryStore = useCategoryStore()\n const transactionStore = useTransactionStore()\n const insightsV2Store = useInsightsV2Store()\n const fireAnalyticsEvent = useAnalyticsEvent()\n const [dialog, setDialog] = useState<DialogAction | null>(null)\n const [amount, setAmount] = useState('')\n const [toast, setToast] = useState<Toast | null>(null)\n const [isTransactionDetailsOpen, setIsTransactionDetailsOpen] = useState(false)\n const inProgress = useRef(false)\n const copy = insightsFeedCopy?.budget_details\n const { categories } = categoryStore\n\n const facts = resolveBudgetFacts(beat)\n const recordedActiveAt = recordedActiveAtOf(insightsV2Store, beat)\n const dateRange = budgetMonthRange(beat, recordedActiveAt)\n const variant = useOpenedCta(beat)?.variant\n const { showPeriodLine } = resolveBudgetDetailsLayout(variant)\n\n if (!copyStore.isInitialized) return <Loader />\n\n if (!copy) {\n return (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy?.error_message}</Text>\n </Stack>\n )\n }\n\n const category = facts.categoryGuid\n ? categories.find(({ guid }) => guid === facts.categoryGuid)\n : undefined\n const budget: Budget | undefined = facts.categoryGuid\n ? budgetsStore.budgets.find(({ category_guid }) => category_guid === facts.categoryGuid)\n : undefined\n const merchantBudget: MerchantBudget | undefined =\n !facts.categoryGuid && facts.merchantGuid\n ? budgetsStore.getMerchantBudgetByMerchantGuid(facts.merchantGuid)\n : undefined\n const subject =\n (category && getLocalizedCategoryName(category, categoriesCopy)) ??\n merchantBudget?.merchant_name ??\n (beat.payload?.merchant_name as string | undefined) ??\n ''\n const limit = budget?.amount ?? merchantBudget?.amount ?? facts.budgeted ?? 0\n const spent = facts.spent ?? budget?.transaction_total ?? merchantBudget?.transaction_total ?? 0\n\n const icon = facts.categoryGuid ? (\n <CategoryTile categoryGuid={facts.categoryGuid} size={44} tint={0.15} />\n ) : (\n <LogoMark logo={{ merchant_guid: facts.merchantGuid }} size={44} />\n )\n\n const monthTransactions = transactionStore.sortedTransactionsWithSplits\n\n const openDialog = (action: DialogAction) => {\n if (action === 'delete') fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.BUDGET_DELETE_START)\n setAmount(action === 'edit' ? String(limit) : '')\n setDialog(action)\n }\n\n const closeDialog = () => {\n setDialog(null)\n setAmount('')\n }\n\n // Cancel, close icon or backdrop.\n const cancelDialog = () => {\n if (dialog === 'delete') fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.BUDGET_DELETE_CANCEL)\n closeDialog()\n }\n\n const dynamic = (key: string) => buildDynamicCopy(key, subject) as string\n\n // \"Your {subject} budget could not be …\": the subject is the copy's one variable.\n const failureFor = (action: DialogAction) =>\n dynamic(\n {\n edit: budgetsCopy.error_alert_edit_merchant_budget,\n delete: budgetsCopy.error_alert_delete_merchant_budget,\n }[action],\n )\n\n const perform = async (\n action: DialogAction,\n value: number,\n ): Promise<{ ok: boolean; success: string; failure?: string }> => {\n if (merchantBudget) {\n if (action === 'delete') {\n const { isSuccess } = await budgetsStore.deleteMerchantBudget(merchantBudget.guid)\n return {\n ok: isSuccess,\n success: dynamic(budgetsCopy.success_alert_delete_merchant_budget),\n failure: dynamic(budgetsCopy.error_alert_delete_merchant_budget),\n }\n }\n const { isSuccess } = await budgetsStore.updateMerchantBudget({\n ...merchantBudget,\n amount: value,\n })\n return {\n ok: isSuccess,\n success: dynamic(budgetsCopy.success_alert_edit_merchant_budget),\n failure: dynamic(budgetsCopy.error_alert_edit_merchant_budget),\n }\n }\n if (action === 'delete' && budget) {\n return {\n ok: await budgetsStore.deleteBudget(budget.guid),\n success: dynamic(budgetsCopy.alert_budget_deleted),\n failure: failureFor(action),\n }\n }\n if (action === 'edit' && budget) {\n return {\n ok: await budgetsStore.updateBudget({ ...budget, amount: value }),\n success: dynamic(budgetsCopy.alert_budget_updated),\n failure: failureFor(action),\n }\n }\n return { ok: false, success: '' }\n }\n\n const submit = async () => {\n if (inProgress.current || !dialog) return\n const value = Number(amount)\n if (dialog !== 'delete' && !isPositiveAmount(amount)) return\n\n inProgress.current = true\n const retry = { action: dialog, amount }\n try {\n const { ok, success, failure } = await perform(dialog, value)\n if (ok) {\n // The host re-reads the beat, so a sampled card follows the budget.\n emitUpdate({ staleBeatGuid: beat.guid })\n if (dialog === 'edit') {\n fireAnalyticsEvent({ ...ANALYTICS_EVENTS_CONFIG.BUDGET_EDIT_SAVE, value: amount })\n }\n if (dialog === 'delete') {\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.BUDGET_DELETE_END)\n // No budget left: close the drawer, as pulse did; the message outlives it.\n insightsV2Store.setActionNotice(beat.guid, { message: success, severity: 'success' })\n insightsV2Store.closeActionDrawer()\n return\n }\n setToast({ message: success, severity: 'success' })\n } else {\n setToast({ message: failure ?? commonCopy.error_message, severity: 'error', retry })\n }\n } catch {\n setToast({ message: failureFor(dialog), severity: 'error', retry })\n } finally {\n inProgress.current = false\n closeDialog()\n }\n }\n\n const hasBudget = Boolean(budget ?? merchantBudget)\n\n // Figma's footer, once the budget has loaded.\n const footer = hasBudget && (\n <Stack\n sx={{\n bgcolor: 'background.paper',\n borderTop: 1,\n borderTopColor: 'divider',\n bottom: 0,\n flexDirection: 'row',\n gap: 16,\n justifyContent: 'flex-end',\n mt: 'auto',\n position: 'sticky',\n px: 24,\n py: 16,\n }}\n >\n <Button color=\"error\" onClick={() => openDialog('delete')} variant=\"outlined\">\n {budgetsCopy.details_delete_button}\n </Button>\n <Button onClick={() => openDialog('edit')} variant=\"contained\">\n {budgetsCopy.details_edit_button}\n </Button>\n </Stack>\n )\n\n const isDelete = dialog === 'delete'\n const dialogCopy = {\n edit: {\n content: budgetsCopy.edit_budget_content,\n primaryText: budgetsCopy.add_save_button,\n title: budgetsCopy.details_edit_title,\n },\n delete: {\n content: budgetsCopy.delete_description,\n primaryText: budgetsCopy.details_delete_button,\n title: budgetsCopy.delete_title,\n },\n }\n\n return (\n <Stack sx={{ minHeight: '100%' }}>\n <Stack sx={{ bgcolor: 'background.paper', gap: 16, p: 24 }}>\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', justifyContent: 'space-between' }}>\n <Text bold={true} variant=\"body1\">\n {formatDate(dateRange.start, DATE_FORMATS_INTL.MONTH_YEAR)}\n </Text>\n {monthTransactions.length > 0 && (\n <Button\n onClick={() => exportTransactionsToCSV(monthTransactions, transactionStore.tags)}\n startIcon={<Icon name=\"ios_share\" />}\n sx={{ height: 28 }}\n >\n <Text bold={true} variant=\"body2\">\n {transactionsCopy.export_csv_btn}\n </Text>\n </Button>\n )}\n </Stack>\n <BudgetSummary\n budgetsCopy={budgetsCopy}\n copy={copy}\n daysLeft={daysLeftInBudgetMonth(beat, undefined, recordedActiveAt)}\n icon={icon}\n limit={limit}\n showPeriodLine={showPeriodLine}\n spent={spent}\n />\n </Stack>\n {/* The month's transactions, always: the list shows its own zero state when there are none. */}\n <Box sx={{ bgcolor: 'background.default', flexGrow: 1 }}>\n {/* As legacy: a tapped row opens its Transaction Details over the budget. */}\n <TransactionList\n onClick={(guid) => {\n insightsV2Store.setActionContext({ transaction_guid: guid })\n setIsTransactionDetailsOpen(true)\n }}\n />\n </Box>\n {footer}\n {dialog && (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n content={buildDynamicCopy(dialogCopy[dialog].content, <b>{subject}</b>) as ReactNode}\n handleInputChange={setAmount}\n handleModalClose={cancelDialog}\n handlePrimaryAction={() => void submit()}\n handleSecondaryAction={cancelDialog}\n inputLabel={isDelete ? undefined : budgetsCopy.add_label}\n inputValue={amount}\n isOpen={true}\n primaryColor={isDelete ? 'error' : 'primary'}\n primaryText={dialogCopy[dialog].primaryText}\n secondaryColor={isDelete ? 'inherit' : 'primary'}\n secondaryText={commonCopy.cancel_button}\n title={dialogCopy[dialog].title}\n />\n )}\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isTransactionDetailsOpen}\n onClose={() => {\n setIsTransactionDetailsOpen(false)\n // Clear only the key this nested drawer owns: the outer drawer's context must survive.\n insightsV2Store.setActionContext({ transaction_guid: undefined })\n }}\n title={insightsFeedCopy.general.transaction_details_title}\n >\n <TransactionDetailsBlock beat={beat} />\n </Drawer>\n <StatusSnackbar\n actionText={toast?.retry ? insightsFeedCopy?.general?.try_again : undefined}\n closeAriaLabel={commonCopy.close_aria}\n message={toast?.message ?? ''}\n onActionClick={() => {\n if (!toast?.retry) return\n setAmount(toast.retry.amount)\n setDialog(toast.retry.action)\n setToast(null)\n }}\n onClose={() => setToast(null)}\n open={Boolean(toast)}\n severity={toast?.severity}\n />\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,IAAa,KAAqB,GAAS,SAA4B,EAAE,MAAA,EAAA,GAA0B;AACjG,QAAM,EAAE,WAAA,GAAW,YAAA,EAAA,IAAe,GAAe,GAC3C,EACJ,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,eAAe,GACf,cAAc,EAAA,IACZ,GAAmB,GACjB,IAAe,GAAgB,GAC/B,IAAgB,GAAiB,GACjC,IAAmB,GAAoB,GACvC,IAAkB,GAAmB,GACrC,IAAqB,GAAkB,GACvC,CAAC,GAAQ,CAAA,IAAa,EAA8B,IAAI,GACxD,CAAC,GAAQ,CAAA,IAAa,EAAS,EAAE,GACjC,CAAC,GAAO,CAAA,IAAY,EAAuB,IAAI,GAC/C,CAAC,GAA0B,CAAA,IAA+B,EAAS,EAAK,GACxE,IAAa,GAAO,EAAK,GACzB,IAAO,GAAkB,gBACzB,EAAE,YAAA,EAAA,IAAe,GAEjB,IAAQ,GAAmB,CAAI,GAC/B,IAAmB,GAAmB,GAAiB,CAAI,GAC3D,IAAY,GAAiB,GAAM,CAAgB,GACnD,IAAU,GAAa,CAAI,GAAG,SAC9B,EAAE,gBAAA,EAAA,IAAmB,GAA2B,CAAO;AAE7D,MAAI,CAAC,EAAU,cAAe,QAAO,gBAAA,EAAC,IAAD,CAAS,CAAA;AAE9C,MAAI,CAAC,EACH,QACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI,EAAE,GAAG,GAAG;AAAA,IACjB,UAAA,gBAAA,EAAC,GAAD,EAA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,gBAAA,EAAC,IAAD;AAAA,QACE,YAAY,GAAO,QAAQ,GAAkB,SAAS,YAAY;AAAA,QAClE,gBAAgB,EAAW;AAAA,QAC3B,SAAS,GAAO,WAAW;AAAA,QAC3B,eAAA,MAAqB;AACnB,UAAK,GAAO,UACZ,EAAU,EAAM,MAAM,MAAM,GAC5B,EAAU,EAAM,MAAM,MAAM,GAC5B,EAAS,IAAI;AAAA,QACf;AAAA,QACA,SAAA,MAAe,EAAS,IAAI;AAAA,QAC5B,MAAM,EAAQ;AAAA,QACd,UAAU,GAAO;AAAA,MAClB,CAAA;AAAA,IACI;AAAA;AAEX,CAAC"}
1
+ {"version":3,"file":"BudgetDetailsBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.tsx"],"sourcesContent":["import { useRef, useState, type ReactNode } from 'react'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { CurrencyDialog, Drawer } from '../../../common/components'\nimport {\n useBudgetsStore,\n useCategoryStore,\n useGlobalCopyStore,\n useGlobalStore,\n useInsightsV2Store,\n useTransactionStore,\n} from '../../../common'\nimport { BlockErrorMessage } from '../BlockErrorMessage'\nimport { TransactionDetailsBlock } from '../TransactionDetailsBlock'\nimport { useOpenedCta } from '../useOpenedCta'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport { buildDynamicCopy } from '../../../core/utils/Localization'\nimport { exportTransactionsToCSV } from '../../../core/utils/TransactionUtils'\nimport { getLocalizedCategoryName } from '../../../core/utils/CategoryUtil'\nimport type { Budget, MerchantBudget } from '../../../core'\nimport { TransactionList } from '../../../transactions'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport CategoryTile from '../../components/CategoryTile'\nimport LogoMark from '../../components/LogoMark'\nimport StatusSnackbar from '../../components/shared/StatusSnackbar'\nimport type { ActionBlockProps } from '../../mappings/blocks'\n\nimport { BudgetSummary } from './BudgetSummary'\nimport {\n budgetMonthRange,\n daysLeftInBudgetMonth,\n isPositiveAmount,\n recordedActiveAtOf,\n resolveBudgetDetailsLayout,\n resolveBudgetFacts,\n} from './layout'\n\n// Figma's Budget Details offers Edit and Delete only: the drawer opens on an existing budget.\ntype DialogAction = 'edit' | 'delete'\n\ninterface Toast {\n message: string\n severity: 'success' | 'error'\n /** A failed write's dialog and amount, reopened by the snackbar's Try Again. */\n retry?: { action: DialogAction; amount: string }\n}\n\nexport const BudgetDetailsBlock = observer(function BudgetDetailsBlock({ beat }: ActionBlockProps) {\n const { emitUpdate } = useGlobalStore()\n const {\n budgets: budgetsCopy,\n categories: categoriesCopy,\n common: commonCopy,\n insights_feed: insightsFeedCopy,\n transactions: transactionsCopy,\n } = useGlobalCopyStore()\n const budgetsStore = useBudgetsStore()\n const categoryStore = useCategoryStore()\n const transactionStore = useTransactionStore()\n const insightsV2Store = useInsightsV2Store()\n const fireAnalyticsEvent = useAnalyticsEvent()\n const [dialog, setDialog] = useState<DialogAction | null>(null)\n const [amount, setAmount] = useState('')\n const [toast, setToast] = useState<Toast | null>(null)\n const [isTransactionDetailsOpen, setIsTransactionDetailsOpen] = useState(false)\n const inProgress = useRef(false)\n const copy = insightsFeedCopy?.budget_details\n const { categories } = categoryStore\n\n const facts = resolveBudgetFacts(beat)\n const recordedActiveAt = recordedActiveAtOf(insightsV2Store, beat)\n const dateRange = budgetMonthRange(beat, recordedActiveAt)\n const variant = useOpenedCta(beat)?.variant\n const { showPeriodLine } = resolveBudgetDetailsLayout(variant)\n\n if (!copy) {\n return <BlockErrorMessage />\n }\n\n const category = facts.categoryGuid\n ? categories.find(({ guid }) => guid === facts.categoryGuid)\n : undefined\n const budget: Budget | undefined = facts.categoryGuid\n ? budgetsStore.budgets.find(({ category_guid }) => category_guid === facts.categoryGuid)\n : undefined\n const merchantBudget: MerchantBudget | undefined =\n !facts.categoryGuid && facts.merchantGuid\n ? budgetsStore.getMerchantBudgetByMerchantGuid(facts.merchantGuid)\n : undefined\n const subject =\n (category && getLocalizedCategoryName(category, categoriesCopy)) ??\n merchantBudget?.merchant_name ??\n (beat.payload?.merchant_name as string | undefined) ??\n ''\n const limit = budget?.amount ?? merchantBudget?.amount ?? facts.budgeted ?? 0\n const spent = facts.spent ?? budget?.transaction_total ?? merchantBudget?.transaction_total ?? 0\n\n const icon = facts.categoryGuid ? (\n <CategoryTile categoryGuid={facts.categoryGuid} size={44} tint={0.15} />\n ) : (\n <LogoMark logo={{ merchant_guid: facts.merchantGuid }} size={44} />\n )\n\n const monthTransactions = transactionStore.sortedTransactionsWithSplits\n\n const openDialog = (action: DialogAction) => {\n if (action === 'delete') fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.BUDGET_DELETE_START)\n setAmount(action === 'edit' ? String(limit) : '')\n setDialog(action)\n }\n\n const closeDialog = () => {\n setDialog(null)\n setAmount('')\n }\n\n // Cancel, close icon or backdrop.\n const cancelDialog = () => {\n if (dialog === 'delete') fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.BUDGET_DELETE_CANCEL)\n closeDialog()\n }\n\n const dynamic = (key: string) => buildDynamicCopy(key, subject) as string\n\n // \"Your {subject} budget could not be …\": the subject is the copy's one variable.\n const failureFor = (action: DialogAction) =>\n dynamic(\n {\n edit: budgetsCopy.error_alert_edit_merchant_budget,\n delete: budgetsCopy.error_alert_delete_merchant_budget,\n }[action],\n )\n\n const perform = async (\n action: DialogAction,\n value: number,\n ): Promise<{ ok: boolean; success: string; failure?: string }> => {\n if (merchantBudget) {\n if (action === 'delete') {\n const { isSuccess } = await budgetsStore.deleteMerchantBudget(merchantBudget.guid)\n return {\n ok: isSuccess,\n success: dynamic(budgetsCopy.success_alert_delete_merchant_budget),\n failure: dynamic(budgetsCopy.error_alert_delete_merchant_budget),\n }\n }\n const { isSuccess } = await budgetsStore.updateMerchantBudget({\n ...merchantBudget,\n amount: value,\n })\n return {\n ok: isSuccess,\n success: dynamic(budgetsCopy.success_alert_edit_merchant_budget),\n failure: dynamic(budgetsCopy.error_alert_edit_merchant_budget),\n }\n }\n if (action === 'delete' && budget) {\n return {\n ok: await budgetsStore.deleteBudget(budget.guid),\n success: dynamic(budgetsCopy.alert_budget_deleted),\n failure: failureFor(action),\n }\n }\n if (action === 'edit' && budget) {\n return {\n ok: await budgetsStore.updateBudget({ ...budget, amount: value }),\n success: dynamic(budgetsCopy.alert_budget_updated),\n failure: failureFor(action),\n }\n }\n return { ok: false, success: '' }\n }\n\n const submit = async () => {\n if (inProgress.current || !dialog) return\n const value = Number(amount)\n if (dialog !== 'delete' && !isPositiveAmount(amount)) return\n\n inProgress.current = true\n const retry = { action: dialog, amount }\n try {\n const { ok, success, failure } = await perform(dialog, value)\n if (ok) {\n // The host re-reads the beat, so a sampled card follows the budget.\n emitUpdate({ staleBeatGuid: beat.guid })\n if (dialog === 'edit') {\n fireAnalyticsEvent({ ...ANALYTICS_EVENTS_CONFIG.BUDGET_EDIT_SAVE, value: amount })\n }\n if (dialog === 'delete') {\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.BUDGET_DELETE_END)\n // No budget left: close the drawer, as pulse did; the message outlives it.\n insightsV2Store.setActionNotice(beat.guid, { message: success, severity: 'success' })\n insightsV2Store.closeActionDrawer()\n return\n }\n setToast({ message: success, severity: 'success' })\n } else {\n setToast({ message: failure ?? commonCopy.error_message, severity: 'error', retry })\n }\n } catch {\n setToast({ message: failureFor(dialog), severity: 'error', retry })\n } finally {\n inProgress.current = false\n closeDialog()\n }\n }\n\n const hasBudget = Boolean(budget ?? merchantBudget)\n\n // Figma's footer, once the budget has loaded.\n const footer = hasBudget && (\n <Stack\n sx={{\n bgcolor: 'background.paper',\n borderTop: 1,\n borderTopColor: 'divider',\n bottom: 0,\n flexDirection: 'row',\n gap: 16,\n justifyContent: 'flex-end',\n mt: 'auto',\n position: 'sticky',\n px: 24,\n py: 16,\n }}\n >\n <Button color=\"error\" onClick={() => openDialog('delete')} variant=\"outlined\">\n {budgetsCopy.details_delete_button}\n </Button>\n <Button onClick={() => openDialog('edit')} variant=\"contained\">\n {budgetsCopy.details_edit_button}\n </Button>\n </Stack>\n )\n\n const isDelete = dialog === 'delete'\n const dialogCopy = {\n edit: {\n content: budgetsCopy.edit_budget_content,\n primaryText: budgetsCopy.add_save_button,\n title: budgetsCopy.details_edit_title,\n },\n delete: {\n content: budgetsCopy.delete_description,\n primaryText: budgetsCopy.details_delete_button,\n title: budgetsCopy.delete_title,\n },\n }\n\n return (\n <Stack sx={{ minHeight: '100%' }}>\n <Stack sx={{ bgcolor: 'background.paper', gap: 16, p: 24 }}>\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', justifyContent: 'space-between' }}>\n <Text bold={true} variant=\"body1\">\n {formatDate(dateRange.start, DATE_FORMATS_INTL.MONTH_YEAR)}\n </Text>\n {monthTransactions.length > 0 && (\n <Button\n onClick={() => exportTransactionsToCSV(monthTransactions, transactionStore.tags)}\n startIcon={<Icon name=\"ios_share\" />}\n sx={{ height: 28 }}\n >\n <Text bold={true} variant=\"body2\">\n {transactionsCopy.export_csv_btn}\n </Text>\n </Button>\n )}\n </Stack>\n <BudgetSummary\n budgetsCopy={budgetsCopy}\n copy={copy}\n daysLeft={daysLeftInBudgetMonth(beat, undefined, recordedActiveAt)}\n icon={icon}\n limit={limit}\n showPeriodLine={showPeriodLine}\n spent={spent}\n />\n </Stack>\n {/* The month's transactions, always: the list shows its own zero state when there are none. */}\n <Box sx={{ bgcolor: 'background.default', flexGrow: 1 }}>\n {/* As legacy: a tapped row opens its Transaction Details over the budget. */}\n <TransactionList\n onClick={(guid) => {\n insightsV2Store.setActionContext({ transaction_guid: guid })\n setIsTransactionDetailsOpen(true)\n }}\n />\n </Box>\n {footer}\n {dialog && (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n content={buildDynamicCopy(dialogCopy[dialog].content, <b>{subject}</b>) as ReactNode}\n handleInputChange={setAmount}\n handleModalClose={cancelDialog}\n handlePrimaryAction={() => void submit()}\n handleSecondaryAction={cancelDialog}\n inputLabel={isDelete ? undefined : budgetsCopy.add_label}\n inputValue={amount}\n isOpen={true}\n primaryColor={isDelete ? 'error' : 'primary'}\n primaryText={dialogCopy[dialog].primaryText}\n secondaryColor={isDelete ? 'inherit' : 'primary'}\n secondaryText={commonCopy.cancel_button}\n title={dialogCopy[dialog].title}\n />\n )}\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isTransactionDetailsOpen}\n onClose={() => {\n setIsTransactionDetailsOpen(false)\n // Clear only the key this nested drawer owns: the outer drawer's context must survive.\n insightsV2Store.setActionContext({ transaction_guid: undefined })\n }}\n title={insightsFeedCopy.general.transaction_details_title}\n >\n <TransactionDetailsBlock beat={beat} />\n </Drawer>\n <StatusSnackbar\n actionText={toast?.retry ? insightsFeedCopy?.general?.try_again : undefined}\n closeAriaLabel={commonCopy.close_aria}\n message={toast?.message ?? ''}\n onActionClick={() => {\n if (!toast?.retry) return\n setAmount(toast.retry.amount)\n setDialog(toast.retry.action)\n setToast(null)\n }}\n onClose={() => setToast(null)}\n open={Boolean(toast)}\n severity={toast?.severity}\n />\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,IAAa,KAAqB,GAAS,SAA4B,EAAE,MAAA,EAAA,GAA0B;AACjG,QAAM,EAAE,YAAA,EAAA,IAAe,GAAe,GAChC,EACJ,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,eAAe,GACf,cAAc,EAAA,IACZ,GAAmB,GACjB,IAAe,GAAgB,GAC/B,IAAgB,GAAiB,GACjC,IAAmB,GAAoB,GACvC,IAAkB,GAAmB,GACrC,IAAqB,GAAkB,GACvC,CAAC,GAAQ,CAAA,IAAa,EAA8B,IAAI,GACxD,CAAC,GAAQ,CAAA,IAAa,EAAS,EAAE,GACjC,CAAC,GAAO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AA,EAAQ;AAAA,MAC3B,CAAA;AAAA,MAEH,gBAAA,EAAC,IAAD;AAAA,QACE,gBAAgB,EAAW;AAAA,QAC3B,QAAQ;AAAA,QACR,SAAA,MAAe;AACb,UAAA,EAA4B,EAAK,GAEjC,EAAgB,iBAAiB,EAAE,kBAAkB,OAAU,CAAC;AAAA,QAClE;AAAA,QACA,OAAO,EAAiB,QAAQ;AAAA,QAEhC,UAAA,gBAAA,EAAC,IAAD,EAA+B,MAAA,EAAO,CAAA;AAAA,MAChC,CAAA;AAAA,MACR,gBAAA,EAAC,IAAD;AAAA,QACE,YAAY,GAAO,QAAQ,GAAkB,SAAS,YAAY;AAAA,QAClE,gBAAgB,EAAW;AAAA,QAC3B,SAAS,GAAO,WAAW;AAAA,QAC3B,eAAA,MAAqB;AACnB,UAAK,GAAO,UACZ,EAAU,EAAM,MAAM,MAAM,GAC5B,EAAU,EAAM,MAAM,MAAM,GAC5B,EAAS,IAAI;AAAA,QACf;AAAA,QACA,SAAA,MAAe,EAAS,IAAI;AAAA,QAC5B,MAAM,EAAQ;AAAA,QACd,UAAU,GAAO;AAAA,MAClB,CAAA;AAAA,IACI;AAAA;AAEX,CAAC"}
@@ -1,22 +1,18 @@
1
- import { useGlobalCopyStore as n, useInsightsV2Store as s } from "../../common/context/hooks.es.js";
2
- import { useBeatActions as i } from "../beatActions.es.js";
3
- import { useEffect as m } from "react";
4
- import { observer as a } from "mobx-react-lite";
5
- import u from "@mui/material/Stack";
6
- import { Text as f } from "@mxenabled/mxui";
7
- import { jsx as p } from "react/jsx-runtime";
8
- var A = a(function(r) {
9
- const { onContactSupport: o } = i(), { closeActionDrawer: e } = s(), { common: c } = n();
10
- return m(() => {
11
- o && (e(), o());
12
- }, [e, o]), o ? null : /* @__PURE__ */ p(u, {
13
- sx: { p: 24 },
14
- children: /* @__PURE__ */ p(f, { children: c?.error_message ?? "" })
15
- });
16
- }), d = (t, r, o) => t === "contact_support_block" && (!r.enable_support_requests || !o);
1
+ import { useInsightsV2Store as e } from "../../common/context/hooks.es.js";
2
+ import { useBeatActions as s } from "../beatActions.es.js";
3
+ import { BlockErrorMessage as c } from "./BlockErrorMessage.es.js";
4
+ import { useEffect as n } from "react";
5
+ import { observer as i } from "mobx-react-lite";
6
+ import { jsx as u } from "react/jsx-runtime";
7
+ var _ = i(function(r) {
8
+ const { onContactSupport: o } = s(), { closeActionDrawer: p } = e();
9
+ return n(() => {
10
+ o && (p(), o());
11
+ }, [p, o]), o ? null : /* @__PURE__ */ u(c, {});
12
+ }), b = (t, r, o) => t === "contact_support_block" && (!r.enable_support_requests || !o);
17
13
  export {
18
- A as ContactSupportActionBlock,
19
- d as isContactSupportCtaDisabled
14
+ _ as ContactSupportActionBlock,
15
+ b as isContactSupportCtaDisabled
20
16
  };
21
17
 
22
18
  //# sourceMappingURL=ContactSupportActionBlock.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContactSupportActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/ContactSupportActionBlock.tsx"],"sourcesContent":["import { useEffect } from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { useGlobalCopyStore, useInsightsV2Store } from '../../common'\nimport { useBeatActions } from '../beatActions'\nimport type { ActionBlockProps } from '../mappings/blocks'\n\n/**\n * `contact_support_block` (`insights_v2.2.md` §7.3) is the help module's contact-support flow,\n * but insights-v2 must **not** import it: hosts that don't ship the Help widget (pulse's webpack\n * config `IgnorePlugin`s every `help` resource inside `@mx-cartographer/experiences/dist`) would\n * get a `webpackMissingModule` stub and crash at import time. So the flow is injected instead:\n *\n * - Feed / mini cards: the host passes `beatActions.onContactSupport` (pulse already threads\n * `beatActions` into `BaseLayout`). `BaseLayout` calls it directly instead of opening a drawer.\n * - Transaction details drawer: the host passes `onContactSupport` to `TransactionDetails`.\n * - The experiences Help widget is itself a host and wires `RequestSupport` through the same hook.\n *\n * The CTA renders disabled (label shown, `aria-disabled`, nothing opens or posts) whenever the\n * client's `enable_support_requests` is off **or** the host supplied no handler — see\n * `isContactSupportCtaDisabled`.\n *\n * This registry entry is only a safety net for a drawer opened by a path that bypassed that gate\n * (e.g. a stale `actionDrawer` state): it hands off to the host handler if one exists, otherwise\n * closes the drawer and shows the generic error.\n */\nexport const ContactSupportActionBlock = observer(function ContactSupportActionBlock(\n _props: ActionBlockProps,\n) {\n const { onContactSupport } = useBeatActions()\n const { closeActionDrawer } = useInsightsV2Store()\n const { common } = useGlobalCopyStore()\n\n useEffect(() => {\n if (onContactSupport) {\n closeActionDrawer()\n onContactSupport()\n }\n }, [closeActionDrawer, onContactSupport])\n\n if (onContactSupport) return null\n\n return (\n <Stack sx={{ p: 24 }}>\n <Text>{common?.error_message ?? ''}</Text>\n </Stack>\n )\n})\n\n/**\n * Whether a host must render a CTA disabled. Only `contact_support_block` is gated: by the client's\n * `enable_support_requests` config (default false) and by whether the host actually wired a handler.\n * Every other block is always enabled. No fallback to a host post message when it is off.\n */\nexport const isContactSupportCtaDisabled = (\n block: string | null | undefined,\n config: { enable_support_requests?: boolean },\n onContactSupport?: (() => void) | null,\n): boolean =>\n block === 'contact_support_block' && (!config.enable_support_requests || !onContactSupport)\n"],"mappings":";;;;;;;AA8BA,IAAa,IAA4B,EAAS,SAChD,GACA;AACA,QAAM,EAAE,kBAAA,EAAA,IAAqB,EAAe,GACtC,EAAE,mBAAA,EAAA,IAAsB,EAAmB,GAC3C,EAAE,QAAA,EAAA,IAAW,EAAmB;AAStC,SAPA,EAAA,MAAgB;AACd,IAAI,MACF,EAAkB,GAClB,EAAiB;AAAA,EAErB,GAAG,CAAC,GAAmB,CAAgB,CAAC,GAEpC,IAAyB,OAG3B,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI,EAAE,GAAG,GAAG;AAAA,IACjB,UAAA,gBAAA,EAAC,GAAD,EAAA,UAAO,GAAQ,iBAAiB,GAAS,CAAA;AAAA,EACpC,CAAA;AAEX,CAAC,GAOY,IAAA,CACX,GACA,GACA,MAEA,MAAU,4BAA4B,CAAC,EAAO,2BAA2B,CAAC"}
1
+ {"version":3,"file":"ContactSupportActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/ContactSupportActionBlock.tsx"],"sourcesContent":["import { useEffect } from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport { useInsightsV2Store } from '../../common'\nimport { useBeatActions } from '../beatActions'\nimport type { ActionBlockProps } from '../mappings/blocks'\nimport { BlockErrorMessage } from './BlockErrorMessage'\n\n/**\n * `contact_support_block` (`insights_v2.2.md` §7.3) is the help module's contact-support flow,\n * but insights-v2 must **not** import it: hosts that don't ship the Help widget (pulse's webpack\n * config `IgnorePlugin`s every `help` resource inside `@mx-cartographer/experiences/dist`) would\n * get a `webpackMissingModule` stub and crash at import time. So the flow is injected instead:\n *\n * - Feed / mini cards: the host passes `beatActions.onContactSupport` (pulse already threads\n * `beatActions` into `BaseLayout`). `BaseLayout` calls it directly instead of opening a drawer.\n * - Transaction details drawer: the host passes `onContactSupport` to `TransactionDetails`.\n * - The experiences Help widget is itself a host and wires `RequestSupport` through the same hook.\n *\n * The CTA renders disabled (label shown, `aria-disabled`, nothing opens or posts) whenever the\n * client's `enable_support_requests` is off **or** the host supplied no handler — see\n * `isContactSupportCtaDisabled`.\n *\n * This registry entry is only a safety net for a drawer opened by a path that bypassed that gate\n * (e.g. a stale `actionDrawer` state): it hands off to the host handler if one exists, otherwise\n * closes the drawer and shows the generic error.\n */\nexport const ContactSupportActionBlock = observer(function ContactSupportActionBlock(\n _props: ActionBlockProps,\n) {\n const { onContactSupport } = useBeatActions()\n const { closeActionDrawer } = useInsightsV2Store()\n\n useEffect(() => {\n if (onContactSupport) {\n closeActionDrawer()\n onContactSupport()\n }\n }, [closeActionDrawer, onContactSupport])\n\n if (onContactSupport) return null\n\n return <BlockErrorMessage />\n})\n\n/**\n * Whether a host must render a CTA disabled. Only `contact_support_block` is gated: by the client's\n * `enable_support_requests` config (default false) and by whether the host actually wired a handler.\n * Every other block is always enabled. No fallback to a host post message when it is off.\n */\nexport const isContactSupportCtaDisabled = (\n block: string | null | undefined,\n config: { enable_support_requests?: boolean },\n onContactSupport?: (() => void) | null,\n): boolean =>\n block === 'contact_support_block' && (!config.enable_support_requests || !onContactSupport)\n"],"mappings":";;;;;;AA2BA,IAAa,IAA4B,EAAS,SAChD,GACA;AACA,QAAM,EAAE,kBAAA,EAAA,IAAqB,EAAe,GACtC,EAAE,mBAAA,EAAA,IAAsB,EAAmB;AASjD,SAPA,EAAA,MAAgB;AACd,IAAI,MACF,EAAkB,GAClB,EAAiB;AAAA,EAErB,GAAG,CAAC,GAAmB,CAAgB,CAAC,GAEpC,IAAyB,OAEtB,gBAAA,EAAC,GAAD,CAAoB,CAAA;AAC7B,CAAC,GAOY,IAAA,CACX,GACA,GACA,MAEA,MAAU,4BAA4B,CAAC,EAAO,2BAA2B,CAAC"}
@@ -1,32 +1,26 @@
1
- import { useAccountStore as u, useGlobalCopyStore as f, useGlobalStore as g } from "../../../common/context/hooks.es.js";
2
- import y from "../../../common/components/Loader.es.js";
3
- import { readCardRows as C, readSummary as _ } from "./layout.es.js";
4
- import h from "./CreditUtilizationContent.es.js";
5
- import { observer as S } from "mobx-react-lite";
6
- import x from "@mui/material/Stack";
7
- import { Text as z } from "@mxenabled/mxui";
8
- import { jsx as o } from "react/jsx-runtime";
9
- var b = (e, i) => ({
10
- ...e,
1
+ import { useAccountStore as p, useGlobalCopyStore as l } from "../../../common/context/hooks.es.js";
2
+ import { BlockErrorMessage as u } from "../BlockErrorMessage.es.js";
3
+ import { readCardRows as f, readSummary as g } from "./layout.es.js";
4
+ import y from "./CreditUtilizationContent.es.js";
5
+ import { observer as C } from "mobx-react-lite";
6
+ import { jsx as s } from "react/jsx-runtime";
7
+ var _ = (r, i) => ({
8
+ ...r,
11
9
  institutionGuid: i
12
- }), F = S(function({ beat: i }) {
13
- const { copyStore: a } = g(), { common: m, insights_feed: c } = f(), { accounts: d } = u(), n = c?.credit_utilization;
14
- if (!a.isInitialized) return /* @__PURE__ */ o(y, {});
15
- if (!n) return /* @__PURE__ */ o(x, {
16
- sx: { p: 24 },
17
- children: /* @__PURE__ */ o(z, { children: m?.error_message ?? "Something went wrong." })
18
- });
19
- const r = i.insights_payload, s = r?.instance_slot_data, p = new Map(d.map((t) => [t.guid, t.institution_guid ?? ""])), l = C(s?.data_series).map((t) => b(t, p.get(t.guid) ?? ""));
20
- return /* @__PURE__ */ o(h, {
21
- cards: l,
22
- copy: n,
23
- descriptionHtml: r?.description?.html_text,
24
- summary: _(s),
25
- title: r?.title
10
+ }), S = C(function({ beat: i }) {
11
+ const { insights_feed: a } = l(), { accounts: c } = p(), e = a?.credit_utilization;
12
+ if (!e) return /* @__PURE__ */ s(u, {});
13
+ const o = i.insights_payload, n = o?.instance_slot_data, d = new Map(c.map((t) => [t.guid, t.institution_guid ?? ""])), m = f(n?.data_series).map((t) => _(t, d.get(t.guid) ?? ""));
14
+ return /* @__PURE__ */ s(y, {
15
+ cards: m,
16
+ copy: e,
17
+ descriptionHtml: o?.description?.html_text,
18
+ summary: g(n),
19
+ title: o?.title
26
20
  });
27
21
  });
28
22
  export {
29
- F as CreditUtilizationBlock
23
+ S as CreditUtilizationBlock
30
24
  };
31
25
 
32
26
  //# sourceMappingURL=CreditUtilizationBlock.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CreditUtilizationBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { Loader, useAccountStore, useGlobalCopyStore, useGlobalStore } from '../../../common'\nimport type { ActionBlockProps } from '../../mappings/blocks'\n\nimport CreditUtilizationContent, { type CreditUtilizationCard } from './CreditUtilizationContent'\nimport { readCardRows, readSummary, type CreditCardRow } from './layout'\n\nconst toCard = (row: CreditCardRow, institutionGuid: string): CreditUtilizationCard => ({\n ...row,\n institutionGuid,\n})\n\n/**\n * Credit Utilization drawer (MEW2-3356): the beat's donut summary, the utilization legend and one\n * row per card from `instance_slot_data.data_series`. Rows are joined to the loaded accounts by guid\n * for the institution logo only, so the drawer renders as soon as copy is in and the logos fill in\n * when the accounts arrive. `observer`: reads copy and accounts from MobX stores.\n */\nexport const CreditUtilizationBlock = observer(function CreditUtilizationBlock({\n beat,\n}: ActionBlockProps) {\n const { copyStore } = useGlobalStore()\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { accounts } = useAccountStore()\n const copy = insightsFeedCopy?.credit_utilization\n\n if (!copyStore.isInitialized) return <Loader />\n\n // Copy loads once at app start, so a retry cannot clear a missing namespace: a plain message, never\n // an endless loader.\n if (!copy) {\n return (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy?.error_message ?? 'Something went wrong.'}</Text>\n </Stack>\n )\n }\n\n const payload = beat.insights_payload\n const data = payload?.instance_slot_data\n const institutionByAccount = new Map(\n accounts.map((account) => [account.guid, account.institution_guid ?? '']),\n )\n const cards = readCardRows(data?.data_series).map((row) =>\n toCard(row, institutionByAccount.get(row.guid) ?? ''),\n )\n\n return (\n <CreditUtilizationContent\n cards={cards}\n copy={copy}\n descriptionHtml={payload?.description?.html_text}\n summary={readSummary(data)}\n title={payload?.title}\n />\n )\n})\n"],"mappings":";;;;;;;;AAWA,IAAM,IAAA,CAAU,GAAoB,OAAoD;AAAA,EACtF,GAAG;AAAA,EACH,iBAAA;AACF,IAQa,IAAyB,EAAS,SAAgC,EAC7E,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,WAAA,EAAA,IAAc,EAAe,GAC/B,EAAE,QAAQ,GAAY,eAAe,EAAA,IAAqB,EAAmB,GAC7E,EAAE,UAAA,EAAA,IAAa,EAAgB,GAC/B,IAAO,GAAkB;AAE/B,MAAI,CAAC,EAAU,cAAe,QAAO,gBAAA,EAAC,GAAD,CAAS,CAAA;AAI9C,MAAI,CAAC,EACH,QACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI,EAAE,GAAG,GAAG;AAAA,IACjB,UAAA,gBAAA,EAAC,GAAD,EAAA,UAAO,GAAY,iBAAiB,wBAA8B,CAAA;AAAA,EAC7D,CAAA;AAIX,QAAM,IAAU,EAAK,kBACf,IAAO,GAAS,oBAChB,IAAuB,IAAI,IAC/B,EAAS,IAAA,CAAK,MAAY,CAAC,EAAQ,MAAM,EAAQ,oBAAoB,EAAE,CAAC,CAC1E,GACM,IAAQ,EAAa,GAAM,WAAW,EAAE,IAAA,CAAK,MACjD,EAAO,GAAK,EAAqB,IAAI,EAAI,IAAI,KAAK,EAAE,CACtD;AAEA,SACE,gBAAA,EAAC,GAAD;AAAA,IACS,OAAA;AAAA,IACD,MAAA;AAAA,IACN,iBAAiB,GAAS,aAAa;AAAA,IACvC,SAAS,EAAY,CAAI;AAAA,IACzB,OAAO,GAAS;AAAA,EACjB,CAAA;AAEL,CAAC"}
1
+ {"version":3,"file":"CreditUtilizationBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport { useAccountStore, useGlobalCopyStore } from '../../../common'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { BlockErrorMessage } from '../BlockErrorMessage'\n\nimport CreditUtilizationContent, { type CreditUtilizationCard } from './CreditUtilizationContent'\nimport { readCardRows, readSummary, type CreditCardRow } from './layout'\n\nconst toCard = (row: CreditCardRow, institutionGuid: string): CreditUtilizationCard => ({\n ...row,\n institutionGuid,\n})\n\n/**\n * Credit Utilization drawer (MEW2-3356): the beat's donut summary, the utilization legend and one\n * row per card from `instance_slot_data.data_series`. Rows are joined to the loaded accounts by guid\n * for the institution logo only, so the drawer renders as soon as copy is in and the logos fill in\n * when the accounts arrive. `observer`: reads copy and accounts from MobX stores.\n */\nexport const CreditUtilizationBlock = observer(function CreditUtilizationBlock({\n beat,\n}: ActionBlockProps) {\n const { insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { accounts } = useAccountStore()\n const copy = insightsFeedCopy?.credit_utilization\n\n if (!copy) {\n return <BlockErrorMessage />\n }\n\n const payload = beat.insights_payload\n const data = payload?.instance_slot_data\n const institutionByAccount = new Map(\n accounts.map((account) => [account.guid, account.institution_guid ?? '']),\n )\n const cards = readCardRows(data?.data_series).map((row) =>\n toCard(row, institutionByAccount.get(row.guid) ?? ''),\n )\n\n return (\n <CreditUtilizationContent\n cards={cards}\n copy={copy}\n descriptionHtml={payload?.description?.html_text}\n summary={readSummary(data)}\n title={payload?.title}\n />\n )\n})\n"],"mappings":";;;;;;AASA,IAAM,IAAA,CAAU,GAAoB,OAAoD;AAAA,EACtF,GAAG;AAAA,EACH,iBAAA;AACF,IAQa,IAAyB,EAAS,SAAgC,EAC7E,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,eAAe,EAAA,IAAqB,EAAmB,GACzD,EAAE,UAAA,EAAA,IAAa,EAAgB,GAC/B,IAAO,GAAkB;AAE/B,MAAI,CAAC,EACH,QAAO,gBAAA,EAAC,GAAD,CAAoB,CAAA;AAG7B,QAAM,IAAU,EAAK,kBACf,IAAO,GAAS,oBAChB,IAAuB,IAAI,IAC/B,EAAS,IAAA,CAAK,MAAY,CAAC,EAAQ,MAAM,EAAQ,oBAAoB,EAAE,CAAC,CAC1E,GACM,IAAQ,EAAa,GAAM,WAAW,EAAE,IAAA,CAAK,MACjD,EAAO,GAAK,EAAqB,IAAI,EAAI,IAAI,KAAK,EAAE,CACtD;AAEA,SACE,gBAAA,EAAC,GAAD;AAAA,IACS,OAAA;AAAA,IACD,MAAA;AAAA,IACN,iBAAiB,GAAS,aAAa;AAAA,IACvC,SAAS,EAAY,CAAI;AAAA,IACzB,OAAO,GAAS;AAAA,EACjB,CAAA;AAEL,CAAC"}