@mx-cartographer/experiences 9.7.126 → 9.7.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js +101 -105
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js +44 -43
- package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +66 -65
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js +24 -30
- package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +84 -101
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
- package/dist/insights-v2/components/CategoryTile.d.ts +14 -0
- package/dist/insights-v2/components/CategoryTile.es.js +28 -0
- package/dist/insights-v2/components/CategoryTile.es.js.map +1 -0
- package/dist/insights-v2/components/ComponentBlocks/DepositLogo.d.ts +5 -16
- package/dist/insights-v2/components/ComponentBlocks/DepositLogo.es.js +14 -17
- package/dist/insights-v2/components/ComponentBlocks/DepositLogo.es.js.map +1 -1
- package/dist/insights-v2/components/LogoFromGuid.d.ts +3 -13
- package/dist/insights-v2/components/LogoFromGuid.es.js +21 -46
- package/dist/insights-v2/components/LogoFromGuid.es.js.map +1 -1
- package/dist/insights-v2/components/LogoMark.d.ts +19 -0
- package/dist/insights-v2/components/LogoMark.es.js +33 -0
- package/dist/insights-v2/components/LogoMark.es.js.map +1 -0
- package/dist/insights-v2/components/SubHeader.es.js +13 -27
- package/dist/insights-v2/components/SubHeader.es.js.map +1 -1
- package/dist/insights-v2/components/shared/EntityLogo.d.ts +2 -2
- package/dist/insights-v2/components/shared/EntityLogo.es.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## [9.7.128] - 11-10-2026
|
|
2
|
+
|
|
3
|
+
- **FIXED** - A budget for a sub-category shows its top-level category's icon and colour on the Insights V2 budget card and the Budget Details drawer instead of the Uncategorized ones, and the Transaction History header's merchant fallback tile does the same (WEC-2259)
|
|
4
|
+
- **FIXED** - A merchant budget card's logo is the size of a category budget's tile (44px), as Figma and the Budget Details drawer have it (WEC-2259)
|
|
5
|
+
- **FIXED** - An Insights V2 transaction row draws no icon, instead of an empty box, for an icon name mx-icons does not define (WEC-2259)
|
|
6
|
+
|
|
7
|
+
## [9.7.127] - 11-10-2026
|
|
8
|
+
|
|
9
|
+
- **FIXED** - An Insights V2 card's subtitle shows a sub-category as its top-level category icon instead of the Uncategorized glyph, and draws nothing instead of an empty box for an icon name mx-icons does not define (WEC-2259)
|
|
10
|
+
|
|
1
11
|
## [9.7.126] - 11-10-2026
|
|
2
12
|
|
|
3
13
|
- **CHANGED** - Insights V2 cards drop a slot value of the wrong kind (for example a number where text is expected) instead of passing it through; valid slots render the same (WEC-2259)
|
|
@@ -1,57 +1,53 @@
|
|
|
1
|
-
import { buildDynamicCopy as
|
|
2
|
-
import { DATE_FORMATS_INTL as
|
|
3
|
-
import { useBudgetsStore as
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { exportTransactionsToCSV as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { budgetMonthRange as
|
|
11
|
-
import { ANALYTICS_EVENTS_CONFIG as
|
|
12
|
-
import { useAnalyticsEvent as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
1
|
+
import { buildDynamicCopy as P } from "../../../core/utils/Localization.es.js";
|
|
2
|
+
import { DATE_FORMATS_INTL as de, formatDate as le } from "../../../core/constants/DateFormats.es.js";
|
|
3
|
+
import { useBudgetsStore as ue, useCategoryStore as me, useGlobalCopyStore as ge, useGlobalStore as _e, useInsightsV2Store as pe, useTransactionStore as fe } from "../../../common/context/hooks.es.js";
|
|
4
|
+
import ye from "../../../common/components/drawer/Drawer.es.js";
|
|
5
|
+
import { getLocalizedCategoryName as he } from "../../../core/utils/CategoryUtil.es.js";
|
|
6
|
+
import { exportTransactionsToCSV as be } from "../../../core/utils/TransactionUtils.es.js";
|
|
7
|
+
import Te from "../../../common/components/Loader.es.js";
|
|
8
|
+
import Ce from "../../../common/components/CurrencyDialog.es.js";
|
|
9
|
+
import ve from "../../../transactions/components/shared/TransactionList.es.js";
|
|
10
|
+
import { budgetMonthRange as De, daysLeftInBudgetMonth as xe, isPositiveAmount as Be, recordedActiveAtOf as Se, resolveBudgetDetailsLayout as Ae, resolveBudgetFacts as Ee } from "./layout.es.js";
|
|
11
|
+
import { ANALYTICS_EVENTS_CONFIG as T } from "../../analytics/analyticsEventsConfig.es.js";
|
|
12
|
+
import { useAnalyticsEvent as ke } from "../../analytics/useAnalyticsEvent.es.js";
|
|
13
|
+
import Ge from "../../components/CategoryTile.es.js";
|
|
14
|
+
import Le from "../../components/LogoMark.es.js";
|
|
15
|
+
import we from "../../components/shared/StatusSnackbar.es.js";
|
|
16
|
+
import { getDynamicCtaBasedOnTriggers as Ie } from "../util.es.js";
|
|
15
17
|
import { TransactionDetailsBlock as Me } from "../TransactionDetailsBlock/TransactionDetailsBlock.es.js";
|
|
16
18
|
import { BudgetSummary as Ne } from "./BudgetSummary.es.js";
|
|
17
|
-
import { useRef as Oe, useState as
|
|
19
|
+
import { useRef as Oe, useState as C } from "react";
|
|
18
20
|
import { observer as Re } from "mobx-react-lite";
|
|
19
|
-
import
|
|
20
|
-
import {
|
|
21
|
+
import f from "@mui/material/Stack";
|
|
22
|
+
import { Text as G } from "@mxenabled/mxui";
|
|
21
23
|
import L from "@mui/material/Button";
|
|
22
|
-
import { Icon as
|
|
24
|
+
import { Icon as Ve } from "@mxenabled/mx-icons";
|
|
23
25
|
import { jsx as t, jsxs as v } from "react/jsx-runtime";
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (!
|
|
29
|
-
if (!N) return /* @__PURE__ */ t(y, {
|
|
26
|
+
import je from "@mui/material/Box";
|
|
27
|
+
var gt = Re(function({ beat: n }) {
|
|
28
|
+
const { copyStore: H, emitUpdate: Y } = _e(), { budgets: o, categories: $, common: l, insights_feed: D, transactions: W } = ge(), u = ue(), q = me(), w = fe(), m = pe(), y = ke(), [r, x] = C(null), [g, h] = C(""), [a, _] = C(null), [J, I] = C(!1), B = Oe(!1), M = D?.budget_details, { categories: K } = q, i = Ee(n), N = Se(m, n), Q = De(n, N), { primary_cta: X, secondary_cta: Z, in_description_cta: ee } = n.insights_payload ?? {}, te = Ie(m.actionDrawer, X, Z, ee)?.variant, { showPeriodLine: oe } = Ae(te);
|
|
29
|
+
if (!H.isInitialized) return /* @__PURE__ */ t(Te, {});
|
|
30
|
+
if (!M) return /* @__PURE__ */ t(f, {
|
|
30
31
|
sx: { p: 24 },
|
|
31
|
-
children: /* @__PURE__ */ t(
|
|
32
|
+
children: /* @__PURE__ */ t(G, { children: l?.error_message })
|
|
32
33
|
});
|
|
33
|
-
const
|
|
34
|
-
categoryGuid:
|
|
34
|
+
const O = i.categoryGuid ? K.find(({ guid: e }) => e === i.categoryGuid) : void 0, s = 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 && he(O, $)) ?? c?.merchant_name ?? n.payload?.merchant_name ?? "", V = s?.amount ?? c?.amount ?? i.budgeted ?? 0, re = i.spent ?? s?.transaction_total ?? c?.transaction_total ?? 0, ie = i.categoryGuid ? /* @__PURE__ */ t(Ge, {
|
|
35
|
+
categoryGuid: i.categoryGuid,
|
|
35
36
|
size: 44,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
color: "text.primary"
|
|
40
|
-
}
|
|
41
|
-
}) : /* @__PURE__ */ t(je, {
|
|
42
|
-
categoryGuid: "",
|
|
43
|
-
merchantGuid: r.merchantGuid ?? "",
|
|
37
|
+
tint: 0.15
|
|
38
|
+
}) : /* @__PURE__ */ t(Le, {
|
|
39
|
+
logo: { merchant_guid: i.merchantGuid },
|
|
44
40
|
size: 44
|
|
45
|
-
}),
|
|
46
|
-
e === "delete" &&
|
|
41
|
+
}), j = w.sortedTransactionsWithSplits, F = (e) => {
|
|
42
|
+
e === "delete" && y(T.BUDGET_DELETE_START), h(e === "edit" ? String(V) : ""), x(e);
|
|
43
|
+
}, U = () => {
|
|
44
|
+
x(null), h("");
|
|
47
45
|
}, z = () => {
|
|
48
|
-
|
|
49
|
-
}, P = () => {
|
|
50
|
-
i === "delete" && f(C.BUDGET_DELETE_CANCEL), z();
|
|
51
|
-
}, d = (e) => $(e, V), S = (e) => d({
|
|
46
|
+
r === "delete" && y(T.BUDGET_DELETE_CANCEL), U();
|
|
47
|
+
}, d = (e) => P(e, R), S = (e) => d({
|
|
52
48
|
edit: o.error_alert_edit_merchant_budget,
|
|
53
49
|
delete: o.error_alert_delete_merchant_budget
|
|
54
|
-
}[e]),
|
|
50
|
+
}[e]), ne = async (e, p) => {
|
|
55
51
|
if (c) {
|
|
56
52
|
if (e === "delete") {
|
|
57
53
|
const { isSuccess: b } = await u.deleteMerchantBudget(c.guid);
|
|
@@ -61,12 +57,12 @@ var yt = Re(function({ beat: n }) {
|
|
|
61
57
|
failure: d(o.error_alert_delete_merchant_budget)
|
|
62
58
|
};
|
|
63
59
|
}
|
|
64
|
-
const { isSuccess:
|
|
60
|
+
const { isSuccess: k } = await u.updateMerchantBudget({
|
|
65
61
|
...c,
|
|
66
|
-
amount:
|
|
62
|
+
amount: p
|
|
67
63
|
});
|
|
68
64
|
return {
|
|
69
|
-
ok:
|
|
65
|
+
ok: k,
|
|
70
66
|
success: d(o.success_alert_edit_merchant_budget),
|
|
71
67
|
failure: d(o.error_alert_edit_merchant_budget)
|
|
72
68
|
};
|
|
@@ -78,7 +74,7 @@ var yt = Re(function({ beat: n }) {
|
|
|
78
74
|
} : e === "edit" && s ? {
|
|
79
75
|
ok: await u.updateBudget({
|
|
80
76
|
...s,
|
|
81
|
-
amount:
|
|
77
|
+
amount: p
|
|
82
78
|
}),
|
|
83
79
|
success: d(o.alert_budget_updated),
|
|
84
80
|
failure: S(e)
|
|
@@ -86,47 +82,47 @@ var yt = Re(function({ beat: n }) {
|
|
|
86
82
|
ok: !1,
|
|
87
83
|
success: ""
|
|
88
84
|
};
|
|
89
|
-
},
|
|
90
|
-
if (B.current || !
|
|
85
|
+
}, ae = async () => {
|
|
86
|
+
if (B.current || !r) return;
|
|
91
87
|
const e = Number(g);
|
|
92
|
-
if (
|
|
88
|
+
if (r !== "delete" && !Be(g)) return;
|
|
93
89
|
B.current = !0;
|
|
94
|
-
const
|
|
95
|
-
action:
|
|
90
|
+
const p = {
|
|
91
|
+
action: r,
|
|
96
92
|
amount: g
|
|
97
93
|
};
|
|
98
94
|
try {
|
|
99
|
-
const { ok:
|
|
100
|
-
if (
|
|
101
|
-
if (
|
|
102
|
-
...
|
|
95
|
+
const { ok: k, success: b, failure: ce } = await ne(r, e);
|
|
96
|
+
if (k) {
|
|
97
|
+
if (Y({ staleBeatGuid: n.guid }), r === "edit" && y({
|
|
98
|
+
...T.BUDGET_EDIT_SAVE,
|
|
103
99
|
value: g
|
|
104
|
-
}),
|
|
105
|
-
|
|
100
|
+
}), r === "delete") {
|
|
101
|
+
y(T.BUDGET_DELETE_END), m.setActionNotice(n.guid, {
|
|
106
102
|
message: b,
|
|
107
103
|
severity: "success"
|
|
108
104
|
}), m.closeActionDrawer();
|
|
109
105
|
return;
|
|
110
106
|
}
|
|
111
|
-
|
|
107
|
+
_({
|
|
112
108
|
message: b,
|
|
113
109
|
severity: "success"
|
|
114
110
|
});
|
|
115
|
-
} else
|
|
116
|
-
message:
|
|
111
|
+
} else _({
|
|
112
|
+
message: ce ?? l.error_message,
|
|
117
113
|
severity: "error",
|
|
118
|
-
retry:
|
|
114
|
+
retry: p
|
|
119
115
|
});
|
|
120
116
|
} catch {
|
|
121
|
-
|
|
122
|
-
message: S(
|
|
117
|
+
_({
|
|
118
|
+
message: S(r),
|
|
123
119
|
severity: "error",
|
|
124
|
-
retry:
|
|
120
|
+
retry: p
|
|
125
121
|
});
|
|
126
122
|
} finally {
|
|
127
|
-
B.current = !1,
|
|
123
|
+
B.current = !1, U();
|
|
128
124
|
}
|
|
129
|
-
},
|
|
125
|
+
}, se = !!(s ?? c) && /* @__PURE__ */ v(f, {
|
|
130
126
|
sx: {
|
|
131
127
|
bgcolor: "background.paper",
|
|
132
128
|
borderTop: 1,
|
|
@@ -142,15 +138,15 @@ var yt = Re(function({ beat: n }) {
|
|
|
142
138
|
},
|
|
143
139
|
children: [/* @__PURE__ */ t(L, {
|
|
144
140
|
color: "error",
|
|
145
|
-
onClick: () =>
|
|
141
|
+
onClick: () => F("delete"),
|
|
146
142
|
variant: "outlined",
|
|
147
143
|
children: o.details_delete_button
|
|
148
144
|
}), /* @__PURE__ */ t(L, {
|
|
149
|
-
onClick: () =>
|
|
145
|
+
onClick: () => F("edit"),
|
|
150
146
|
variant: "contained",
|
|
151
147
|
children: o.details_edit_button
|
|
152
148
|
})]
|
|
153
|
-
}), A =
|
|
149
|
+
}), A = r === "delete", E = {
|
|
154
150
|
edit: {
|
|
155
151
|
content: o.edit_budget_content,
|
|
156
152
|
primaryText: o.add_save_button,
|
|
@@ -162,90 +158,90 @@ var yt = Re(function({ beat: n }) {
|
|
|
162
158
|
title: o.delete_title
|
|
163
159
|
}
|
|
164
160
|
};
|
|
165
|
-
return /* @__PURE__ */ v(
|
|
161
|
+
return /* @__PURE__ */ v(f, {
|
|
166
162
|
sx: { minHeight: "100%" },
|
|
167
163
|
children: [
|
|
168
|
-
/* @__PURE__ */ v(
|
|
164
|
+
/* @__PURE__ */ v(f, {
|
|
169
165
|
sx: {
|
|
170
166
|
bgcolor: "background.paper",
|
|
171
167
|
gap: 16,
|
|
172
168
|
p: 24
|
|
173
169
|
},
|
|
174
|
-
children: [/* @__PURE__ */ v(
|
|
170
|
+
children: [/* @__PURE__ */ v(f, {
|
|
175
171
|
sx: {
|
|
176
172
|
alignItems: "center",
|
|
177
173
|
flexDirection: "row",
|
|
178
174
|
justifyContent: "space-between"
|
|
179
175
|
},
|
|
180
|
-
children: [/* @__PURE__ */ t(
|
|
176
|
+
children: [/* @__PURE__ */ t(G, {
|
|
181
177
|
bold: !0,
|
|
182
178
|
variant: "body1",
|
|
183
|
-
children:
|
|
184
|
-
}),
|
|
185
|
-
onClick: () =>
|
|
186
|
-
startIcon: /* @__PURE__ */ t(
|
|
179
|
+
children: le(Q.start, de.MONTH_YEAR)
|
|
180
|
+
}), j.length > 0 && /* @__PURE__ */ t(L, {
|
|
181
|
+
onClick: () => be(j, w.tags),
|
|
182
|
+
startIcon: /* @__PURE__ */ t(Ve, { name: "ios_share" }),
|
|
187
183
|
sx: { height: 28 },
|
|
188
|
-
children: /* @__PURE__ */ t(
|
|
184
|
+
children: /* @__PURE__ */ t(G, {
|
|
189
185
|
bold: !0,
|
|
190
186
|
variant: "body2",
|
|
191
|
-
children:
|
|
187
|
+
children: W.export_csv_btn
|
|
192
188
|
})
|
|
193
189
|
})]
|
|
194
190
|
}), /* @__PURE__ */ t(Ne, {
|
|
195
191
|
budgetsCopy: o,
|
|
196
|
-
copy:
|
|
197
|
-
daysLeft:
|
|
198
|
-
icon:
|
|
199
|
-
limit:
|
|
200
|
-
showPeriodLine:
|
|
201
|
-
spent:
|
|
192
|
+
copy: M,
|
|
193
|
+
daysLeft: xe(n, void 0, N),
|
|
194
|
+
icon: ie,
|
|
195
|
+
limit: V,
|
|
196
|
+
showPeriodLine: oe,
|
|
197
|
+
spent: re
|
|
202
198
|
})]
|
|
203
199
|
}),
|
|
204
|
-
/* @__PURE__ */ t(
|
|
200
|
+
/* @__PURE__ */ t(je, {
|
|
205
201
|
sx: {
|
|
206
202
|
bgcolor: "background.default",
|
|
207
203
|
flexGrow: 1
|
|
208
204
|
},
|
|
209
|
-
children: /* @__PURE__ */ t(
|
|
210
|
-
m.setActionContext({ transaction_guid: e }),
|
|
205
|
+
children: /* @__PURE__ */ t(ve, { onClick: (e) => {
|
|
206
|
+
m.setActionContext({ transaction_guid: e }), I(!0);
|
|
211
207
|
} })
|
|
212
208
|
}),
|
|
213
|
-
|
|
214
|
-
|
|
209
|
+
se,
|
|
210
|
+
r && /* @__PURE__ */ t(Ce, {
|
|
215
211
|
closeAriaLabel: l.close_aria,
|
|
216
|
-
content:
|
|
212
|
+
content: P(E[r].content, /* @__PURE__ */ t("b", { children: R })),
|
|
217
213
|
handleInputChange: h,
|
|
218
|
-
handleModalClose:
|
|
214
|
+
handleModalClose: z,
|
|
219
215
|
handlePrimaryAction: () => {
|
|
220
|
-
|
|
216
|
+
ae();
|
|
221
217
|
},
|
|
222
|
-
handleSecondaryAction:
|
|
218
|
+
handleSecondaryAction: z,
|
|
223
219
|
inputLabel: A ? void 0 : o.add_label,
|
|
224
220
|
inputValue: g,
|
|
225
221
|
isOpen: !0,
|
|
226
222
|
primaryColor: A ? "error" : "primary",
|
|
227
|
-
primaryText:
|
|
223
|
+
primaryText: E[r].primaryText,
|
|
228
224
|
secondaryColor: A ? "inherit" : "primary",
|
|
229
225
|
secondaryText: l.cancel_button,
|
|
230
|
-
title:
|
|
226
|
+
title: E[r].title
|
|
231
227
|
}),
|
|
232
|
-
/* @__PURE__ */ t(
|
|
228
|
+
/* @__PURE__ */ t(ye, {
|
|
233
229
|
ariaLabelClose: l.close_aria,
|
|
234
|
-
isOpen:
|
|
230
|
+
isOpen: J,
|
|
235
231
|
onClose: () => {
|
|
236
|
-
|
|
232
|
+
I(!1), m.setActionContext({ transaction_guid: void 0 });
|
|
237
233
|
},
|
|
238
|
-
title:
|
|
234
|
+
title: D.general.transaction_details_title,
|
|
239
235
|
children: /* @__PURE__ */ t(Me, { beat: n })
|
|
240
236
|
}),
|
|
241
|
-
/* @__PURE__ */ t(
|
|
242
|
-
actionText: a?.retry ?
|
|
237
|
+
/* @__PURE__ */ t(we, {
|
|
238
|
+
actionText: a?.retry ? D?.general?.try_again : void 0,
|
|
243
239
|
closeAriaLabel: l.close_aria,
|
|
244
240
|
message: a?.message ?? "",
|
|
245
241
|
onActionClick: () => {
|
|
246
|
-
a?.retry && (h(a.retry.amount),
|
|
242
|
+
a?.retry && (h(a.retry.amount), x(a.retry.action), _(null));
|
|
247
243
|
},
|
|
248
|
-
onClose: () =>
|
|
244
|
+
onClose: () => _(null),
|
|
249
245
|
open: !!a,
|
|
250
246
|
severity: a?.severity
|
|
251
247
|
})
|
|
@@ -253,7 +249,7 @@ var yt = Re(function({ beat: n }) {
|
|
|
253
249
|
});
|
|
254
250
|
});
|
|
255
251
|
export {
|
|
256
|
-
|
|
252
|
+
gt as BudgetDetailsBlock
|
|
257
253
|
};
|
|
258
254
|
|
|
259
255
|
//# 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'\nimport { alpha, useTheme } from '@mui/material/styles'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { CategoryIcon, MerchantLogo, 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 { getDynamicCtaBasedOnTriggers } from '../util'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport { buildDynamicCopy } from '../../../core/utils/Localization'\nimport { exportTransactionsToCSV } from '../../../core/utils/TransactionUtils'\nimport { getCategoryColor, getLocalizedCategoryName } from '../../../core/utils/CategoryUtil'\nimport type { Budget, MerchantBudget } from '../../../core'\nimport { TransactionList } from '../../../transactions'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\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 theme = useTheme()\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 { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n const variant = getDynamicCtaBasedOnTriggers(\n insightsV2Store.actionDrawer,\n primary_cta,\n secondary_cta,\n in_description_cta,\n )?.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 <CategoryIcon\n categoryGuid={facts.categoryGuid}\n size={44}\n sx={{\n bgcolor: alpha(getCategoryColor(facts.categoryGuid, theme), 0.15),\n border: `1px solid ${getCategoryColor(facts.categoryGuid, theme)}`,\n color: 'text.primary',\n }}\n />\n ) : (\n <MerchantLogo categoryGuid=\"\" merchantGuid={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":";;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,IAAa,KAAqB,GAAS,SAA4B,EAAE,MAAA,EAAA,GAA0B;AACjG,QAAM,IAAQ,GAAS,GACjB,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,EAAE,aAAA,IAAa,eAAA,IAAe,oBAAA,GAAA,IAAuB,EAAK,oBAAoB,CAAC,GAC/E,KAAU,GACd,EAAgB,cAChB,IACA,IACA,EACF,GAAG,SACG,EAAE,gBAAA,GAAA,IAAmB,GAA2B,EAAO;AAE7D,MAAI,CAAC,EAAU,cAAe,QAAO,gBAAA,EAAC,IAAD,CAAS,CAAA;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AA,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
|
+
{"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 { getDynamicCtaBasedOnTriggers } from '../util'\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 { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n const variant = getDynamicCtaBasedOnTriggers(\n insightsV2Store.actionDrawer,\n primary_cta,\n secondary_cta,\n in_description_cta,\n )?.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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ACnB,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,90 +1,91 @@
|
|
|
1
|
-
import { CategoryGuids as
|
|
2
|
-
import { DEFAULT_INSTITUTION_LOGO_URL as
|
|
3
|
-
import
|
|
4
|
-
import { useAccountStore as
|
|
5
|
-
import { getAccountStartingBalance as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { CategoryGuids as L } from "../../../core/constants/Category.es.js";
|
|
2
|
+
import { DEFAULT_INSTITUTION_LOGO_URL as T } from "../../../core/constants/InstitutionLogo.es.js";
|
|
3
|
+
import R from "../../../common/utils/AccountDisplayName.es.js";
|
|
4
|
+
import { useAccountStore as G, useActionContext as S, useAppConfig as w, useCashflowStore as A, useGlobalCopyStore as U, useRecurringTransactionsStore as E, useTransactionStore as I } from "../../../common/context/hooks.es.js";
|
|
5
|
+
import { getAccountStartingBalance as O } from "../../../core/utils/AccountUtils.es.js";
|
|
6
|
+
import b from "../../../common/components/Loader.es.js";
|
|
7
|
+
import d from "../../components/CategoryTile.es.js";
|
|
8
|
+
import { ErrorCard as k } from "../../components/ErrorCard.es.js";
|
|
9
|
+
import { useRecurringTransactionLoad as v } from "../RecurringTransactionBlock/useRecurringTransactionPrepare.es.js";
|
|
10
|
+
import { getCaption as N, getOtherLabel as D, groupRows as F } from "./layout.es.js";
|
|
11
|
+
import z from "./RemainingCashContent.es.js";
|
|
12
|
+
import { observer as B } from "mobx-react-lite";
|
|
13
|
+
import H from "@mui/material/Stack";
|
|
14
|
+
import { InstitutionLogo as p, Text as P } from "@mxenabled/mxui";
|
|
15
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
16
|
+
var g = (m, i, s) => {
|
|
17
|
+
const { others: a, shown: r } = F(m);
|
|
17
18
|
return a ? [...r, {
|
|
18
19
|
amount: a.total,
|
|
19
20
|
key: "other",
|
|
20
21
|
leading: s,
|
|
21
|
-
name:
|
|
22
|
+
name: D(i.one, i.multi, a.count)
|
|
22
23
|
}] : r;
|
|
23
|
-
},
|
|
24
|
-
const { common: s, insights_feed: a } =
|
|
25
|
-
if (a?.general && !o) return /* @__PURE__ */
|
|
24
|
+
}, to = B(function(i) {
|
|
25
|
+
const { common: s, insights_feed: a } = U(), { config: r } = w(), { uiStore: t } = A(), { accountsLoaded: l } = G(), { transactionsLoaded: u, transactionsLoading: h } = I(), { isDataLoaded: c } = E(), f = S()?.recurringLoadFailed === !0, _ = v(), y = c && !u && !h, o = a?.remaining_cash;
|
|
26
|
+
if (a?.general && !o) return /* @__PURE__ */ n(H, {
|
|
26
27
|
sx: { p: 24 },
|
|
27
|
-
children: /* @__PURE__ */
|
|
28
|
+
children: /* @__PURE__ */ n(P, { children: s?.error_message })
|
|
28
29
|
});
|
|
29
|
-
if (
|
|
30
|
-
|
|
30
|
+
if (f && !c || y) return /* @__PURE__ */ n(k, { onRetry: () => {
|
|
31
|
+
_();
|
|
31
32
|
} });
|
|
32
|
-
if (!c || !
|
|
33
|
-
const
|
|
34
|
-
amount:
|
|
33
|
+
if (!c || !l || !u || !o) return /* @__PURE__ */ n(b, {});
|
|
34
|
+
const C = g(t.selectedCashAccounts.map((e) => ({
|
|
35
|
+
amount: O(e, r.display_available_balance_in_accounts),
|
|
35
36
|
key: e.guid,
|
|
36
|
-
leading: /* @__PURE__ */
|
|
37
|
+
leading: /* @__PURE__ */ n(p, {
|
|
37
38
|
alt: "",
|
|
38
39
|
institutionGuid: e.institution_guid ?? "",
|
|
39
40
|
size: 32
|
|
40
41
|
}),
|
|
41
|
-
name:
|
|
42
|
+
name: R(e)
|
|
42
43
|
})), {
|
|
43
44
|
multi: o.other_accounts,
|
|
44
45
|
one: o.other_accounts_one
|
|
45
|
-
}, /* @__PURE__ */
|
|
46
|
+
}, /* @__PURE__ */ n(p, {
|
|
46
47
|
alt: "",
|
|
47
48
|
institutionGuid: "",
|
|
48
|
-
logoUrl:
|
|
49
|
+
logoUrl: T,
|
|
49
50
|
size: 32
|
|
50
|
-
})), x =
|
|
51
|
+
})), x = g(t.expensesTilNextIncome.map((e) => ({
|
|
51
52
|
amount: e.amount,
|
|
52
53
|
key: `${e.repeatingTransactionGuid}-${e.expectedDate.getTime()}`,
|
|
53
|
-
leading: /* @__PURE__ */
|
|
54
|
-
categoryGuid:
|
|
54
|
+
leading: /* @__PURE__ */ n(d, {
|
|
55
|
+
categoryGuid: e.categoryGuid,
|
|
55
56
|
size: 32
|
|
56
57
|
}),
|
|
57
58
|
name: e.name
|
|
58
59
|
})), {
|
|
59
60
|
multi: o.other_expenses,
|
|
60
61
|
one: o.other_expenses_one
|
|
61
|
-
}, /* @__PURE__ */
|
|
62
|
-
categoryGuid:
|
|
62
|
+
}, /* @__PURE__ */ n(d, {
|
|
63
|
+
categoryGuid: L.UNCATEGORIZED,
|
|
63
64
|
size: 32
|
|
64
65
|
}));
|
|
65
|
-
return /* @__PURE__ */
|
|
66
|
+
return /* @__PURE__ */ n(z, {
|
|
66
67
|
accounts: {
|
|
67
68
|
header: o.accounts_header,
|
|
68
|
-
rows:
|
|
69
|
+
rows: C
|
|
69
70
|
},
|
|
70
71
|
expenses: {
|
|
71
72
|
header: o.recurring_expenses_header,
|
|
72
73
|
rows: x
|
|
73
74
|
},
|
|
74
75
|
summary: {
|
|
75
|
-
remaining:
|
|
76
|
-
amount:
|
|
77
|
-
caption:
|
|
76
|
+
remaining: t.hasUpcomingPayday ? {
|
|
77
|
+
amount: t.remainingUntilPayday,
|
|
78
|
+
caption: N(o, t.daysUntilNextIncome)
|
|
78
79
|
} : void 0,
|
|
79
|
-
cashOnHand:
|
|
80
|
+
cashOnHand: t.selectedCashBalance,
|
|
80
81
|
cashOnHandLabel: o.cash_on_hand,
|
|
81
|
-
upcomingExpenses:
|
|
82
|
+
upcomingExpenses: t.upcomingExpensesTotal,
|
|
82
83
|
upcomingExpensesLabel: o.upcoming_expenses
|
|
83
84
|
}
|
|
84
85
|
});
|
|
85
86
|
});
|
|
86
87
|
export {
|
|
87
|
-
|
|
88
|
+
to as RemainingCashBlock
|
|
88
89
|
};
|
|
89
90
|
|
|
90
91
|
//# sourceMappingURL=RemainingCashBlock.es.js.map
|