@mx-cartographer/experiences 7.2.16-alpha.mm0 → 8.0.0-alpha.bb1

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 (63) hide show
  1. package/dist/{Account-vp_TAbGt.mjs → Account-Bxw0_4FU.mjs} +1 -1
  2. package/dist/{AccountDetailsContent-CsH1w_GZ.mjs → AccountDetailsContent-CAM9y39M.mjs} +6 -6
  3. package/dist/{AccountDetailsHeader-Df1JkzYi.mjs → AccountDetailsHeader-JtSX6Uf9.mjs} +4 -4
  4. package/dist/{AccountFields-DUToRRqW.mjs → AccountFields-C9FlatNb.mjs} +2 -2
  5. package/dist/{AccountListItem-CeY_WIpj.mjs → AccountListItem-JFMZROh7.mjs} +7 -7
  6. package/dist/{AccountStore-BkoLK9Tq.mjs → AccountStore-BgNOyMdp.mjs} +74 -100
  7. package/dist/Accounts-BRf_YeTf.mjs +27 -0
  8. package/dist/CategoryStore-yHI0hWmK.mjs +174 -0
  9. package/dist/CategoryUtil-pZRIYOgN.mjs +80 -0
  10. package/dist/{ConnectDrawer-Bw5s6Dw1.mjs → ConnectDrawer-BQNs-hjk.mjs} +9 -9
  11. package/dist/{ConnectionsDrawer-BDvVuJQf.mjs → ConnectionsDrawer-ByGQE7D5.mjs} +3 -3
  12. package/dist/{DebtsStore-BD_XwsI7.mjs → DebtsStore-C9bblOgW.mjs} +1 -1
  13. package/dist/{GoalStore-DZ_Jvsa_.mjs → GoalStore-D-aB35SY.mjs} +151 -111
  14. package/dist/{ManageIncome-CV-bGuR-.mjs → ManageIncome-1s_q5W4X.mjs} +3 -3
  15. package/dist/{NetWorthStore-D1NiDUcc.mjs → NetWorthStore-DCsTZpuS.mjs} +2 -2
  16. package/dist/{NotificationSettings-5i3IywCi.mjs → NotificationSettings-DqrkNMod.mjs} +236 -238
  17. package/dist/{NotificationStore-C6PH6MKm.mjs → NotificationStore-BxP_P2dA.mjs} +23 -15
  18. package/dist/{RecurringSettings-G6_BbsIF.mjs → RecurringSettings-A_rAGCTP.mjs} +3 -3
  19. package/dist/{RecurringTransactions-ej39mgA6.mjs → RecurringTransactions-DK8dWldr.mjs} +3 -3
  20. package/dist/{RecurringTransactionsStore-DrzS1LmF.mjs → RecurringTransactionsStore-C4YOD7_D.mjs} +29 -26
  21. package/dist/{TransactionDetails-CDtya0KS.mjs → TransactionDetails-oP1eSuiS.mjs} +1 -1
  22. package/dist/TransactionStore-ai3uII_r.mjs +690 -0
  23. package/dist/{WidgetContainer-EbrN1oIo.mjs → WidgetContainer-BHWANqT4.mjs} +1 -1
  24. package/dist/accounts/components/AccountsWidgetContent.d.ts +3 -0
  25. package/dist/accounts/index.es.js +184 -174
  26. package/dist/accounts/stores/AccountStore.d.ts +25 -22
  27. package/dist/accounts/utils/Accounts.d.ts +2 -1
  28. package/dist/budgets/index.es.js +499 -501
  29. package/dist/budgets/store/BudgetsStore.d.ts +1 -0
  30. package/dist/cashflow/index.es.js +382 -384
  31. package/dist/categories/index.es.js +1 -1
  32. package/dist/categories/stores/CategoryStore.d.ts +5 -1
  33. package/dist/categories/util/CategoryUtil.d.ts +3 -2
  34. package/dist/common/index.es.js +206 -214
  35. package/dist/common/stores/AppDataStore.d.ts +3 -1
  36. package/dist/common/stores/GlobalCopyStore.d.ts +0 -1
  37. package/dist/common/stores/GlobalStore.d.ts +3 -3
  38. package/dist/common/stores/UserStore.d.ts +3 -2
  39. package/dist/common/types/Account.d.ts +9 -6
  40. package/dist/dashboard/index.es.js +1 -1
  41. package/dist/debts/index.es.js +375 -377
  42. package/dist/finstrong/index.es.js +415 -417
  43. package/dist/goals/index.es.js +557 -559
  44. package/dist/goals/stores/GoalStore.d.ts +17 -4
  45. package/dist/help/index.es.js +1 -1
  46. package/dist/investments/index.es.js +435 -437
  47. package/dist/investments/stores/HoldingStore.d.ts +1 -0
  48. package/dist/networth/index.es.js +172 -174
  49. package/dist/notifications/index.es.js +3 -3
  50. package/dist/notifications/stores/NotificationStore.d.ts +3 -1
  51. package/dist/recurringtransactions/index.es.js +173 -175
  52. package/dist/recurringtransactions/stores/RecurringTransactionsStore.d.ts +3 -2
  53. package/dist/settings/index.es.js +279 -285
  54. package/dist/spending/index.es.js +281 -283
  55. package/dist/transactions/index.es.js +6 -6
  56. package/dist/transactions/stores/TransactionStore.d.ts +21 -77
  57. package/dist/trends/index.es.js +4 -4
  58. package/dist/{useAccountDisplayName-jS05A6-6.mjs → useAccountDisplayName-BUAApBIb.mjs} +1 -1
  59. package/package.json +4 -4
  60. package/dist/Accounts-C1QxUB-e.mjs +0 -9
  61. package/dist/CategoryStore-BCcpI3oJ.mjs +0 -183
  62. package/dist/CategoryUtil-BR3H5i6n.mjs +0 -78
  63. package/dist/TransactionStore-DxPLdF3B.mjs +0 -677
