@mx-cartographer/experiences 6.26.0-alpha.sms7 → 6.26.1-alpha.mega1

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 (95) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/dist/AccountStore-DkL93tXL.mjs +317 -0
  3. package/dist/AccountStore-DkL93tXL.mjs.map +1 -0
  4. package/dist/BudgetUtil-CVqAdv-j.mjs +187 -0
  5. package/dist/BudgetUtil-CVqAdv-j.mjs.map +1 -0
  6. package/dist/CashflowStore-gPEEBiXo.mjs +53 -0
  7. package/dist/CashflowStore-gPEEBiXo.mjs.map +1 -0
  8. package/dist/CategoryStore-m7oieLzP.mjs +260 -0
  9. package/dist/CategoryStore-m7oieLzP.mjs.map +1 -0
  10. package/dist/ConnectMiniWidget-CQWafYtQ.mjs +22966 -0
  11. package/dist/ConnectMiniWidget-CQWafYtQ.mjs.map +1 -0
  12. package/dist/DebtsStore-cUhIgJx6.mjs +145 -0
  13. package/dist/DebtsStore-cUhIgJx6.mjs.map +1 -0
  14. package/dist/Donut-CGNFni9y.mjs +58 -0
  15. package/dist/Donut-CGNFni9y.mjs.map +1 -0
  16. package/dist/FinstrongStore-BDG7l0nI.mjs +183 -0
  17. package/dist/FinstrongStore-BDG7l0nI.mjs.map +1 -0
  18. package/dist/GoalStore-o2waGeyf.mjs +293 -0
  19. package/dist/GoalStore-o2waGeyf.mjs.map +1 -0
  20. package/dist/Loader-CwdK8lfx.mjs +147 -0
  21. package/dist/Loader-CwdK8lfx.mjs.map +1 -0
  22. package/dist/MerchantStore-Cck9IGIH.mjs +125 -0
  23. package/dist/MerchantStore-Cck9IGIH.mjs.map +1 -0
  24. package/dist/NetWorthStore-D5eUfGQt.mjs +66 -0
  25. package/dist/NetWorthStore-D5eUfGQt.mjs.map +1 -0
  26. package/dist/NotificationStore-DCxw8W7u.mjs +141 -0
  27. package/dist/NotificationStore-DCxw8W7u.mjs.map +1 -0
  28. package/dist/RecurringTransactionsStore-Bijrgllq.mjs +337 -0
  29. package/dist/RecurringTransactionsStore-Bijrgllq.mjs.map +1 -0
  30. package/dist/SettingsStore-BhOYgUOa.mjs +352 -0
  31. package/dist/SettingsStore-BhOYgUOa.mjs.map +1 -0
  32. package/dist/TransactionApi-Dnbyi1JL.mjs +175 -0
  33. package/dist/TransactionApi-Dnbyi1JL.mjs.map +1 -0
  34. package/dist/TransactionStore-CiEtt5XJ.mjs +417 -0
  35. package/dist/TransactionStore-CiEtt5XJ.mjs.map +1 -0
  36. package/dist/TrendsStore-Idq3QfoA.mjs +131 -0
  37. package/dist/TrendsStore-Idq3QfoA.mjs.map +1 -0
  38. package/dist/accounts/index.es.js +18 -0
  39. package/dist/accounts/index.es.js.map +1 -0
  40. package/dist/analytics/index.es.js +170 -0
  41. package/dist/analytics/index.es.js.map +1 -0
  42. package/dist/budgets/index.es.js +1116 -0
  43. package/dist/budgets/index.es.js.map +1 -0
  44. package/dist/cashflow/index.es.js +118 -0
  45. package/dist/cashflow/index.es.js.map +1 -0
  46. package/dist/categories/index.es.js +10 -0
  47. package/dist/categories/index.es.js.map +1 -0
  48. package/dist/categories/util/CategoryUtil.d.ts +3 -2
  49. package/dist/common/components/charts/StackedLineChart.d.ts +2 -2
  50. package/dist/common/components/charts/stackedlinechart/CustomLegend.d.ts +1 -0
  51. package/dist/common/context/hooks.d.ts +13 -13
  52. package/dist/common/index.es.js +1549 -0
  53. package/dist/common/index.es.js.map +1 -0
  54. package/dist/common/types/AppData.d.ts +2 -0
  55. package/dist/common/types/Category.d.ts +2 -8
  56. package/dist/common/types/index.d.ts +1 -1
  57. package/dist/dashboard/index.es.js +257 -0
  58. package/dist/dashboard/index.es.js.map +1 -0
  59. package/dist/debts/index.es.js +9 -0
  60. package/dist/debts/index.es.js.map +1 -0
  61. package/dist/finstrong/index.es.js +11 -0
  62. package/dist/finstrong/index.es.js.map +1 -0
  63. package/dist/goals/index.es.js +9 -0
  64. package/dist/goals/index.es.js.map +1 -0
  65. package/dist/help/components/content/section/index.d.ts +15 -15
  66. package/dist/help/index.es.js +6 -0
  67. package/dist/help/index.es.js.map +1 -0
  68. package/dist/investments/index.es.js +1694 -0
  69. package/dist/investments/index.es.js.map +1 -0
  70. package/dist/merchants/index.es.js +7 -0
  71. package/dist/merchants/index.es.js.map +1 -0
  72. package/dist/microinsights/index.es.js +21 -0
  73. package/dist/microinsights/index.es.js.map +1 -0
  74. package/dist/networth/index.es.js +11 -0
  75. package/dist/networth/index.es.js.map +1 -0
  76. package/dist/notifications/index.es.js +116 -0
  77. package/dist/notifications/index.es.js.map +1 -0
  78. package/dist/recurringtransactions/index.es.js +14 -0
  79. package/dist/recurringtransactions/index.es.js.map +1 -0
  80. package/dist/settings/index.es.js +112 -0
  81. package/dist/settings/index.es.js.map +1 -0
  82. package/dist/spending/index.es.js +632 -0
  83. package/dist/spending/index.es.js.map +1 -0
  84. package/dist/transactions/index.es.js +19 -0
  85. package/dist/transactions/index.es.js.map +1 -0
  86. package/dist/trends/components/CategoriesList.d.ts +5 -5
  87. package/dist/trends/components/CategoriesListItem.d.ts +7 -4
  88. package/dist/trends/components/CategoryDetailChart.d.ts +5 -1
  89. package/dist/trends/index.es.js +10 -0
  90. package/dist/trends/index.es.js.map +1 -0
  91. package/dist/trends/stores/TrendsStore.d.ts +11 -16
  92. package/package.json +91 -3
  93. package/dist/index.d.ts +0 -22
  94. package/dist/index.es.js +0 -29873
  95. package/dist/index.es.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CashflowStore-gPEEBiXo.mjs","sources":["../src/cashflow/stores/UiStore.ts","../src/cashflow/stores/CashflowStore.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\nimport { addDays } from 'date-fns/addDays'\nimport { differenceInDays } from 'date-fns/differenceInDays'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { isBefore } from 'date-fns/isBefore'\nimport { startOfToday } from 'date-fns/startOfToday'\n\nimport { type Account, type Recurrence } from '../../common'\n\nexport class UiStore {\n // Cashflow is hard-coded to display 30 days starting from today\n dateRange = { start: startOfToday(), end: addDays(startOfToday(), 30) }\n isDirty = false\n\n nextIncome: Recurrence | undefined = undefined\n upcomingExpenses: Recurrence[] = []\n\n selectedCashAccounts: Account[] = []\n\n constructor() {\n makeAutoObservable(this)\n }\n\n // Returns the number of days until the next income activity or 0 if there is no income activity\n get daysUntilNextIncome() {\n return this.nextIncome\n ? Math.abs(differenceInDays(startOfToday(), this.nextIncome.expectedDate))\n : 0\n }\n\n // Returns the expenses (Activities) until the next income activity or the end of the month\n // if there is no income activity\n get expensesTilNextIncome() {\n return this.upcomingExpenses.filter((a) =>\n isBefore(a.expectedDate, this.nextIncome?.expectedDate || endOfMonth(new Date())),\n )\n }\n\n setNextIncome = (nextIncome: Recurrence) => {\n this.nextIncome = nextIncome\n }\n\n setUpcomingExpenses = (expenses: Recurrence[]) => {\n this.upcomingExpenses = expenses\n }\n\n setSelectedCashAccounts = (accounts: Account[]) => (this.selectedCashAccounts = accounts)\n}\n","import { makeAutoObservable } from 'mobx'\n\nimport { GlobalStore, type UserProfile } from '../../common'\n\nimport { UiStore } from './UiStore'\n\nexport class CashflowStore {\n globalStore: GlobalStore\n uiStore: UiStore\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.uiStore = new UiStore()\n\n makeAutoObservable(this)\n }\n\n completeOnboarding = async () => {\n const updatedUserProfile = {\n ...this.globalStore.userStore.userProfile,\n has_completed_cash_flow_onboarding: true,\n } as UserProfile\n\n await this.globalStore.userStore.updateUserProfile(updatedUserProfile)\n }\n}\n"],"names":["UiStore","startOfToday","addDays","makeAutoObservable","differenceInDays","a","isBefore","endOfMonth","nextIncome","expenses","accounts","CashflowStore","globalStore","updatedUserProfile"],"mappings":";;;;;;AASO,MAAMA,EAAQ;AAAA;AAAA,EAEnB,YAAY,EAAE,OAAOC,KAAgB,KAAKC,EAAQD,EAAA,GAAgB,EAAE;EACpE,UAAU;AAAA,EAEV,aAAqC;AAAA,EACrC,mBAAiC,CAAA;AAAA,EAEjC,uBAAkC,CAAA;AAAA,EAElC,cAAc;AACZ,IAAAE,EAAmB,IAAI;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,sBAAsB;AACjB,WAAA,KAAK,aACR,KAAK,IAAIC,EAAiBH,EAAa,GAAG,KAAK,WAAW,YAAY,CAAC,IACvE;AAAA,EACN;AAAA;AAAA;AAAA,EAIA,IAAI,wBAAwB;AAC1B,WAAO,KAAK,iBAAiB;AAAA,MAAO,CAACI,MACnCC,EAASD,EAAE,cAAc,KAAK,YAAY,gBAAgBE,EAAW,oBAAI,KAAM,CAAA,CAAC;AAAA,IAAA;AAAA,EAEpF;AAAA,EAEA,gBAAgB,CAACC,MAA2B;AAC1C,SAAK,aAAaA;AAAA,EAAA;AAAA,EAGpB,sBAAsB,CAACC,MAA2B;AAChD,SAAK,mBAAmBA;AAAA,EAAA;AAAA,EAG1B,0BAA0B,CAACC,MAAyB,KAAK,uBAAuBA;AAClF;ACzCO,MAAMC,EAAc;AAAA,EACzB;AAAA,EACA;AAAA,EAEA,YAAYC,GAA0B;AACpC,SAAK,cAAcA,GACd,KAAA,UAAU,IAAIZ,KAEnBG,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,qBAAqB,YAAY;AAC/B,UAAMU,IAAqB;AAAA,MACzB,GAAG,KAAK,YAAY,UAAU;AAAA,MAC9B,oCAAoC;AAAA,IAAA;AAGtC,UAAM,KAAK,YAAY,UAAU,kBAAkBA,CAAkB;AAAA,EAAA;AAEzE;"}
@@ -0,0 +1,260 @@
1
+ import { makeAutoObservable as d, runInAction as l } from "mobx";
2
+ import { getUnixTime as a } from "date-fns/getUnixTime";
3
+ import { subMonths as g } from "date-fns/subMonths";
4
+ import { startOfMonth as m } from "date-fns/startOfMonth";
5
+ import { endOfMonth as p } from "date-fns/endOfMonth";
6
+ import "bowser";
7
+ import "date-fns/intlFormat";
8
+ import { ae as u, af as s, aX as C, aK as T, aY as f } from "./ConnectMiniWidget-CQWafYtQ.mjs";
9
+ import "date-fns/addMonths";
10
+ import "date-fns/addQuarters";
11
+ import "date-fns/addWeeks";
12
+ import "date-fns/addYears";
13
+ import "date-fns/getDay";
14
+ import "date-fns/isBefore";
15
+ import "date-fns/nextDay";
16
+ import "date-fns/setDate";
17
+ import "date-fns/startOfToday";
18
+ import "date-fns/fromUnixTime";
19
+ import "react";
20
+ import "numeral";
21
+ import "@mui/material";
22
+ import "react/jsx-runtime";
23
+ import "@mui/material/Button";
24
+ import "@mxenabled/mxui";
25
+ import "@mui/material/Tooltip";
26
+ import "@mui/material/Box";
27
+ import "@mui/material/IconButton";
28
+ import "./Loader-CwdK8lfx.mjs";
29
+ import "@mui/material/styles/useTheme";
30
+ import "@mui/material/useMediaQuery";
31
+ import "@mxenabled/cssinjs";
32
+ import "date-fns/addDays";
33
+ import "date-fns/eachDayOfInterval";
34
+ import "date-fns/eachWeekOfInterval";
35
+ import "date-fns/format";
36
+ import "date-fns/isSameMonth";
37
+ import "@mui/material/Paper";
38
+ import "@mxenabled/mx-icons";
39
+ import "date-fns/isSameDay";
40
+ import "date-fns/isWithinInterval";
41
+ import "d3";
42
+ import "@mui/material/styles";
43
+ import "@mui/x-charts";
44
+ import "@mui/x-charts/ChartsTooltip";
45
+ import "@mui/material/Stack";
46
+ import "date-fns/differenceInCalendarDays";
47
+ import "date-fns/endOfToday";
48
+ import "date-fns/endOfYear";
49
+ import "date-fns/startOfYear";
50
+ import "date-fns/subDays";
51
+ import "date-fns/subYears";
52
+ import "@mui/material/ButtonGroup";
53
+ import "@mui/material/Tab";
54
+ import "@mui/material/Tabs";
55
+ import "@mui/material/ToggleButton";
56
+ import "@mui/material/ToggleButtonGroup";
57
+ import "@mui/material/Dialog";
58
+ import "@mui/material/DialogContent";
59
+ import "@mui/material/Card";
60
+ import "@mui/material/CardContent";
61
+ import "@mui/material/CardHeader";
62
+ import "uuid";
63
+ import "@mui/material/CircularProgress";
64
+ import "@mui/material/FormControlLabel";
65
+ import "@mui/material/Radio";
66
+ import "@mui/material/Avatar";
67
+ import "@mui/material/ListItem";
68
+ import "@mui/material/ListItemAvatar";
69
+ import "@mui/material/ListItemButton";
70
+ import "@mui/material/ListItemText";
71
+ import "@mui/material/ListItemIcon";
72
+ import "@mui/material/MenuItem";
73
+ import "@mui/material/TextField";
74
+ import "@mui/material/Switch";
75
+ import "posthog-js";
76
+ import "date-fns/differenceInDays";
77
+ import "@mui/x-data-grid-pro";
78
+ import "date-fns";
79
+ import "@mui/material/Divider";
80
+ import "@mui/material/List";
81
+ import "date-fns/formatISO";
82
+ import "date-fns/isAfter";
83
+ import "date-fns/parseISO";
84
+ import "date-fns/subQuarters";
85
+ import "date-fns/lastDayOfMonth";
86
+ import "date-fns/setDayOfYear";
87
+ import "date-fns/addSeconds";
88
+ import "date-fns/differenceInCalendarMonths";
89
+ import "date-fns/getMonth";
90
+ class h {
91
+ fetchInstance;
92
+ constructor(t, e) {
93
+ this.fetchInstance = new u(t, e);
94
+ }
95
+ addCategory = async (t) => this.fetchInstance.post(s.CATEGORIES, t).then((e) => e.category);
96
+ getCategories = async () => this.fetchInstance.get(s.CATEGORIES).then((t) => t.categories);
97
+ getDateRangeCategoryTotals = async (t, e, r) => r.length === 0 ? [] : this.fetchInstance.post(`${s.DATE_RANGE_CATEGORY_TOTALS}/from/${t}/to/${e}`, {
98
+ account_guid: r.map((o) => o.guid)
99
+ }).then((o) => o.date_range_category_totals);
100
+ getMonthlyCategoryTotals = async (t, e, r) => {
101
+ try {
102
+ const o = `${s.MONTHLY_CATEGORY_TOTALS}/from/${t}/to/${e}`;
103
+ if (r) {
104
+ const i = r.length === 0 ? [""] : r.map((y) => y.guid);
105
+ return (await this.fetchInstance.post(o, { account_guid: i })).monthly_category_totals;
106
+ } else
107
+ return (await this.fetchInstance.get(o)).monthly_category_totals;
108
+ } catch (o) {
109
+ throw console.error("Error fetching monthly category totals:", o), o;
110
+ }
111
+ };
112
+ removeCategory = async (t) => this.fetchInstance.delete(`${s.CATEGORIES}/${t}`);
113
+ updateCategory = async (t) => this.fetchInstance.put(`${s.CATEGORIES}/${t.guid}`, t).then((e) => e.category);
114
+ }
115
+ class w {
116
+ expandedGuid = null;
117
+ selectedGuid = null;
118
+ searchValue = "";
119
+ showSelected = !0;
120
+ shouldDisableDrawerScroll = !1;
121
+ unselectable = [];
122
+ unselectableText = "";
123
+ savedOnSelect;
124
+ // todo
125
+ constructor() {
126
+ d(this);
127
+ }
128
+ setExpandedGuid = (t) => this.expandedGuid = t;
129
+ setSelectedGuid = (t) => this.selectedGuid = t;
130
+ setSearchValue = (t) => this.searchValue = t;
131
+ setShouldDisableDrawerScroll = (t) => this.shouldDisableDrawerScroll = t;
132
+ setShowSelected = (t) => this.showSelected = t;
133
+ setUnselectable = (t) => this.unselectable = t;
134
+ setUnselectableText = (t) => this.unselectableText = t;
135
+ onSelect = (t) => this.savedOnSelect(t);
136
+ setOnSelect = (t) => this.savedOnSelect = t;
137
+ }
138
+ class oe {
139
+ globalStore;
140
+ uiStore;
141
+ api = new h("/", "");
142
+ categories = [];
143
+ dateRangeCategoryTotals = [];
144
+ monthlyCategoryTotals = [];
145
+ dataRangeTotalsLoaded = !1;
146
+ isLoadingCategoryTotals = !1;
147
+ monthlyTotalsLoaded = !1;
148
+ constructor(t) {
149
+ this.globalStore = t, this.uiStore = new w(), this.api = new h(t.endpoint, t.sessionToken), d(this);
150
+ }
151
+ get detailedCategories() {
152
+ return C(
153
+ this.categories,
154
+ this.dateRangeCategoryTotals,
155
+ this.monthlyCategoryTotals,
156
+ this.globalStore.transactionStore.sortedTransactions
157
+ );
158
+ }
159
+ get incomeCategories() {
160
+ return this.detailedCategories.filter((t) => t.is_income);
161
+ }
162
+ get spendCategories() {
163
+ return this.detailedCategories.filter(
164
+ (t) => !t.is_income && !t.isTransfer && t.guid !== T.INVESTMENTS
165
+ );
166
+ }
167
+ get transferCategories() {
168
+ return this.detailedCategories.filter((t) => t.isTransfer);
169
+ }
170
+ addCategory = async (t, e) => {
171
+ const r = { name: t, parent_guid: e };
172
+ try {
173
+ await this.api.addCategory(r), await this.loadCategories();
174
+ } catch (o) {
175
+ console.error(`Error occurred while adding category: ${o}`);
176
+ }
177
+ };
178
+ loadCategories = async (t) => {
179
+ try {
180
+ const e = t || await this.api.getCategories(), { default_categories: r } = this.globalStore.copyStore.copy.categories;
181
+ l(() => {
182
+ this.categories = e.map((o) => ({
183
+ ...o,
184
+ name: r[o.guid] ? r[o.guid].replace(/&/g, "&") : o.name
185
+ }));
186
+ });
187
+ } catch (e) {
188
+ console.error(`Error occurred while getting categories: ${e}`);
189
+ }
190
+ };
191
+ loadDateRangeCategoryTotals = async (t, e, r) => {
192
+ this.setIsLoadingCategoryTotals(!0);
193
+ try {
194
+ const o = await this.api.getDateRangeCategoryTotals(
195
+ a(e),
196
+ a(r),
197
+ t
198
+ );
199
+ l(() => {
200
+ this.dateRangeCategoryTotals = o, this.setIsLoadingCategoryTotals(!1), this.dataRangeTotalsLoaded = !0;
201
+ });
202
+ } catch (o) {
203
+ this.setIsLoadingCategoryTotals(!1), console.error(`Error occurred while getting date range category totals: ${o}`);
204
+ }
205
+ };
206
+ loadMonthlyCategoryTotals = async (t = this.globalStore.globalUiStore.selectedAccounts, e, r) => {
207
+ const o = a(m(e ?? g(/* @__PURE__ */ new Date(), 11))), i = a(p(r ?? /* @__PURE__ */ new Date()));
208
+ try {
209
+ const n = await this.api.getMonthlyCategoryTotals(o, i, t);
210
+ l(() => {
211
+ this.monthlyCategoryTotals = n, this.monthlyTotalsLoaded = !0;
212
+ });
213
+ } catch (n) {
214
+ console.error(`Error occurred while getting monthly category totals: ${n}`);
215
+ }
216
+ };
217
+ reloadCategoryTotals = async (t, e, r) => {
218
+ this.setIsLoadingCategoryTotals(!0);
219
+ try {
220
+ const o = await this.api.getDateRangeCategoryTotals(
221
+ a(e),
222
+ a(r),
223
+ t
224
+ ), i = await this.api.getMonthlyCategoryTotals(
225
+ a(m(g(r, 11))),
226
+ a(p(r)),
227
+ t
228
+ );
229
+ l(() => {
230
+ this.dateRangeCategoryTotals = o, this.monthlyCategoryTotals = i, this.dataRangeTotalsLoaded = !0, this.monthlyTotalsLoaded = !0, this.setIsLoadingCategoryTotals(!1);
231
+ });
232
+ } catch (o) {
233
+ console.error(`Error occurred while getting category totals: ${o}`);
234
+ }
235
+ };
236
+ removeCategory = async (t) => {
237
+ try {
238
+ await this.api.removeCategory(t), await this.loadCategories();
239
+ } catch (e) {
240
+ console.error(`Error occurred while removing category: ${e}`);
241
+ }
242
+ };
243
+ setIsLoadingCategoryTotals = (t) => {
244
+ this.isLoadingCategoryTotals = t;
245
+ };
246
+ updateCategory = async (t) => {
247
+ try {
248
+ await this.api.updateCategory(t), await this.loadCategories();
249
+ } catch (e) {
250
+ console.error(`Error occurred while updating category: ${e}`);
251
+ }
252
+ };
253
+ // TODO: Remove this after refactoring Trends components to use detailedCategories
254
+ getCategoryName = (t) => this.categories.find((r) => r.guid === t)?.name ?? f[t];
255
+ }
256
+ export {
257
+ oe as C,
258
+ h as a
259
+ };
260
+ //# sourceMappingURL=CategoryStore-m7oieLzP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CategoryStore-m7oieLzP.mjs","sources":["../src/common/api/CategoryApi.ts","../src/categories/stores/UiStore.ts","../src/categories/stores/CategoryStore.ts"],"sourcesContent":["import Fetch from '../utils/Fetch'\n\nimport { ApiEndpoints } from '../constants/ApiEndpoints'\n\nimport type { Account } from '../types/Account'\nimport type { Category } from '../types/Category'\n\nexport class CategoryApi {\n fetchInstance: Fetch\n\n constructor(endpoint: string, token: string) {\n this.fetchInstance = new Fetch(endpoint, token)\n }\n\n addCategory = async (category: Category) => {\n return this.fetchInstance.post(ApiEndpoints.CATEGORIES, category).then((data) => data.category)\n }\n\n getCategories = async () => {\n return this.fetchInstance.get(ApiEndpoints.CATEGORIES).then((data) => data.categories)\n }\n\n getDateRangeCategoryTotals = async (startDate: number, endDate: number, accounts: Account[]) => {\n // If no accounts are selected, return an empty array\n if (accounts.length === 0) return []\n return this.fetchInstance\n .post(`${ApiEndpoints.DATE_RANGE_CATEGORY_TOTALS}/from/${startDate}/to/${endDate}`, {\n account_guid: accounts.map((account) => account.guid),\n })\n .then((data) => data.date_range_category_totals)\n }\n\n getMonthlyCategoryTotals = async (startDate: number, endDate: number, accounts?: Account[]) => {\n try {\n const url = `${ApiEndpoints.MONTHLY_CATEGORY_TOTALS}/from/${startDate}/to/${endDate}`\n if (accounts) {\n const accountGuids = accounts.length === 0 ? [''] : accounts.map((account) => account.guid)\n const response = await this.fetchInstance.post(url, { account_guid: accountGuids })\n return response.monthly_category_totals\n } else {\n const response = await this.fetchInstance.get(url)\n return response.monthly_category_totals\n }\n } catch (error) {\n console.error('Error fetching monthly category totals:', error)\n throw error // Re-throw the error for the caller to handle\n }\n }\n removeCategory = async (guid: string) => {\n return this.fetchInstance.delete(`${ApiEndpoints.CATEGORIES}/${guid}`)\n }\n\n updateCategory = async (category: Category) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.CATEGORIES}/${category.guid}`, category)\n .then((data) => data.category)\n }\n}\n","import { makeAutoObservable } from 'mobx'\n\nexport class UiStore {\n expandedGuid: string | null = null\n selectedGuid: string | null = null\n searchValue = ''\n showSelected = true\n shouldDisableDrawerScroll = false\n unselectable: string[] = []\n unselectableText = ''\n\n savedOnSelect: any // todo\n\n constructor() {\n makeAutoObservable(this)\n }\n\n setExpandedGuid = (guid: string | null) => (this.expandedGuid = guid)\n\n setSelectedGuid = (guid: string | null) => (this.selectedGuid = guid)\n\n setSearchValue = (value: string) => (this.searchValue = value)\n\n setShouldDisableDrawerScroll = (shouldDisable: boolean) =>\n (this.shouldDisableDrawerScroll = shouldDisable)\n\n setShowSelected = (showSelected: boolean) => (this.showSelected = showSelected)\n\n setUnselectable = (unselectable: string[]) => (this.unselectable = unselectable)\n\n setUnselectableText = (text: string) => (this.unselectableText = text)\n\n onSelect = (guid: string) => this.savedOnSelect(guid)\n\n setOnSelect = (callback: any) => (this.savedOnSelect = callback)\n}\n","import { makeAutoObservable, runInAction } from 'mobx'\nimport { getUnixTime } from 'date-fns/getUnixTime'\nimport { subMonths } from 'date-fns/subMonths'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { endOfMonth } from 'date-fns/endOfMonth'\n\nimport { Account, CategoryApi, CategoryGuids, CategoryGuidToName } from '../../common'\n\nimport type {\n Category,\n DetailedCategory,\n DateRangeCategoryTotals,\n GlobalStore,\n MonthlyCategoryTotals,\n} from '../../common'\n\nimport { augmentCategories } from '../util/CategoryUtil'\nimport { UiStore } from './UiStore'\n\nexport class CategoryStore {\n globalStore: GlobalStore\n uiStore: UiStore\n api = new CategoryApi('/', '')\n\n categories: Category[] = []\n dateRangeCategoryTotals: DateRangeCategoryTotals[] = []\n monthlyCategoryTotals: MonthlyCategoryTotals[] = []\n\n dataRangeTotalsLoaded = false\n isLoadingCategoryTotals = false\n monthlyTotalsLoaded = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.uiStore = new UiStore()\n this.api = new CategoryApi(globalStore.endpoint, globalStore.sessionToken)\n\n makeAutoObservable(this)\n }\n\n get detailedCategories(): DetailedCategory[] {\n return augmentCategories(\n this.categories,\n this.dateRangeCategoryTotals,\n this.monthlyCategoryTotals,\n this.globalStore.transactionStore.sortedTransactions,\n )\n }\n\n get incomeCategories(): DetailedCategory[] {\n return this.detailedCategories.filter((c) => c.is_income)\n }\n\n get spendCategories(): DetailedCategory[] {\n return this.detailedCategories.filter(\n (c) => !c.is_income && !c.isTransfer && c.guid !== CategoryGuids.INVESTMENTS,\n )\n }\n\n get transferCategories(): DetailedCategory[] {\n return this.detailedCategories.filter((c) => c.isTransfer)\n }\n\n addCategory = async (name: string, parentGuid: string) => {\n const category = { name, parent_guid: parentGuid } as Category\n\n try {\n await this.api.addCategory(category)\n await this.loadCategories()\n } catch (error) {\n console.error(`Error occurred while adding category: ${error}`)\n }\n }\n\n loadCategories = async (categoriesOverride?: Category[]) => {\n try {\n const categories = categoriesOverride || (await this.api.getCategories())\n const { default_categories } = this.globalStore.copyStore.copy.categories\n\n runInAction(() => {\n this.categories = categories.map((category: Category) => ({\n ...category,\n name: default_categories[category.guid]\n ? default_categories[category.guid].replace(/&/g, '&')\n : category.name,\n }))\n })\n } catch (error) {\n console.error(`Error occurred while getting categories: ${error}`)\n }\n }\n\n loadDateRangeCategoryTotals = async (accounts: Account[], startDate: Date, endDate: Date) => {\n this.setIsLoadingCategoryTotals(true)\n try {\n const totals = await this.api.getDateRangeCategoryTotals(\n getUnixTime(startDate),\n getUnixTime(endDate),\n accounts,\n )\n runInAction(() => {\n this.dateRangeCategoryTotals = totals\n this.setIsLoadingCategoryTotals(false)\n this.dataRangeTotalsLoaded = true\n })\n } catch (error) {\n this.setIsLoadingCategoryTotals(false)\n console.error(`Error occurred while getting date range category totals: ${error}`)\n }\n }\n\n loadMonthlyCategoryTotals = async (\n accounts: Account[] = this.globalStore.globalUiStore.selectedAccounts,\n startDate?: Date,\n endDate?: Date,\n ) => {\n const start = getUnixTime(startOfMonth(startDate ?? subMonths(new Date(), 11)))\n const end = getUnixTime(endOfMonth(endDate ?? new Date()))\n\n try {\n const totals = await this.api.getMonthlyCategoryTotals(start, end, accounts)\n\n runInAction(() => {\n this.monthlyCategoryTotals = totals\n this.monthlyTotalsLoaded = true\n })\n } catch (error) {\n console.error(`Error occurred while getting monthly category totals: ${error}`)\n }\n }\n\n reloadCategoryTotals = async (accounts: Account[], startDate: Date, endDate: Date) => {\n this.setIsLoadingCategoryTotals(true)\n try {\n const dateRangeTotals = await this.api.getDateRangeCategoryTotals(\n getUnixTime(startDate),\n getUnixTime(endDate),\n accounts,\n )\n\n const monthlyTotals = await this.api.getMonthlyCategoryTotals(\n getUnixTime(startOfMonth(subMonths(endDate, 11))),\n getUnixTime(endOfMonth(endDate)),\n accounts,\n )\n\n runInAction(() => {\n this.dateRangeCategoryTotals = dateRangeTotals\n this.monthlyCategoryTotals = monthlyTotals\n this.dataRangeTotalsLoaded = true\n this.monthlyTotalsLoaded = true\n this.setIsLoadingCategoryTotals(false)\n })\n } catch (error) {\n console.error(`Error occurred while getting category totals: ${error}`)\n }\n }\n\n removeCategory = async (guid: string) => {\n try {\n await this.api.removeCategory(guid)\n await this.loadCategories()\n } catch (error) {\n console.error(`Error occurred while removing category: ${error}`)\n }\n }\n\n setIsLoadingCategoryTotals = (isLoading: boolean) => {\n this.isLoadingCategoryTotals = isLoading\n }\n\n updateCategory = async (category: Category) => {\n try {\n await this.api.updateCategory(category)\n await this.loadCategories()\n } catch (error) {\n console.error(`Error occurred while updating category: ${error}`)\n }\n }\n\n // TODO: Remove this after refactoring Trends components to use detailedCategories\n getCategoryName = (guid: string) => {\n const category = this.categories.find((c) => c.guid === guid)\n return category?.name ?? CategoryGuidToName[guid]\n }\n}\n"],"names":["CategoryApi","endpoint","token","Fetch","category","ApiEndpoints","data","startDate","endDate","accounts","account","url","accountGuids","error","guid","UiStore","makeAutoObservable","value","shouldDisable","showSelected","unselectable","text","callback","CategoryStore","globalStore","augmentCategories","c","CategoryGuids","name","parentGuid","categoriesOverride","categories","default_categories","runInAction","totals","getUnixTime","start","startOfMonth","subMonths","end","endOfMonth","dateRangeTotals","monthlyTotals","isLoading","CategoryGuidToName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOO,MAAMA,EAAY;AAAA,EACvB;AAAA,EAEA,YAAYC,GAAkBC,GAAe;AAC3C,SAAK,gBAAgB,IAAIC,EAAMF,GAAUC,CAAK;AAAA,EAChD;AAAA,EAEA,cAAc,OAAOE,MACZ,KAAK,cAAc,KAAKC,EAAa,YAAYD,CAAQ,EAAE,KAAK,CAACE,MAASA,EAAK,QAAQ;AAAA,EAGhG,gBAAgB,YACP,KAAK,cAAc,IAAID,EAAa,UAAU,EAAE,KAAK,CAACC,MAASA,EAAK,UAAU;AAAA,EA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