@mx-cartographer/experiences 9.0.13 → 9.0.14

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.
@@ -1,902 +0,0 @@
1
- import { jsxs as c, jsx as e, Fragment as W } from "react/jsx-runtime";
2
- import d from "react";
3
- import { observer as M } from "mobx-react-lite";
4
- import j from "@mui/material/Box";
5
- import F from "@mui/material/Divider";
6
- import te from "@mui/material/List";
7
- import _ from "@mui/material/Stack";
8
- import { P as H, Text as f, MerchantLogo as ne, InstitutionLogo as Ne } from "@mxenabled/mxui";
9
- import Ge from "@mui/material/ListItem";
10
- import ue from "@mui/material/ListItemAvatar";
11
- import Ue from "@mui/material/ListItemButton";
12
- import me from "@mui/material/ListItemText";
13
- import { b as Pe, f as oe } from "./NumberFormatting--XMeeBfr.mjs";
14
- import { R as O, F as m, g as _e, a as E, c as Fe, d as ze } from "./RecurringTransactionsUtil-zOxq5pzY.mjs";
15
- import { subDays as pe } from "date-fns/subDays";
16
- import { startOfToday as P } from "date-fns/startOfToday";
17
- import { endOfMonth as Ye } from "date-fns/endOfMonth";
18
- import he from "@mui/material/Button";
19
- import { CheckCircle as Be, Cancel as We, Icon as Ke, ChevronRight as qe, Delete as je, Add as He, ReceiptLong as Qe } from "@mxenabled/mx-icons";
20
- import { T as $e } from "./TransactionDetails-DQ_eE7M4.mjs";
21
- import { a as Xe } from "./AccountDetailsDrawer-BuxLfuIm.mjs";
22
- import { u as Ze } from "./AccountDetailsHeader-ByGNPZpO.mjs";
23
- import { C as V } from "./Category-DEKZGLYe.mjs";
24
- import { T as ye } from "./TransactionUtils-BphBJBbU.mjs";
25
- import { u as fe, T as Je, S as Ve, a as et } from "./EmbeddedCard-BxgB26dd.mjs";
26
- import { u as k, h as Y, g as ae, f as K, a as tt, c as nt, C as ot } from "./hooks-97sNJ_lf.mjs";
27
- import { S as at } from "./SearchBox-Cpgu_gdO.mjs";
28
- import { D as z } from "./Drawer-DsnW2o0v.mjs";
29
- import { D as re } from "./Dialog-Bvd2n8hz.mjs";
30
- import { addYears as le } from "date-fns/addYears";
31
- import { getDayOfYear as rt } from "date-fns/getDayOfYear";
32
- import { setDayOfYear as it } from "date-fns/setDayOfYear";
33
- import { AdapterDateFns as st } from "@mui/x-date-pickers/AdapterDateFnsV3";
34
- import { DatePicker as ct } from "@mui/x-date-pickers";
35
- import { LocalizationProvider as lt } from "@mui/x-date-pickers/LocalizationProvider";
36
- import { S as q, D as ee } from "./Select-CSpkK5cR.mjs";
37
- import { A as D } from "./Analytics-WeZYytR0.mjs";
38
- import { fromUnixTime as ge } from "date-fns/fromUnixTime";
39
- import { getUnixTime as dt } from "date-fns/getUnixTime";
40
- import ut from "@mui/material/IconButton";
41
- import mt from "@mui/material/Menu";
42
- import _t from "@mui/material/MenuItem";
43
- import { L as pt } from "./ListItemWrapper-BHIbqx7E.mjs";
44
- import { f as Ce, D as be } from "./DateFormats-HudZ3Bjs.mjs";
45
- import ht from "@mui/material/Card";
46
- import yt from "@mui/material/CardActionArea";
47
- import { useTheme as ft, alpha as gt } from "@mui/material";
48
- import { B as Ct } from "./BeatMaterialIcon-1KOfRZrA.mjs";
49
- import { formatISO as bt } from "date-fns/formatISO";
50
- import { k as St } from "./DateUtil-CzBmbjmA.mjs";
51
- const Q = (n) => n.top_level_category_guid !== V.INCOME && n.transaction_type === ye.DEBIT, Se = (n, t) => Q(n) ? n.payee?.toLowerCase().includes(t.toLowerCase()) || n.description.toLowerCase().includes(t.toLowerCase()) || n.feed_description.toLowerCase().includes(t.toLowerCase()) : !1, $ = (n) => n.top_level_category_guid === V.INCOME || n.top_level_category_guid === V.TRANSFER && n.transaction_type === ye.CREDIT, xe = (n, t) => $(n) ? n.payee?.toLowerCase().includes(t.toLowerCase()) || n.description?.toLowerCase().includes(t.toLowerCase()) || n.feed_description?.toLowerCase().includes(t.toLowerCase()) : !1, ke = M(
52
- ({
53
- bgcolor: n = "background.default",
54
- description: t,
55
- onSearch: r,
56
- onSelected: i
57
- }) => {
58
- const { recurring: a } = k(), { searchValue: u, setSearchValue: o } = fe();
59
- return /* @__PURE__ */ c(_, { sx: { bgcolor: n, gap: 16, pt: 8 }, children: [
60
- t && /* @__PURE__ */ e(H, { sx: { mx: 24 }, children: t }),
61
- /* @__PURE__ */ e(
62
- at,
63
- {
64
- ariaLabel: a.select_transaction_search_aria,
65
- cancelAriaLabel: a.select_transaction_search_cancel_aria,
66
- onChange: (l) => {
67
- o(l), r(l);
68
- },
69
- placeholder: a.select_transaction_search_placeholder,
70
- searchValue: u
71
- }
72
- ),
73
- /* @__PURE__ */ e(
74
- Je,
75
- {
76
- bgcolor: n,
77
- filter: (l) => !!l.merchant_guid,
78
- height: "auto",
79
- onClick: i,
80
- showLoader: !1
81
- }
82
- )
83
- ] });
84
- }
85
- ), de = (n, t) => (r) => {
86
- if (r.repeating_transaction_guid) return !1;
87
- const i = n.repeating_transaction_type === O.Income;
88
- return t ? i ? xe(r, t) : Se(r, t) : i ? $(r) : Q(r);
89
- }, xt = M(
90
- ({ isOpen: n, onClose: t, recurringTransaction: r }) => {
91
- const { recurring: i } = k(), { markRecurrenceAsPaid: a } = Y(), { filter: u, setFilter: o, transactions: l } = ae(), { setSearchValue: h } = fe();
92
- d.useEffect(() => {
93
- n ? o({ ...u, custom: de(r) }) : h("");
94
- }, [n, r]);
95
- const p = (y) => {
96
- o({ ...u, custom: de(r, y) });
97
- }, C = async (y) => {
98
- const b = l.find((S) => S.guid === y);
99
- b && (await a(r.guid, b), t());
100
- };
101
- return /* @__PURE__ */ e(
102
- z,
103
- {
104
- ariaLabelClose: i.close_drawer_aria,
105
- isOpen: n,
106
- onClose: t,
107
- title: i.link_transaction_button,
108
- children: /* @__PURE__ */ e(ke, { onSearch: p, onSelected: C })
109
- }
110
- );
111
- }
112
- ), kt = ({ isOpen: n, onClose: t, onLinkTransaction: r }) => {
113
- const { recurring: i } = k();
114
- return /* @__PURE__ */ e(
115
- re,
116
- {
117
- copy: {
118
- title: i.mark_as_paid_dialog_title,
119
- close_aria: i.close_drawer_aria
120
- },
121
- isOpen: n,
122
- maxWidth: "xs",
123
- onClose: t,
124
- onPrimaryAction: r,
125
- primaryText: i.link_transaction_button,
126
- sx: {
127
- "& .MuiStack-root, & .MuiDialogContent-root": {
128
- backgroundColor: "background.paper"
129
- }
130
- },
131
- children: /* @__PURE__ */ e(f, { truncate: !1, children: i.link_transaction_description })
132
- }
133
- );
134
- }, At = ({
135
- isOpen: n,
136
- onClose: t,
137
- onUnlinkTransaction: r
138
- }) => {
139
- const { recurring: i } = k();
140
- return /* @__PURE__ */ e(
141
- re,
142
- {
143
- copy: {
144
- title: i.mark_as_unpaid_dialog_title,
145
- close_aria: i.close_drawer_aria
146
- },
147
- isOpen: n,
148
- maxWidth: "xs",
149
- onClose: t,
150
- onPrimaryAction: r,
151
- primaryText: i.unlink_transaction_button,
152
- sx: {
153
- "& .MuiStack-root, & .MuiDialogContent-root": {
154
- backgroundColor: "background.paper"
155
- }
156
- },
157
- children: /* @__PURE__ */ e(f, { truncate: !1, children: i.unlink_transaction_description })
158
- }
159
- );
160
- }, Ae = ({
161
- frequency: n,
162
- firstDay: t,
163
- secondDay: r,
164
- onFrequencyChange: i,
165
- onFirstDayChange: a,
166
- onSecondDayChange: u
167
- }) => {
168
- const { recurring: o } = k(), l = d.useMemo(
169
- () => [
170
- { id: m.EveryWeek, label: o.frequency_every_week },
171
- { id: m.EveryOtherWeek, label: o.frequency_every_other_week },
172
- { id: m.TwiceAMonth, label: o.frequency_twice_a_month },
173
- { id: m.EveryMonth, label: o.frequency_every_month },
174
- { id: m.EveryOtherMonth, label: o.frequency_every_other_month },
175
- { id: m.EveryQuarter, label: o.frequency_every_quarter },
176
- { id: m.EveryOtherQuarter, label: o.frequency_every_other_quarter },
177
- { id: m.EveryYear, label: o.frequency_every_year }
178
- ],
179
- [o]
180
- ), h = [
181
- { id: 0, label: o.weekday_sunday },
182
- { id: 1, label: o.weekday_monday },
183
- { id: 2, label: o.weekday_tuesday },
184
- { id: 3, label: o.weekday_wednesday },
185
- { id: 4, label: o.weekday_thursday },
186
- { id: 5, label: o.weekday_friday },
187
- { id: 6, label: o.weekday_saturday }
188
- ], p = [...Array(31).keys()].map((x) => ({
189
- id: x + 1,
190
- label: Pe(x + 1)
191
- }));
192
- p[30].label += ` (${o.last_day_of_month})`;
193
- const C = p.slice(0, 15), y = p.slice(14), b = n === m.EveryWeek || n === m.EveryOtherWeek, S = n === m.TwiceAMonth || n === m.EveryMonth || n === m.EveryOtherMonth || n === m.EveryQuarter || n === m.EveryOtherQuarter, v = it(P(), t), w = v < P() ? le(v, 1) : v, T = (x) => {
194
- x && a(rt(x));
195
- };
196
- return /* @__PURE__ */ c(_, { gap: 24, sx: { m: 24 }, children: [
197
- /* @__PURE__ */ e(
198
- q,
199
- {
200
- label: o.frequency,
201
- onChange: i,
202
- options: l,
203
- value: n
204
- }
205
- ),
206
- b && /* @__PURE__ */ e(
207
- q,
208
- {
209
- label: o.day_of_the_week,
210
- onChange: a,
211
- options: h,
212
- value: t
213
- }
214
- ),
215
- S && /* @__PURE__ */ e(
216
- q,
217
- {
218
- label: n === m.TwiceAMonth ? o.first_day_of_the_month : o.day_of_the_month,
219
- onChange: a,
220
- options: n === m.TwiceAMonth ? C : p,
221
- value: t
222
- }
223
- ),
224
- n === m.TwiceAMonth && /* @__PURE__ */ e(
225
- q,
226
- {
227
- label: o.second_day_of_the_month,
228
- onChange: u,
229
- options: y,
230
- value: r || 0
231
- }
232
- ),
233
- n === m.EveryYear && /* @__PURE__ */ e(lt, { dateAdapter: st, children: /* @__PURE__ */ e(
234
- ct,
235
- {
236
- disablePast: !0,
237
- label: o.next_payment_date,
238
- maxDate: pe(le(P(), 1), 1),
239
- minDate: P(),
240
- onChange: T,
241
- value: w
242
- }
243
- ) })
244
- ] });
245
- }, vt = M(({ repeatingTransaction: n }) => {
246
- const { recurring: t } = k(), { updateRepeatingTransaction: r } = Y(), { onEvent: i } = K(), [a, u] = d.useState(!1), [o, l] = d.useState(n.recurrence_type), [h, p] = d.useState(n.recurrence_day), [C, y] = d.useState(n.second_recurrence_day), b = async () => {
247
- await r({
248
- ...n,
249
- recurrence_type: o,
250
- recurrence_day: h,
251
- second_recurrence_day: C
252
- }), u(!1);
253
- }, S = () => {
254
- u(!0), i(D.RECURRING_TRANSACTIONS_DETAILS_CLICK_PAYMENT_SCHEDULE);
255
- };
256
- return /* @__PURE__ */ c(W, { children: [
257
- /* @__PURE__ */ e(
258
- ee,
259
- {
260
- iconName: "sync",
261
- label: t.activity_schedule,
262
- onClick: S,
263
- showChevron: !1,
264
- value: `${_e(t, n, !0)}`
265
- }
266
- ),
267
- /* @__PURE__ */ e(
268
- z,
269
- {
270
- ariaLabelClose: t.close_drawer_aria,
271
- isOpen: a,
272
- onClose: () => u(!1),
273
- onPrimaryAction: b,
274
- title: t.payment_schedule,
275
- children: /* @__PURE__ */ e(
276
- Ae,
277
- {
278
- firstDay: h,
279
- frequency: o,
280
- onFirstDayChange: p,
281
- onFrequencyChange: l,
282
- onSecondDayChange: y,
283
- secondDay: C
284
- }
285
- )
286
- }
287
- )
288
- ] });
289
- }), Rt = (n, t) => {
290
- const r = n.map((a) => ({
291
- key: a.guid,
292
- name: a.payee || a.description || a.feed_description,
293
- amount: a.amount,
294
- date: a.date,
295
- merchantGuid: a.merchant_guid || "",
296
- categoryGuid: a.top_level_category_guid || "",
297
- category: a.category || "",
298
- status: E.Paid,
299
- transactionGuid: a.guid
300
- })), i = t.map((a) => ({
301
- key: `missed-${a.expectedDate.getTime()}`,
302
- name: a.name,
303
- amount: a.amount,
304
- date: dt(a.expectedDate),
305
- merchantGuid: a.merchantGuid,
306
- categoryGuid: a.categoryGuid,
307
- category: "",
308
- status: E.Missed
309
- }));
310
- return [...r, ...i].sort((a, u) => u.date - a.date);
311
- }, wt = ({
312
- isIncome: n = !1,
313
- onMarkAsUnpaidClick: t,
314
- onMarkAsPaidClick: r,
315
- onTransactionClick: i,
316
- recurringTransaction: a,
317
- transactions: u
318
- }) => {
319
- const { recurring: o } = k(), { onEvent: l } = K(), { recurrences: h } = Y(), [p, C] = d.useState(null), [y, b] = d.useState(null), S = d.useMemo(
320
- () => h.filter(
321
- (s) => s.repeatingTransactionGuid === a.guid && s.status === E.Missed
322
- ),
323
- [h, a.guid]
324
- ), v = d.useMemo(
325
- () => Rt(u, S),
326
- [u, S]
327
- ), w = (s) => {
328
- s.transactionGuid && i(s.transactionGuid);
329
- }, T = (s, L) => {
330
- s.stopPropagation(), C(s.currentTarget), b(L), l(D.RECURRING_TRANSACTIONS_LIST_CLICK_MORE_MENU);
331
- }, x = () => {
332
- C(null), b(null);
333
- }, B = () => {
334
- y && (y.status === E.Missed ? r() : y.transactionGuid && t(y.transactionGuid), x());
335
- };
336
- return /* @__PURE__ */ c(_, { direction: "column", sx: { minHeight: "30dvh" }, children: [
337
- /* @__PURE__ */ e(f, { bold: !0, sx: { ml: 24, mt: 16, mb: 8 }, variant: "body1", children: o.past_activity }),
338
- /* @__PURE__ */ e(te, { sx: { flex: 1, overflow: "auto" }, children: v.map((s, L) => {
339
- const I = s.status === E.Paid, N = s.status === E.Missed, g = L === v.length - 1;
340
- return /* @__PURE__ */ c(d.Fragment, { children: [
341
- /* @__PURE__ */ c(
342
- pt,
343
- {
344
- onClick: I ? () => w(s) : void 0,
345
- sx: { "& .MuiListItemButton-root": { pr: 10 } },
346
- children: [
347
- /* @__PURE__ */ e(ue, { children: /* @__PURE__ */ e(ne, { categoryGuid: s.categoryGuid, merchantGuid: s.merchantGuid }) }),
348
- /* @__PURE__ */ e(
349
- me,
350
- {
351
- disableTypography: !0,
352
- secondary: /* @__PURE__ */ c(_, { direction: "row", justifyContent: "space-between", children: [
353
- /* @__PURE__ */ e(f, { variant: "caption", children: Ce(ge(s.date), be.MONTH_DAY_YEAR) }),
354
- /* @__PURE__ */ c(
355
- _,
356
- {
357
- alignItems: "center",
358
- direction: "row",
359
- gap: 6,
360
- sx: { textTransform: "uppercase" },
361
- children: [
362
- I && /* @__PURE__ */ e(Be, { color: "success", filled: !0, size: 12 }),
363
- N && /* @__PURE__ */ e(We, { color: "error", filled: !0, size: 12 }),
364
- /* @__PURE__ */ e(f, { bold: !0, color: "text.secondary", variant: "caption", children: I ? o.paid?.toLowerCase() : o.missed?.toLowerCase() })
365
- ]
366
- }
367
- )
368
- ] }),
369
- children: /* @__PURE__ */ c(_, { direction: "row", justifyContent: "space-between", sx: { gap: 8 }, children: [
370
- /* @__PURE__ */ e(f, { bold: !0, variant: "body1", children: s.name }),
371
- /* @__PURE__ */ c(
372
- f,
373
- {
374
- bold: !0,
375
- color: n ? "success.main" : "text.primary",
376
- sx: { flexShrink: 0 },
377
- variant: "body1",
378
- children: [
379
- n ? "+" : "",
380
- oe(s.amount, "0,0.00")
381
- ]
382
- }
383
- )
384
- ] })
385
- }
386
- ),
387
- /* @__PURE__ */ e(
388
- ut,
389
- {
390
- "aria-label": o.more_menu_aria,
391
- onClick: (R) => T(R, s),
392
- size: "small",
393
- sx: { alignSelf: "center", ml: 4 },
394
- children: /* @__PURE__ */ e(Ke, { name: "more_vert", size: 20, sx: { color: "text.secondary" } })
395
- }
396
- )
397
- ]
398
- }
399
- ),
400
- /* @__PURE__ */ e(F, { variant: g ? "fullWidth" : "inset" })
401
- ] }, s.key);
402
- }) }),
403
- /* @__PURE__ */ e(
404
- mt,
405
- {
406
- anchorEl: p,
407
- anchorOrigin: { horizontal: "right", vertical: "bottom" },
408
- disableScrollLock: !0,
409
- onClose: x,
410
- open: !!p,
411
- transformOrigin: { horizontal: "right", vertical: "top" },
412
- children: /* @__PURE__ */ e(_t, { onClick: B, sx: { p: 12 }, children: /* @__PURE__ */ e(f, { variant: "body1", children: y?.status === E.Missed ? o.mark_as_paid_cta : o.mark_as_unpaid_cta }) })
413
- }
414
- )
415
- ] });
416
- }, It = ({
417
- expectedDate: n,
418
- onMarkAsPaidClick: t
419
- }) => {
420
- const r = ft(), { recurring: i } = k();
421
- return /* @__PURE__ */ e(ht, { variant: "elevation", children: /* @__PURE__ */ e(yt, { onClick: t, children: /* @__PURE__ */ c(
422
- _,
423
- {
424
- alignItems: "center",
425
- direction: "row",
426
- justifyContent: "space-between",
427
- sx: { px: 16, py: 14 },
428
- children: [
429
- /* @__PURE__ */ c(_, { alignItems: "center", direction: "row", gap: 12, children: [
430
- /* @__PURE__ */ e(
431
- Ct,
432
- {
433
- bgColor: gt(r.palette.primary.main, 0.15),
434
- name: "calendar_clock"
435
- }
436
- ),
437
- /* @__PURE__ */ c(_, { direction: "column", children: [
438
- /* @__PURE__ */ e(f, { fontSize: 11, variant: "body1", children: i.upcoming }),
439
- /* @__PURE__ */ e(f, { bold: !0, variant: "body1", children: Ce(n, be.MONTH_DAY_YEAR) })
440
- ] })
441
- ] }),
442
- /* @__PURE__ */ c(_, { alignItems: "center", direction: "row", gap: 4, children: [
443
- /* @__PURE__ */ e(f, { bold: !0, variant: "body1", children: i.mark_as_paid_cta }),
444
- /* @__PURE__ */ e(qe, { size: 20 })
445
- ] })
446
- ]
447
- }
448
- ) }) });
449
- }, Dt = M(
450
- ({ onDeleted: n, recurringTransaction: t }) => {
451
- const { recurring: r } = k(), { selectedAccountGuids: i } = tt(), { onEvent: a } = K(), { deleteRepeatingTransaction: u, markRecurrenceAsUnpaid: o, recurrences: l } = Y(), { setFilter: h, transactions: p } = ae(), { setSelectedAccount: C, setSelectedMember: y } = Ze(), { members: b } = nt(), { amount: S, description: v, merchant_guid: w } = t, [T, x] = d.useState(!1), [B, s] = d.useState(!1), [L, I] = d.useState(!1), [N, g] = d.useState(!1), [R, X] = d.useState(""), [Re, ie] = d.useState(!1), [Z, se] = d.useState("");
452
- d.useEffect(() => {
453
- h({
454
- accounts: i,
455
- dateRange: { start: pe(P(), 90), end: Ye(P()) },
456
- custom: (A) => A.repeating_transaction_guid === t.guid
457
- });
458
- }, [t.guid]);
459
- const G = d.useMemo(
460
- () => p.find((A) => A.guid === Z),
461
- [Z, p]
462
- ), U = t.repeating_transaction_type === O.Income, we = d.useMemo(
463
- () => p.filter((A) => A.repeating_transaction_guid === t.guid),
464
- [p, t.guid]
465
- ), Ie = Fe(t, l), De = () => {
466
- if (t.account) {
467
- C(t.account);
468
- const A = b.find((J) => J.guid === t.account?.member_guid) || {};
469
- A && y(A), x(!0);
470
- }
471
- }, Me = async () => {
472
- await u(t.guid), n();
473
- }, Te = () => {
474
- s(!0), a(D.RECURRING_TRANSACTIONS_DETAILS_CLICK_DELETE);
475
- }, ce = () => {
476
- I(!0), a(D.RECURRING_TRANSACTIONS_LIST_CLICK_MARK_AS_PAID);
477
- }, Le = () => {
478
- I(!1), ie(!0);
479
- }, Ee = (A) => {
480
- X(A), g(!0), a(D.RECURRING_TRANSACTIONS_LIST_CLICK_MARK_AS_UNPAID);
481
- }, Oe = async () => {
482
- const A = p.find((J) => J.guid === R);
483
- A && await o(A), g(!1), X("");
484
- };
485
- return /* @__PURE__ */ c(_, { bgcolor: "background.default", direction: "column", height: "100%", children: [
486
- /* @__PURE__ */ c(_, { direction: "column", m: 24, children: [
487
- /* @__PURE__ */ e(
488
- ne,
489
- {
490
- categoryGuid: G?.category_guid || "",
491
- merchantGuid: w,
492
- size: 64,
493
- sx: { mb: 12 }
494
- }
495
- ),
496
- /* @__PURE__ */ e(f, { bold: !0, variant: "body1", children: v }),
497
- /* @__PURE__ */ c(H, { color: U ? "success.main" : "text.primary", sx: { mt: 4, mb: 16 }, variant: "h1", children: [
498
- U ? "+" : "",
499
- oe(S, "0,0.00")
500
- ] }),
501
- /* @__PURE__ */ e(
502
- It,
503
- {
504
- expectedDate: Ie,
505
- onMarkAsPaidClick: ce
506
- }
507
- )
508
- ] }),
509
- /* @__PURE__ */ c(te, { sx: { bgcolor: "background.paper" }, children: [
510
- t.account && /* @__PURE__ */ c(W, { children: [
511
- /* @__PURE__ */ e(
512
- ee,
513
- {
514
- iconName: "checkbook",
515
- label: r.account,
516
- onClick: De,
517
- showChevron: !1,
518
- value: t.account.displayName || ""
519
- }
520
- ),
521
- /* @__PURE__ */ e(F, { variant: "inset" })
522
- ] }),
523
- G?.category && /* @__PURE__ */ c(W, { children: [
524
- /* @__PURE__ */ e(
525
- ee,
526
- {
527
- iconName: "monetization_on",
528
- label: r.category,
529
- value: G.category
530
- }
531
- ),
532
- /* @__PURE__ */ e(F, { variant: "inset" })
533
- ] }),
534
- /* @__PURE__ */ e(vt, { repeatingTransaction: t }),
535
- /* @__PURE__ */ e(F, {})
536
- ] }),
537
- /* @__PURE__ */ e(
538
- he,
539
- {
540
- color: "error",
541
- onClick: Te,
542
- startIcon: /* @__PURE__ */ e(je, {}),
543
- sx: { mx: 24, my: 16 },
544
- variant: "text",
545
- children: U ? r.delete_income_title : r.delete_expense_title
546
- }
547
- ),
548
- /* @__PURE__ */ e(
549
- wt,
550
- {
551
- isIncome: U,
552
- onMarkAsPaidClick: ce,
553
- onMarkAsUnpaidClick: Ee,
554
- onTransactionClick: se,
555
- recurringTransaction: t,
556
- transactions: we
557
- }
558
- ),
559
- /* @__PURE__ */ e(
560
- z,
561
- {
562
- ariaLabelClose: r.close_drawer_aria,
563
- isOpen: !!Z && !!G,
564
- onClose: () => se(""),
565
- title: r.transaction_details_drawer_title,
566
- children: G && /* @__PURE__ */ e($e, { transaction: G })
567
- }
568
- ),
569
- /* @__PURE__ */ e(
570
- re,
571
- {
572
- copy: {
573
- title: U ? r.delete_income_title : r.delete_expense_title,
574
- close_aria: r.close_drawer_aria
575
- },
576
- isOpen: B,
577
- onClose: () => s(!1),
578
- onPrimaryAction: Me,
579
- children: /* @__PURE__ */ e(f, { children: U ? r.delete_income_description : r.delete_expense_description })
580
- }
581
- ),
582
- /* @__PURE__ */ e(
583
- kt,
584
- {
585
- isOpen: L,
586
- onClose: () => I(!1),
587
- onLinkTransaction: Le
588
- }
589
- ),
590
- /* @__PURE__ */ e(
591
- At,
592
- {
593
- isOpen: N,
594
- onClose: () => {
595
- g(!1), X("");
596
- },
597
- onUnlinkTransaction: Oe
598
- }
599
- ),
600
- /* @__PURE__ */ e(
601
- xt,
602
- {
603
- isOpen: Re,
604
- onClose: () => ie(!1),
605
- recurringTransaction: t
606
- }
607
- ),
608
- /* @__PURE__ */ e(
609
- Xe,
610
- {
611
- isOpen: T,
612
- onClose: () => x(!1)
613
- }
614
- )
615
- ] });
616
- }
617
- ), Mt = M(
618
- ({ onClick: n = () => {
619
- }, repeatingTransaction: t }) => {
620
- const { recurring: r } = k(), [i, a] = d.useState(!1), u = d.useMemo(
621
- () => t.transactions.length === 0 ? "" : t.transactions[0].category_guid || "",
622
- [t]
623
- ), o = t.account?.displayName || "", l = t.repeating_transaction_type === O.Income, h = _e(r, t, !0);
624
- return /* @__PURE__ */ c(Ge, { disableGutters: !0, disablePadding: !0, children: [
625
- /* @__PURE__ */ c(Ue, { onClick: () => {
626
- n(t), a(!0);
627
- }, children: [
628
- /* @__PURE__ */ e(ue, { children: /* @__PURE__ */ e(
629
- ne,
630
- {
631
- categoryGuid: u,
632
- merchantGuid: t.merchant_guid
633
- }
634
- ) }),
635
- /* @__PURE__ */ e(me, { children: /* @__PURE__ */ c(_, { direction: "row", gap: 4, sx: { justifyContent: "space-between" }, children: [
636
- /* @__PURE__ */ c(_, { direction: "column", sx: { width: "50%" }, children: [
637
- /* @__PURE__ */ e(f, { bold: !0, variant: "body1", children: t.description }),
638
- /* @__PURE__ */ c(_, { alignItems: "center", direction: "row", gap: 6, children: [
639
- t.account?.institution_guid && /* @__PURE__ */ e(
640
- Ne,
641
- {
642
- alt: o,
643
- institutionGuid: t.account?.institution_guid,
644
- size: 12
645
- }
646
- ),
647
- /* @__PURE__ */ e(f, { variant: "caption", children: o })
648
- ] })
649
- ] }),
650
- /* @__PURE__ */ c(_, { alignItems: "flex-end", sx: { width: "50%" }, children: [
651
- /* @__PURE__ */ c(
652
- f,
653
- {
654
- bold: !0,
655
- color: l ? "success.main" : "text.primary",
656
- variant: "body1",
657
- children: [
658
- l ? "+" : "",
659
- oe(t.amount, "0,0.00")
660
- ]
661
- }
662
- ),
663
- /* @__PURE__ */ e(
664
- _,
665
- {
666
- direction: "row",
667
- sx: {
668
- alignItems: "center",
669
- gap: 6,
670
- justifyContent: "flex-end",
671
- textTransform: "uppercase",
672
- width: "100%"
673
- },
674
- children: /* @__PURE__ */ e(f, { bold: !0, color: "text.secondary", variant: "caption", children: h })
675
- }
676
- )
677
- ] })
678
- ] }) })
679
- ] }),
680
- /* @__PURE__ */ e(
681
- z,
682
- {
683
- ariaLabelClose: r.close_drawer_aria,
684
- isOpen: i,
685
- onClose: () => a(!1),
686
- title: t.repeating_transaction_type === O.Income ? r.income_details : r.expense_details,
687
- children: /* @__PURE__ */ e(
688
- Dt,
689
- {
690
- onDeleted: () => a(!1),
691
- recurringTransaction: t
692
- }
693
- )
694
- }
695
- )
696
- ] });
697
- }
698
- ), Tt = M(
699
- ({
700
- bgcolor: n = "background.default",
701
- firstDay: t,
702
- secondDay: r,
703
- frequency: i,
704
- onFrequencyChange: a,
705
- onFirstDayChange: u,
706
- onSecondDayChange: o,
707
- transaction: l
708
- }) => {
709
- const { recurring: h } = k();
710
- return /* @__PURE__ */ c(_, { bgcolor: n, gap: 24, height: "100%", children: [
711
- /* @__PURE__ */ c(_, { children: [
712
- /* @__PURE__ */ e(Ve, { bgcolor: n, children: St(l.date) }),
713
- /* @__PURE__ */ e(et, { transaction: l })
714
- ] }),
715
- /* @__PURE__ */ c(j, { children: [
716
- /* @__PURE__ */ e(f, { bold: !0, sx: { mx: 24 }, variant: "body1", children: h.payment_schedule }),
717
- /* @__PURE__ */ e(
718
- Ae,
719
- {
720
- firstDay: t,
721
- frequency: i,
722
- onFirstDayChange: u,
723
- onFrequencyChange: a,
724
- onSecondDayChange: o,
725
- secondDay: r
726
- }
727
- )
728
- ] })
729
- ] });
730
- }
731
- ), ve = M(
732
- ({
733
- isIncome: n = !1,
734
- label: t,
735
- onAddRecurringTransaction: r = () => null
736
- }) => {
737
- const { recurring: i } = k(), { filter: a, setFilter: u, transactions: o } = ae(), { addRepeatingTransaction: l } = Y(), { user: h } = ot(), [p, C] = d.useState(!1), [y, b] = d.useState(""), [S, v] = d.useState(m.EveryMonth), [w, T] = d.useState(1), [x, B] = d.useState(15), s = d.useMemo(
738
- () => o.find((g) => g.guid === y),
739
- [y, o]
740
- ), L = () => {
741
- C(!0), u(n ? { ...a, custom: $ } : { ...a, custom: Q });
742
- }, I = async () => {
743
- if (!s) {
744
- N();
745
- return;
746
- }
747
- r();
748
- const g = ze(S, ge(s.date), w), R = {
749
- account_guid: s.account_guid,
750
- amount: s.amount,
751
- created_by: 0,
752
- // User
753
- merchant_guid: s.merchant_guid,
754
- description: s.payee || s.description || s.feed_description,
755
- predicted_occurs_on: bt(g, { representation: "date" }),
756
- recurrence_day: w,
757
- recurrence_type: S,
758
- repeating_transaction_type: n ? O.Income : O.Bill,
759
- second_recurrence_day: x,
760
- transaction_type: s.transaction_type,
761
- user_guid: h.guid
762
- };
763
- await l(R, s), N();
764
- }, N = () => {
765
- b(""), C(!1);
766
- };
767
- return /* @__PURE__ */ c(W, { children: [
768
- /* @__PURE__ */ e(he, { onClick: L, startIcon: /* @__PURE__ */ e(He, { size: 24 }), variant: "contained", children: t }),
769
- /* @__PURE__ */ e(
770
- z,
771
- {
772
- ariaLabelClose: i.close_drawer_aria,
773
- isOpen: p,
774
- onClose: () => C(!1),
775
- title: t,
776
- children: /* @__PURE__ */ e(
777
- ke,
778
- {
779
- description: n ? i.add_income_description : i.add_expense_description,
780
- onSearch: (g) => {
781
- u({
782
- ...a,
783
- custom: (R) => n ? g ? xe(R, g) : $(R) : g ? Se(R, g) : Q(R)
784
- });
785
- },
786
- onSelected: (g) => b(g)
787
- }
788
- )
789
- }
790
- ),
791
- /* @__PURE__ */ e(
792
- z,
793
- {
794
- ariaLabelClose: i.close_drawer_aria,
795
- isOpen: !!y,
796
- onClose: () => b(""),
797
- onPrimaryAction: I,
798
- title: n ? i.income_details : i.expense_details,
799
- children: s && /* @__PURE__ */ e(
800
- Tt,
801
- {
802
- firstDay: w,
803
- frequency: S,
804
- onFirstDayChange: T,
805
- onFrequencyChange: v,
806
- onSecondDayChange: B,
807
- secondDay: x,
808
- transaction: s
809
- }
810
- )
811
- }
812
- )
813
- ] });
814
- }
815
- ), Lt = M(
816
- ({ zeroStateFor: n }) => {
817
- const { recurring: t } = k(), { onEvent: r } = K(), i = n === "income", a = i ? t.recurring_setting_zero_state_income_title : t.recurring_setting_zero_state_expenses_title, u = i ? t.recurring_setting_zero_state_income_description : t.recurring_setting_zero_state_expenses_description, o = i ? t.add_income : t.add_expense;
818
- return /* @__PURE__ */ c(_, { sx: { alignItems: "center", p: 24, pt: 48 }, children: [
819
- /* @__PURE__ */ e(Qe, { size: 48 }),
820
- /* @__PURE__ */ e(H, { sx: { my: 8, fontWeight: 600 }, variant: "body1", children: a }),
821
- /* @__PURE__ */ e(H, { color: "text.secondary", sx: { mb: 32 }, variant: "subtitle2", children: u }),
822
- /* @__PURE__ */ e(
823
- ve,
824
- {
825
- isIncome: i,
826
- label: o,
827
- onAddRecurringTransaction: () => {
828
- r(
829
- i ? D.RECURRING_TRANSACTIONS_CLICK_ADD_INCOME : D.RECURRING_ACTIVITY_CLICK_ADD_EXPENSE
830
- );
831
- }
832
- }
833
- )
834
- ] });
835
- }
836
- ), Mn = M(({ forOverview: n = !1 }) => {
837
- const { recurring: t } = k(), { detailedRepeatingTransactions: r } = Y(), { onEvent: i } = K(), a = (l) => {
838
- i(D.RECURRING_TRANSACTIONS_CLICK_INCOME, {
839
- repeating_transaction_guid: l.guid
840
- });
841
- }, u = () => {
842
- i(D.RECURRING_TRANSACTIONS_CLICK_ADD_INCOME);
843
- }, o = r.filter(
844
- (l) => l.repeating_transaction_type === O.Income && (l.transactions.length > 0 || l.recurrence_type === m.EveryYear)
845
- );
846
- return /* @__PURE__ */ e(W, { children: o.length !== 0 ? /* @__PURE__ */ c(
847
- _,
848
- {
849
- sx: {
850
- height: n ? "calc(100vh - 62px)" : "calc(100vh - 109px)",
851
- maxHeight: n ? "calc(100vh - 62px)" : "calc(100vh - 109px)"
852
- },
853
- children: [
854
- n && /* @__PURE__ */ e(f, { bold: !0, sx: { mb: 4, mt: 12, mx: 24 }, variant: "body2", children: t.income }),
855
- /* @__PURE__ */ e(j, { sx: { flex: 1, overflow: "auto" }, children: /* @__PURE__ */ e(te, { sx: { bgcolor: "background.paper" }, children: o.map((l, h) => /* @__PURE__ */ c(d.Fragment, { children: [
856
- /* @__PURE__ */ e(Mt, { onClick: a, repeatingTransaction: l }),
857
- /* @__PURE__ */ e(
858
- F,
859
- {
860
- variant: h < o.length - 1 ? "inset" : "fullWidth"
861
- }
862
- )
863
- ] }, l.guid)) }) }),
864
- /* @__PURE__ */ c(j, { children: [
865
- /* @__PURE__ */ e(F, {}),
866
- /* @__PURE__ */ e(
867
- j,
868
- {
869
- sx: {
870
- alignContent: "center",
871
- bgcolor: "background.paper",
872
- justifyContent: "flex-end",
873
- px: 24,
874
- py: 12,
875
- textAlign: "right"
876
- },
877
- children: /* @__PURE__ */ e(
878
- ve,
879
- {
880
- isIncome: !0,
881
- label: t.add_income,
882
- onAddRecurringTransaction: u
883
- }
884
- )
885
- }
886
- )
887
- ] })
888
- ]
889
- }
890
- ) : /* @__PURE__ */ e(Lt, { zeroStateFor: "income" }) });
891
- });
892
- export {
893
- ve as A,
894
- Mn as M,
895
- Mt as R,
896
- ke as S,
897
- Lt as a,
898
- $ as b,
899
- Tt as c,
900
- Dt as d,
901
- xe as i
902
- };