@@ -1,10 +1,10 @@
1
1
  import { T as Aa } from "../TransactionApi-B3Tksf7L.mjs";
2
- import { u as P, C as Pe, D as $e, M as Ve, c as We, T as Ge, a as Ue } from "../TransactionDetails-CDtya0KS.mjs";
3
- import { B as xa, d as wa, b as Ia } from "../TransactionDetails-CDtya0KS.mjs";
2
+ import { u as P, C as Pe, D as $e, M as Ve, c as We, T as Ge, a as Ue } from "../TransactionDetails-oP1eSuiS.mjs";
3
+ import { B as xa, d as wa, b as Ia } from "../TransactionDetails-oP1eSuiS.mjs";
4
4
  import { T as M } from "../User-BQUxBeZV.mjs";
5
5
  import { O as Da } from "../User-BQUxBeZV.mjs";
6
- import { S as ae, D as Fe } from "../TransactionStore-DxPLdF3B.mjs";
7
- import { T as Ea } from "../TransactionStore-DxPLdF3B.mjs";
6
+ import { S as ae, D as Fe } from "../TransactionStore-ai3uII_r.mjs";
7
+ import { T as Ea } from "../TransactionStore-ai3uII_r.mjs";
8
8
  import { e as ze } from "../exportTransactionsToCSV-7bVS7KXf.mjs";
9
9
  import { E as Ma } from "../ExportCsvAction-sX8Rg4Ov.mjs";
10
10
  import { jsxs as _, jsx as e } from "react/jsx-runtime";
@@ -26,7 +26,7 @@ import { getUnixTime as rt } from "date-fns/getUnixTime";
26
26
  import { startOfMonth as st } from "date-fns/startOfMonth";
27
27
  import { startOfToday as K } from "date-fns/startOfToday";
28
28
  import it from "@mui/material/styles/useTheme";
29
- import { l as ct } from "../ConnectDrawer-Bw5s6Dw1.mjs";
29
+ import { l as ct } from "../ConnectDrawer-BQNs-hjk.mjs";
30
30
  import lt from "@mui/material/Divider";
31
31
  import dt from "@mui/material/MenuItem";
32
32
  import ut from "@mui/material/RadioGroup";
@@ -35,7 +35,7 @@ import { C as _t } from "../CurrencyInput-DUsQbkXb.mjs";
35
35
  import { a as pt, u as gt } from "../CategorySelectorDrawer-DUe4lH5-.mjs";
36
36
  import { b as q } from "../Localization-2MODESHW.mjs";
37
37
  import { u as ht } from "../useAriaLive-B3_pRUio.mjs";
38
- import { A, W as ft } from "../WidgetContainer-EbrN1oIo.mjs";
38
+ import { A, W as ft } from "../WidgetContainer-BHWANqT4.mjs";
39
39
  import { u as Ct } from "../useScreenSize-B6JyS_Lj.mjs";
40
40
  import { S as yt } from "../SearchBox-B2_zLv8-.mjs";
41
41
  import { D as oe } from "../Drawer-kEE73B87.mjs";
@@ -1,4 +1,4 @@
1
- import { BeatApi, TransactionType, Beat, GlobalStore, Tag, Tagging, Transaction, TransactionRule } from '../../common';
1
+ import { BeatApi, Beat, GlobalStore, Tag, Tagging, Transaction, TransactionRule } from '../../common';
2
2
  import { TransactionApi } from '../api/TransactionApi';
3
3
  import { UiStore } from './UiStore';
4
4
  export type TransactionFilter = {
@@ -17,103 +17,47 @@ export declare class TransactionStore {
17
17
  api: TransactionApi;
18
18
  beatApi: BeatApi;
19
19
  associatedBeats: Beat[];
20
+ associatedBeatsLoaded: boolean;
21
+ transactions: Transaction[];
22
+ transactionsLoaded: boolean;
23
+ taggings: Tagging[];
24
+ taggingsLoaded: boolean;
25
+ tags: Tag[];
26
+ tagsLoaded: boolean;
27
+ transactionRules: TransactionRule[];
28
+ transactionRulesLoaded: boolean;
20
29
  cachedStartDate: Date;
21
30
  filter: TransactionFilter;
22
31
  isLoading: boolean;
23
- rawTransactions: Transaction[];
24
32
  sortColumn: string;
25
33
  sortDirection: string;
26
- taggings: Tagging[];
27
- tags: Tag[];
28
- transactionRules: TransactionRule[];
29
34
  onAnalyticEvent: (event: string, session: import('../analytics').AnalyticSession | null) => Promise<any>;
30
35
  constructor(globalStore: GlobalStore);
31
- loadTransactionData: ({ associatedBeats, transactionRules, transactions, }?: {
32
- associatedBeats?: Beat[];
33
- taggings?: Tagging[];
34
- tags?: Tag[];
35
- transactionRules?: TransactionRule[];
36
- transactions?: Transaction[];
37
- }) => Promise<void>;
36
+ loadTransactionData: () => Promise<void>;
37
+ get isTransactionDataLoaded(): boolean;
38
38
  get sortedTransactions(): Transaction[];
39
39
  get sortedTransactionsWithSplits(): Transaction[];
40
- get transactions(): Transaction[];
40
+ get detailedTransactions(): Transaction[];
41
+ setAssociatedBeats: (beats: Beat[]) => void;
42
+ setTaggings: (taggings: Tagging[]) => void;
43
+ setTags: (tags: Tag[]) => void;
44
+ setTransactionRules: (transactionRules: TransactionRule[]) => void;
45
+ setTransactions: (transactions: Transaction[]) => void;
41
46
  addTag: (name: string) => Promise<void>;
42
47
  addTagging: (tagGuid: string, transactionGuid: string) => Promise<void>;
43
48
  addOrUpdateTransactionRule: (categoryGuid: string, transaction: Transaction) => Promise<void>;
44
49
  addTransaction: (transaction: Transaction) => Promise<void>;
45
- augmentTransactions: (transactions: Transaction[]) => {
46
- account: string;
47
- accountIsClosed: boolean;
48
- accountIsHidden: boolean;
49
- category: string;
50
- isIncome: boolean;
51
- isPending: boolean;
52
- number: string;
53
- payee: string;
54
- tags: string[];
55
- guid: string;
56
- account_guid: string;
57
- amount: number;
58
- attachment_guid?: string | null;
59
- category_guid?: string;
60
- check_number?: string | null;
61
- currency_code: string | null;
62
- date: number;
63
- description: string;
64
- duplicate: boolean;
65
- external_guid?: string | null;
66
- feed_attachment_guid?: string | null;
67
- feed_description: string;
68
- feed_localized_description?: string | null;
69
- feed_posted_date?: number | null;
70
- feed_status: import('../../common').TransactionStatus | null;
71
- feed_transaction_date: number | null;
72
- flags?: number | null;
73
- has_been_split: boolean;
74
- has_been_viewed: boolean;
75
- is_cleared: boolean;
76
- is_flagged: boolean;
77
- is_hidden: boolean;
78
- is_international?: boolean | null;
79
- is_manual: boolean;
80
- is_personal: boolean;
81
- is_reimbursable: boolean;
82
- is_subscription: boolean;
83
- is_void: boolean;
84
- localized_description?: string | null;
85
- localized_memo?: string | null;
86
- memo?: string | null;
87
- metadata?: string | null;
88
- merchant_guid?: string | null;
89
- parent_guid?: string | null;
90
- posted_date?: number | null;
91
- reference?: string | null;
92
- revision: number;
93
- repeating_transaction_guid?: string | null;
94
- scheduled_payment_guid?: string | null;
95
- top_level_category_guid?: string;
96
- transaction_type: TransactionType;
97
- user_date?: number | null;
98
- user_guid: string;
99
- user_transaction_rule_guid?: string | null;
100
- is_duplicate: boolean;
101
- feed_transacted_at: number | null;
102
- }[];
103
- getTransactionData: () => {};
104
- loadAssociatedBeats: (fromDate?: Date, beatsOverride?: Beat[]) => Promise<void>;
50
+ loadAssociatedBeats: (fromDate?: Date) => Promise<void>;
105
51
  loadTags: () => Promise<void>;
106
52
  loadTaggings: () => Promise<void>;
107
- loadTransactionRules: (transactionRulesOverrides?: TransactionRule[]) => Promise<void>;
108
- loadTransactions: (startDate?: Date, endDate?: Date, transactionsOverrides?: Transaction[]) => Promise<void>;
109
- loadTransactionsByDateRange: (endDate: number, startDate: number) => Promise<void>;
53
+ loadTransactionRules: () => Promise<void>;
54
+ loadTransactions: (startDate?: Date) => Promise<void>;
110
55
  modifyTransactionByAccountGuid: (guid: string, updates: Partial<Transaction>) => void;
111
56
  removeTag: (tagGuid: string) => Promise<void>;
112
57
  removeTagging: (taggingGuid: string) => Promise<void>;
113
58
  removeTransaction: (transactionGuid: string) => Promise<void>;
114
59
  setFilter: (filter: TransactionFilter) => void;
115
60
  setIsLoading: (isLoading: boolean) => boolean;
116
- setSortData: (sortColumn: string, sortDirection: string) => void;
117
61
  splitTransaction: (transaction: Transaction, splits: Transaction[]) => Promise<void>;
118
62
  unSplitTransaction: (guid: string) => Promise<void>;
119
63
  updateTaggings: (tagGuids: string[], transactionGuid: string) => Promise<void>;
@@ -20,9 +20,9 @@ import { C as pt } from "../CurrencyText-kyC1aseI.mjs";
20
20
  import { b as Ct } from "../Localization-2MODESHW.mjs";
21
21
  import { H as Ie } from "../HeaderCell-DjuifqHJ.mjs";
22
22
  import { T as M, b as ft } from "../ViewMoreMicroCard-SCn2wt4i.mjs";
23
- import { A as _, W as ke } from "../WidgetContainer-EbrN1oIo.mjs";
23
+ import { A as _, W as ke } from "../WidgetContainer-BHWANqT4.mjs";
24
24
  import { c as Tt } from "../Category-CevNQ03n.mjs";
25
- import { a as Ne, T as He } from "../TransactionDetails-CDtya0KS.mjs";
25
+ import { a as Ne, T as He } from "../TransactionDetails-oP1eSuiS.mjs";
26
26
  import { D as Ce } from "../Drawer-kEE73B87.mjs";
27
27
  import { L as Q } from "../Loader-DUaFpDGv.mjs";
28
28
  import { useTheme as We } from "@mui/material/styles";
@@ -42,11 +42,11 @@ import Oe from "@mui/material/styles/useTheme";
42
42
  import Nt from "@mui/material/Divider";
43
43
  import { useTheme as Ht, Stack as Wt } from "@mui/material";
44
44
  import Ot from "@mui/material/Paper";
45
- import { b as Vt } from "../CategoryUtil-BR3H5i6n.mjs";
45
+ import { b as Vt } from "../CategoryUtil-pZRIYOgN.mjs";
46
46
  import { E as Gt } from "../ExportCsvAction-sX8Rg4Ov.mjs";
47
47
  import { u as Bt } from "../useInsightsEnabled-DBpwEq10.mjs";
48
48
  import { E as zt } from "../EmptyState-DA_lfRBv.mjs";
49
- import { l as Pt } from "../ConnectDrawer-Bw5s6Dw1.mjs";
49
+ import { l as Pt } from "../ConnectDrawer-BQNs-hjk.mjs";
50
50
  const Ve = ({ selectedTab: t, onTabChange: o }) => /* @__PURE__ */ e(
51
51
  dt,
52
52
  {
@@ -1,5 +1,5 @@
1
1
  import s from "react";
2
- import { g as e } from "./ConnectDrawer-Bw5s6Dw1.mjs";
2
+ import { g as e } from "./ConnectDrawer-BQNs-hjk.mjs";
3
3
  import { a as n } from "./hooks-D6XlXHf4.mjs";
4
4
  const i = (o) => {
5
5
  const { config: a } = n();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-cartographer/experiences",
3
- "version": "7.2.16-alpha.mm0",
3
+ "version": "8.0.0-alpha.bb1",
4
4
  "description": "Library containing experience widgets",
5
5
  "author": "MX",
6
6
  "license": "MIT",
@@ -186,7 +186,7 @@
186
186
  "@mui/x-date-pickers-pro": "^7.29.4",
187
187
  "@mxenabled/cssinjs": "^0.6.0",
188
188
  "@mxenabled/mx-icons": "^1.5.1",
189
- "@mxenabled/mxui": "^1.5.6",
189
+ "@mxenabled/mxui": "^1.5.8",
190
190
  "@mxenabled/web-widget-sdk": "^0.0.13",
191
191
  "@tanstack/react-virtual": "^3.13.2",
192
192
  "bowser": "^2.11.0",
@@ -252,7 +252,7 @@
252
252
  "storybook-dark-mode": "4.0.1",
253
253
  "typescript": "^5.8.2",
254
254
  "vi-canvas-mock": "^1.0.0",
255
- "vite": "^5.4.19",
255
+ "vite": "^5.4.21",
256
256
  "vite-plugin-dts": "^4.5.3",
257
257
  "vite-tsconfig-paths": "^5.1.4",
258
258
  "vitest": "^3.0.8"
@@ -272,5 +272,5 @@
272
272
  "CHANGELOG.md",
273
273
  "README.md"
274
274
  ],
275
- "packageManager": "yarn@4.9.2"
275
+ "packageManager": "yarn@4.11.0"
276
276
  }
@@ -1,9 +0,0 @@
1
- import { A as _ } from "./ConnectDrawer-Bw5s6Dw1.mjs";
2
- const s = (t) => t && (t.account_type === _.CREDIT_CARD || t.account_type === _.LOAN || t.account_type === _.MORTGAGE || t.account_type === _.LINE_OF_CREDIT || t.account_type === _.CHECKING_LINE_OF_CREDIT), p = (t) => t.is_manual || !t.guid, E = (t) => t.account_type === _.LINE_OF_CREDIT || t.account_type === _.CREDIT_CARD || t.account_type === _.CHECKING_LINE_OF_CREDIT, a = (t) => t.account_type === _.SAVINGS || t.account_type === _.CHECKING || t.account_type === _.LINE_OF_CREDIT || t.account_type === _.CREDIT_CARD || t.account_type === _.LOAN || t.account_type === _.MORTGAGE, y = (t) => t.account_type === _.LOAN || t.account_type === _.MORTGAGE;
3
- export {
4
- s as a,
5
- E as b,
6
- y as c,
7
- p as i,
8
- a as u
9
- };
@@ -1,183 +0,0 @@
1
- import { makeAutoObservable as u, runInAction as l } from "mobx";
2
- import { getUnixTime as r } from "date-fns/getUnixTime";
3
- import { subMonths as g } from "date-fns/subMonths";
4
- import { startOfMonth as h } from "date-fns/startOfMonth";
5
- import { endOfMonth as d } from "date-fns/endOfMonth";
6
- import { a as T, g as m } from "./CategoryUtil-BR3H5i6n.mjs";
7
- import { F as p, A as i } from "./Fetch-87LIQbEA.mjs";
8
- import { b as f, c as w } from "./Category-CevNQ03n.mjs";
9
- class y {
10
- fetchInstance;
11
- constructor(t, e, o) {
12
- this.fetchInstance = new p(t, e, void 0, o);
13
- }
14
- addCategory = async (t) => this.fetchInstance.post(i.CATEGORIES, t).then((e) => e.category);
15
- getCategories = async () => this.fetchInstance.get(i.CATEGORIES).then((t) => t.categories);
16
- getDateRangeCategoryTotals = async (t, e, o) => o.length === 0 ? [] : this.fetchInstance.post(`${i.DATE_RANGE_CATEGORY_TOTALS}/from/${t}/to/${e}`, {
17
- account_guid: o.map((a) => a.guid)
18
- }).then((a) => a.date_range_category_totals);
19
- getMonthlyCategoryTotals = async (t, e, o) => {
20
- try {
21
- const a = `${i.MONTHLY_CATEGORY_TOTALS}/from/${t}/to/${e}`;
22
- if (o) {
23
- const s = o.length === 0 ? [""] : o.map((C) => C.guid);
24
- return (await this.fetchInstance.post(a, { account_guid: s })).monthly_category_totals;
25
- } else
26
- return (await this.fetchInstance.get(a)).monthly_category_totals;
27
- } catch (a) {
28
- throw console.error("Error fetching monthly category totals:", a), a;
29
- }
30
- };
31
- removeCategory = async (t) => this.fetchInstance.delete(`${i.CATEGORIES}/${t}`);
32
- updateCategory = async (t) => this.fetchInstance.put(`${i.CATEGORIES}/${t.guid}`, t).then((e) => e.category);
33
- }
34
- class S {
35
- expandedGuid = null;
36
- selectedGuid = null;
37
- searchValue = "";
38
- showSelected = !0;
39
- shouldDisableDrawerScroll = !1;
40
- unselectable = [];
41
- unselectableText = "";
42
- savedOnSelect;
43
- // todo
44
- constructor() {
45
- u(this);
46
- }
47
- setExpandedGuid = (t) => this.expandedGuid = t;
48
- setSelectedGuid = (t) => this.selectedGuid = t;
49
- setSearchValue = (t) => this.searchValue = t;
50
- setShouldDisableDrawerScroll = (t) => this.shouldDisableDrawerScroll = t;
51
- setShowSelected = (t) => this.showSelected = t;
52
- setUnselectable = (t) => this.unselectable = t;
53
- setUnselectableText = (t) => this.unselectableText = t;
54
- onSelect = (t) => this.savedOnSelect(t);
55
- setOnSelect = (t) => this.savedOnSelect = t;
56
- }
57
- class G {
58
- globalStore;
59
- uiStore;
60
- api = new y("/", "");
61
- categories = [];
62
- dateRangeCategoryTotals = [];
63
- monthlyCategoryTotals = [];
64
- dataRangeTotalsLoaded = !1;
65
- isLoadingCategoryTotals = !1;
66
- monthlyTotalsLoaded = !1;
67
- constructor(t) {
68
- this.globalStore = t, this.uiStore = new S(), this.api = new y(t.endpoint, t.sessionToken, t.onError), u(this);
69
- }
70
- get detailedCategories() {
71
- return T(
72
- this.categories,
73
- this.dateRangeCategoryTotals,
74
- this.monthlyCategoryTotals
75
- );
76
- }
77
- get detailedCategoriesWithTransactions() {
78
- return m(
79
- this.detailedCategories,
80
- this.globalStore.transactionStore.sortedTransactions
81
- );
82
- }
83
- get incomeCategories() {
84
- return this.detailedCategories.filter((t) => t.is_income);
85
- }
86
- get spendCategories() {
87
- return this.detailedCategories.filter(
88
- (t) => !t.is_income && !t.isTransfer && t.guid !== f.INVESTMENTS
89
- );
90
- }
91
- get transferCategories() {
92
- return this.detailedCategories.filter((t) => t.isTransfer);
93
- }
94
- addCategory = async (t, e) => {
95
- const o = { name: t, parent_guid: e };
96
- try {
97
- await this.api.addCategory(o), await this.loadCategories();
98
- } catch (a) {
99
- console.error(`Error occurred while adding category: ${a}`);
100
- }
101
- };
102
- loadCategories = async (t) => {
103
- try {
104
- const e = t || await this.api.getCategories(), { default_categories: o } = this.globalStore.copyStore.copy.categories;
105
- l(() => {
106
- this.categories = e.map((a) => ({
107
- ...a,
108
- name: o[a.guid] ? o[a.guid].replace(/&amp;/g, "&") : a.name
109
- }));
110
- });
111
- } catch (e) {
112
- console.error(`Error occurred while getting categories: ${e}`);
113
- }
114
- };
115
- loadDateRangeCategoryTotals = async (t, e, o) => {
116
- this.setIsLoadingCategoryTotals(!0);
117
- try {
118
- const a = await this.api.getDateRangeCategoryTotals(
119
- r(e),
120
- r(o),
121
- t
122
- );
123
- l(() => {
124
- this.dateRangeCategoryTotals = a, this.setIsLoadingCategoryTotals(!1), this.dataRangeTotalsLoaded = !0;
125
- });
126
- } catch (a) {
127
- this.setIsLoadingCategoryTotals(!1), console.error(`Error occurred while getting date range category totals: ${a}`);
128
- }
129
- };
130
- loadMonthlyCategoryTotals = async (t = this.globalStore.globalUiStore.selectedAccounts, e, o) => {
131
- const a = r(h(e ?? g(/* @__PURE__ */ new Date(), 11))), s = r(d(o ?? /* @__PURE__ */ new Date()));
132
- try {
133
- const n = await this.api.getMonthlyCategoryTotals(a, s, t);
134
- l(() => {
135
- this.monthlyCategoryTotals = n, this.monthlyTotalsLoaded = !0;
136
- });
137
- } catch (n) {
138
- console.error(`Error occurred while getting monthly category totals: ${n}`);
139
- }
140
- };
141
- reloadCategoryTotals = async (t, e, o) => {
142
- this.setIsLoadingCategoryTotals(!0);
143
- try {
144
- const a = await this.api.getDateRangeCategoryTotals(
145
- r(e),
146
- r(o),
147
- t
148
- ), s = await this.api.getMonthlyCategoryTotals(
149
- r(h(g(o, 11))),
150
- r(d(o)),
151
- t
152
- );
153
- l(() => {
154
- this.dateRangeCategoryTotals = a, this.monthlyCategoryTotals = s, this.dataRangeTotalsLoaded = !0, this.monthlyTotalsLoaded = !0, this.setIsLoadingCategoryTotals(!1);
155
- });
156
- } catch (a) {
157
- console.error(`Error occurred while getting category totals: ${a}`);
158
- }
159
- };
160
- removeCategory = async (t) => {
161
- try {
162
- await this.api.removeCategory(t), await this.loadCategories();
163
- } catch (e) {
164
- console.error(`Error occurred while removing category: ${e}`);
165
- }
166
- };
167
- setIsLoadingCategoryTotals = (t) => {
168
- this.isLoadingCategoryTotals = t;
169
- };
170
- updateCategory = async (t) => {
171
- try {
172
- await this.api.updateCategory(t), await this.loadCategories();
173
- } catch (e) {
174
- console.error(`Error occurred while updating category: ${e}`);
175
- }
176
- };
177
- // TODO: Remove this after refactoring Trends components to use detailedCategories
178
- getCategoryName = (t) => this.categories.find((o) => o.guid === t)?.name ?? w[t];
179
- }
180
- export {
181
- G as C,
182
- y as a
183
- };
@@ -1,78 +0,0 @@
1
- import { format as l } from "date-fns/format";
2
- import { startOfMonth as h } from "date-fns/startOfMonth";
3
- import { startOfToday as M } from "date-fns/startOfToday";
4
- import { subMonths as T } from "date-fns/subMonths";
5
- import { CategoryIconList as C } from "@mxenabled/mxui";
6
- import { C as N, a as O, b } from "./Category-CevNQ03n.mjs";
7
- import { f as D, D as E } from "./Dialog-CWW597AF.mjs";
8
- const R = 3, d = 12, Y = (n, r, t) => n.filter((e) => !e.parent_guid).map(
9
- (e) => _(
10
- e,
11
- r,
12
- t,
13
- n.filter((o) => o.parent_guid === e.guid)
14
- )
15
- ), x = (n, r) => {
16
- const t = C.find((e) => e.guid === n);
17
- return t ? r.palette.categories[t.colorName] || "" : r.palette.categories.uncategorized || "";
18
- }, _ = (n, r, t, e = []) => {
19
- const o = n.guid, i = n.parent_guid || o, u = o === i, s = r.find((a) => a.category_guid === o)?.total || 0, c = f(
20
- t.filter((a) => a.category_guid === o)
21
- ), g = f(
22
- t.filter(
23
- (a) => a.category_guid === o || a.top_level_category_guid === o
24
- )
25
- ), m = e.map(
26
- (a) => _(a, r, t)
27
- ), p = m.reduce(
28
- (a, A) => a + A.currentAmount,
29
- s
30
- );
31
- return {
32
- ...n,
33
- currentAmount: s,
34
- averageAmount: y(c),
35
- color: N[i],
36
- icon: O[i],
37
- isTransfer: i === b.TRANSFER,
38
- monthlyAmounts: c,
39
- subCategories: m,
40
- totalAmount: u ? p : 0,
41
- totalAverageAmount: y(g),
42
- totalMonthlyAmounts: u ? g : []
43
- };
44
- }, k = (n, r) => n.map((t) => {
45
- const e = r.filter(
46
- (o) => o.category_guid === t.guid || o.top_level_category_guid === t.guid
47
- );
48
- return {
49
- ...t,
50
- transactions: e
51
- };
52
- }), y = (n, r = R) => {
53
- const t = r > history.length ? history.length : r;
54
- return Math.ceil(
55
- Math.max(
56
- 0,
57
- n.slice(-t).reduce((e, o) => e + o.amount, 0) / t
58
- )
59
- );
60
- }, f = (n) => {
61
- const r = [], t = M();
62
- for (let e = 0; e <= d; e++) {
63
- const o = h(T(t, d - e)), u = n.filter(
64
- (s) => s.year_month === Number(l(o, "yyyyMM"))
65
- ).reduce((s, c) => s + c.total, 0);
66
- r.push({
67
- amount: u,
68
- isoDate: l(o, "yyyy-MM-dd"),
69
- label: D(o, E.MONTH_YEAR)
70
- });
71
- }
72
- return r;
73
- };
74
- export {
75
- Y as a,
76
- x as b,
77
- k as g
78
- };