@mx-cartographer/experiences 9.7.55 → 9.7.57
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/core/stores/TransactionStore.d.ts +6 -0
- package/dist/core/stores/TransactionStore.es.js +45 -33
- package/dist/core/stores/TransactionStore.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +8 -0
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.d.ts +5 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +63 -58
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +119 -111
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +7 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +111 -62
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.d.ts +7 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js +13 -13
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.d.ts +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +10 -7
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +48 -18
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +90 -57
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { buildDynamicCopy as
|
|
2
|
-
import { DATE_FORMATS_INTL as
|
|
3
|
-
import { fromUnixUTC as
|
|
4
|
-
import { getCategoryColor as
|
|
5
|
-
import { getLayoutConfig as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { buildDynamicCopy as A } from "../../../core/utils/Localization.es.js";
|
|
2
|
+
import { DATE_FORMATS_INTL as C, formatDate as L } from "../../../core/constants/DateFormats.es.js";
|
|
3
|
+
import { fromUnixUTC as O } from "../../../core/utils/DateUtil.es.js";
|
|
4
|
+
import { getCategoryColor as b } from "../../../core/utils/CategoryUtil.es.js";
|
|
5
|
+
import { getLayoutConfig as I } from "../../blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js";
|
|
6
|
+
import { buildProjectedBillTransaction as M, calendarDateOf as E, finiteNumberOf as T, guidListOf as D, nonEmptyStringOf as h } from "./utils.es.js";
|
|
7
|
+
import { MerchantLogo as B } from "@mxenabled/mxui";
|
|
8
|
+
import { Icon as R } from "@mxenabled/mx-icons";
|
|
9
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
10
|
+
import { endOfMonth as y, fromUnixTime as G, isValid as S, parseISO as d, startOfMonth as N } from "date-fns";
|
|
10
11
|
var i = {
|
|
11
12
|
TRANSACTION: "not_standard_amount",
|
|
12
13
|
CATEGORY_SPEND: "category_spend",
|
|
@@ -20,10 +21,10 @@ var i = {
|
|
|
20
21
|
NON_ESSENTIAL_CATEGORY: "non_essential_category_summary",
|
|
21
22
|
DEPOSIT_SUMMARY: "monthly_deposit_summary",
|
|
22
23
|
LOW_BALANCE: "low_balance"
|
|
23
|
-
},
|
|
24
|
-
start:
|
|
25
|
-
end:
|
|
26
|
-
}),
|
|
24
|
+
}, l = (t, e) => e && b(e, t) || t.palette.primary.main, p = (t) => typeof t == "string" ? d(t) : new Date(t ?? NaN), _ = (t) => ({
|
|
25
|
+
start: N(p(t)),
|
|
26
|
+
end: y(p(t))
|
|
27
|
+
}), u = (t) => t?.length ? { accounts: t } : {}, U = ({ beat: t }) => {
|
|
27
28
|
const { account_guid: e, from_date: o, to_date: r } = t.insights_payload?.drilldown_data ?? {};
|
|
28
29
|
return typeof e != "string" || typeof o != "number" || typeof r != "number" || !Number.isFinite(o) || !Number.isFinite(r) || r <= o ? {
|
|
29
30
|
accounts: [],
|
|
@@ -31,65 +32,100 @@ var i = {
|
|
|
31
32
|
} : {
|
|
32
33
|
accounts: [e],
|
|
33
34
|
dateRange: {
|
|
34
|
-
start:
|
|
35
|
-
end:
|
|
35
|
+
start: O(o),
|
|
36
|
+
end: O(r - 1)
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
|
-
},
|
|
39
|
-
const
|
|
39
|
+
}, w = (t) => {
|
|
40
|
+
const e = t?.drilldown_data ?? {};
|
|
40
41
|
return {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
transaction_guids: D(e.transaction_guids),
|
|
43
|
+
date: E(e.due_date),
|
|
44
|
+
amount: T(e.amount),
|
|
45
|
+
category_guid: h(e.category_guid),
|
|
46
|
+
average_amount: T(e.average_amount),
|
|
47
|
+
merchant_name: h(e.merchant_name)
|
|
44
48
|
};
|
|
45
|
-
},
|
|
49
|
+
}, P = (t, e) => {
|
|
50
|
+
const o = M(t, e);
|
|
51
|
+
return o ? [...t, o] : t;
|
|
52
|
+
}, Y = (t, e, o, r) => {
|
|
53
|
+
const a = r?.merchant_name, n = r?.date;
|
|
54
|
+
if (!a || !n) return;
|
|
55
|
+
const s = e.transaction_history_block?.upcoming_bill_tip_message;
|
|
56
|
+
if (s)
|
|
57
|
+
return {
|
|
58
|
+
message: A(s, /* @__PURE__ */ c("strong", { children: e.general.tip_section_title }), a, L(d(n), C.FULL_MONTH_DAY)),
|
|
59
|
+
onDismiss: () => t(!0)
|
|
60
|
+
};
|
|
61
|
+
}, f = ({ beatTransactions: t, dataSeries: e, selectedIndex: o }) => {
|
|
62
|
+
const r = e[o], a = r?.guid, n = t.find((s) => s.guid === a)?.has_been_split;
|
|
63
|
+
return {
|
|
64
|
+
custom: (s) => s.guid === a,
|
|
65
|
+
dateRange: _(r?.date),
|
|
66
|
+
showSplits: !n
|
|
67
|
+
};
|
|
68
|
+
}, F = ({ dataSeries: t, selectedIndex: e, instanceSlotData: o }) => {
|
|
46
69
|
const r = t[e], a = o.category_guid ?? r?.guid;
|
|
47
70
|
return {
|
|
48
|
-
custom: (
|
|
49
|
-
dateRange:
|
|
71
|
+
custom: (n) => n.category_guid === a || n.top_level_category_guid === a,
|
|
72
|
+
dateRange: _(r?.date)
|
|
50
73
|
};
|
|
51
|
-
},
|
|
74
|
+
}, H = ({ dataSeries: t, selectedIndex: e, spendCategoryGuids: o, instanceSlotData: r }) => {
|
|
52
75
|
const a = t[e];
|
|
53
76
|
return {
|
|
54
|
-
custom: (
|
|
55
|
-
dateRange:
|
|
56
|
-
...
|
|
77
|
+
custom: (n) => !!n.top_level_category_guid && o.includes(n.top_level_category_guid),
|
|
78
|
+
dateRange: _(a?.date),
|
|
79
|
+
...u(r.account_guids)
|
|
57
80
|
};
|
|
58
|
-
},
|
|
59
|
-
const
|
|
81
|
+
}, x = (t) => typeof t == "number" ? G(t) : d(t ?? ""), V = ({ beat: t, dataSeries: e, selectedIndex: o, isLastTab: r, instanceSlotData: a }) => {
|
|
82
|
+
const n = e[o], { start: s, end: g } = _(n?.date), m = x(t.created_at);
|
|
60
83
|
return {
|
|
61
84
|
dateRange: {
|
|
62
|
-
start:
|
|
63
|
-
end: r &&
|
|
85
|
+
start: s,
|
|
86
|
+
end: r && S(m) && m < g ? m : g
|
|
87
|
+
},
|
|
88
|
+
...u(t.account_guids?.length ? t.account_guids : a.account_guids)
|
|
89
|
+
};
|
|
90
|
+
}, v = ({ beat: t, comparisonBars: e, selectedIndex: o, subIndex: r }) => {
|
|
91
|
+
const a = e[o], n = new Set(r === 1 ? a?.comparisonGuids : a?.mainGuids), s = d(a?.date ?? "");
|
|
92
|
+
return !n.size || !S(s) ? {
|
|
93
|
+
accounts: [],
|
|
94
|
+
custom: () => !1
|
|
95
|
+
} : {
|
|
96
|
+
custom: (g) => n.has(g.guid),
|
|
97
|
+
dateRange: {
|
|
98
|
+
start: N(s),
|
|
99
|
+
end: y(s)
|
|
64
100
|
},
|
|
65
|
-
...
|
|
101
|
+
...u(t.account_guids)
|
|
66
102
|
};
|
|
67
|
-
},
|
|
68
|
-
const
|
|
69
|
-
return !
|
|
103
|
+
}, z = ({ beat: t, dataSeries: e, subIndex: o }) => {
|
|
104
|
+
const r = e[o], a = new Set(r?.aggregated_guids), n = d(r?.date ?? "");
|
|
105
|
+
return !a.size || !S(n) ? {
|
|
70
106
|
accounts: [],
|
|
71
107
|
custom: () => !1
|
|
72
108
|
} : {
|
|
73
|
-
custom: (
|
|
109
|
+
custom: (s) => a.has(s.guid),
|
|
74
110
|
dateRange: {
|
|
75
|
-
start:
|
|
76
|
-
end:
|
|
111
|
+
start: N(n),
|
|
112
|
+
end: y(n)
|
|
77
113
|
},
|
|
78
|
-
...
|
|
114
|
+
...u(t.account_guids)
|
|
79
115
|
};
|
|
80
|
-
},
|
|
116
|
+
}, tt = {
|
|
81
117
|
[i.TRANSACTION]: {
|
|
82
118
|
top: "singleBar",
|
|
83
119
|
scope: "store",
|
|
84
120
|
filterMode: "store",
|
|
85
|
-
filterStrategy:
|
|
86
|
-
colors: (t, e) => [
|
|
121
|
+
filterStrategy: f,
|
|
122
|
+
colors: (t, e) => [l(t, e)],
|
|
87
123
|
header: (t) => {
|
|
88
124
|
const { title: e, subHeader: o } = t;
|
|
89
125
|
return {
|
|
90
126
|
heading: e,
|
|
91
127
|
subHeadingText: o?.text || void 0,
|
|
92
|
-
icon: /* @__PURE__ */
|
|
128
|
+
icon: /* @__PURE__ */ c(B, {
|
|
93
129
|
alt: o?.text,
|
|
94
130
|
categoryGuid: o?.logo?.category_guid || "",
|
|
95
131
|
merchantGuid: o?.logo?.merchant_guid || "",
|
|
@@ -98,20 +134,20 @@ var i = {
|
|
|
98
134
|
};
|
|
99
135
|
},
|
|
100
136
|
tipSection: (t, e, o = "") => ({
|
|
101
|
-
message:
|
|
137
|
+
message: A(e.general.tip_section_message, /* @__PURE__ */ c("strong", { children: e.general.tip_section_title }), /* @__PURE__ */ c("strong", { children: o })),
|
|
102
138
|
onDismiss: () => t(!0)
|
|
103
139
|
})
|
|
104
140
|
},
|
|
105
141
|
[i.CATEGORY_SPEND]: {
|
|
106
142
|
top: "singleBar",
|
|
107
|
-
filterStrategy:
|
|
143
|
+
filterStrategy: F,
|
|
108
144
|
scope: "store",
|
|
109
145
|
filterMode: "store",
|
|
110
|
-
colors: (t, e) => [
|
|
146
|
+
colors: (t, e) => [l(t, e)],
|
|
111
147
|
header: (t) => ({
|
|
112
148
|
heading: t.categoryName,
|
|
113
|
-
subHeadingText: t.selectedDate &&
|
|
114
|
-
icon: /* @__PURE__ */
|
|
149
|
+
subHeadingText: t.selectedDate && L(p(t.selectedDate), C.MONTH_LONG) || "",
|
|
150
|
+
icon: /* @__PURE__ */ c(R, {
|
|
115
151
|
name: "calendar_month",
|
|
116
152
|
size: 16
|
|
117
153
|
})
|
|
@@ -119,59 +155,72 @@ var i = {
|
|
|
119
155
|
},
|
|
120
156
|
[i.MONTHLY_SPEND]: {
|
|
121
157
|
top: "singleBar",
|
|
122
|
-
filterStrategy:
|
|
158
|
+
filterStrategy: H,
|
|
123
159
|
scope: "store",
|
|
124
160
|
filterMode: "store",
|
|
125
161
|
colors: (t) => [t.palette.chart.chart2 ?? t.palette.primary.main]
|
|
126
162
|
},
|
|
127
163
|
[i.ACCOUNT_BALANCE]: {
|
|
128
164
|
top: "singleBar",
|
|
129
|
-
filterStrategy:
|
|
165
|
+
filterStrategy: V,
|
|
130
166
|
scope: "store",
|
|
131
167
|
filterMode: "store",
|
|
132
168
|
colors: (t) => [t.palette.success.main]
|
|
133
169
|
},
|
|
134
170
|
[i.UPCOMING_BILL]: {
|
|
135
171
|
top: "upcomingBill",
|
|
136
|
-
filterStrategy:
|
|
172
|
+
filterStrategy: f,
|
|
137
173
|
scope: "beat",
|
|
138
174
|
filterMode: "local",
|
|
139
|
-
colors: (t, e) => [
|
|
175
|
+
colors: (t, e) => [l(t, e)],
|
|
176
|
+
slotData: w,
|
|
177
|
+
beatTransactions: P,
|
|
178
|
+
fetchMissingTransactions: (t) => t.insights_payload?.drilldown_data?.transaction_guids,
|
|
179
|
+
tipSection: Y
|
|
140
180
|
},
|
|
141
181
|
[i.LOW_BALANCE]: {
|
|
142
182
|
top: "list",
|
|
143
|
-
filterStrategy:
|
|
183
|
+
filterStrategy: U,
|
|
144
184
|
scope: "store",
|
|
145
185
|
filterMode: "store",
|
|
146
186
|
colors: (t) => [t.palette.primary.main]
|
|
147
187
|
},
|
|
148
188
|
[i.SPEND_TO_INCOME]: {
|
|
149
189
|
top: "doubleBar",
|
|
150
|
-
filterStrategy:
|
|
190
|
+
filterStrategy: v,
|
|
151
191
|
scope: "store",
|
|
152
192
|
filterMode: "store",
|
|
153
|
-
colors: (t) =>
|
|
193
|
+
colors: (t) => I(t, "spend_to_income")?.color ?? [],
|
|
154
194
|
subTabAriaLabels: (t) => [t.general.spend_transactions, t.general.income_transactions]
|
|
155
195
|
},
|
|
156
196
|
[i.COST_OF_LIVING]: {
|
|
157
197
|
top: "doubleBar",
|
|
158
|
-
filterStrategy:
|
|
198
|
+
filterStrategy: v,
|
|
159
199
|
scope: "store",
|
|
160
200
|
filterMode: "store",
|
|
161
|
-
colors: (t, e) => [
|
|
201
|
+
colors: (t, e) => [l(t, e), t.palette.chart.chart4 ?? t.palette.primary.main],
|
|
162
202
|
subTabAriaLabels: (t) => [void 0, t.general.income_transactions]
|
|
203
|
+
},
|
|
204
|
+
[i.NON_ESSENTIAL_CATEGORY]: {
|
|
205
|
+
top: "tabsOnly",
|
|
206
|
+
filterStrategy: z,
|
|
207
|
+
scope: "store",
|
|
208
|
+
filterMode: "store",
|
|
209
|
+
colors: (t) => [t.palette.primary.main]
|
|
163
210
|
}
|
|
164
|
-
},
|
|
211
|
+
}, et = {
|
|
165
212
|
top: "singleBar",
|
|
166
|
-
filterStrategy:
|
|
213
|
+
filterStrategy: f,
|
|
167
214
|
scope: "store",
|
|
168
215
|
filterMode: "store",
|
|
169
|
-
colors: (t, e) => [
|
|
216
|
+
colors: (t, e) => [l(t, e)]
|
|
170
217
|
};
|
|
171
218
|
export {
|
|
172
219
|
i as DRILLDOWN_VARIANTS,
|
|
173
|
-
|
|
174
|
-
|
|
220
|
+
et as FALLBACK,
|
|
221
|
+
tt as layout,
|
|
222
|
+
w as resolveUpcomingBillSlotData,
|
|
223
|
+
P as resolveUpcomingBillTransactions
|
|
175
224
|
};
|
|
176
225
|
|
|
177
226
|
//# sourceMappingURL=layout.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/layout.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { Theme } from '@mui/material/styles'\nimport { endOfMonth, fromUnixTime, isValid, parseISO, startOfMonth } from 'date-fns'\nimport { getCategoryColor } from '../../../core/utils/CategoryUtil'\nimport {\n type Beat,\n type InsightsFeedCopy,\n type Subtitle,\n type Transaction,\n buildDynamicCopy,\n} from '../../../core'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport type {\n DataSet,\n InsightsInstanceSlotData,\n} from '../../../core/types/InsightsInstanceSlotData'\nimport { MerchantLogo } from '@mxenabled/mxui'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport { fromUnixUTC } from '../../../core/utils/DateUtil'\nimport { Icon } from '@mxenabled/mx-icons'\nimport type { ChartDataSeriesItem } from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport { getLayoutConfig as getDoubleBarLayoutConfig } from '../../blocks/ChartBlocks/DoubleBarChartBlock/layout'\nimport type { TipSectionProps } from '../../../insights/components/shared/ChartDrawerTemplate/TipSection'\n\nexport interface DrillDownHeader {\n heading?: string\n subHeadingText?: string\n icon?: ReactNode\n}\n\nexport interface DrillDownHeaderContext {\n title?: string\n subHeader?: Subtitle\n categoryName: string\n selectedDate?: string | Date\n}\n\nexport const DRILLDOWN_VARIANTS = {\n TRANSACTION: 'not_standard_amount',\n CATEGORY_SPEND: 'category_spend',\n MONTHLY_SPEND: 'monthly_spend_comparison',\n ACCOUNT_BALANCE: 'account_balance',\n UPCOMING_BILL: 'upcoming_bill',\n SPEND_TO_INCOME: 'monthly_spend_to_income',\n SAVINGS_TO_INCOME: 'monthly_savings_to_income',\n DEBT_TO_INCOME: 'monthly_debt_to_income',\n COST_OF_LIVING: 'cost_living_to_income',\n NON_ESSENTIAL_CATEGORY: 'non_essential_category_summary',\n DEPOSIT_SUMMARY: 'monthly_deposit_summary',\n LOW_BALANCE: 'low_balance',\n} as const\n\nexport type DrillDownVariant = (typeof DRILLDOWN_VARIANTS)[keyof typeof DRILLDOWN_VARIANTS]\n\n/**\n * One row of the flattened data_series a filterStrategy indexes into: a single-bar monthly total or a\n * synthesized upcoming-bill bar. Fields are optional because the backend keys each row dynamically\n * from data_series.names and not every variant carries a guid/category. Double-bar comparison rows\n * will extend this in the next MR.\n */\n\n// Resolves the top-chart palette from the theme (and the beat's category, when relevant).\nexport type ColorKind = (theme: Theme, categoryGuid?: string) => string[]\n\n// Resolves the dynamic drawer header (heading/sub-heading/icon JSX) from the selection context.\nexport type HeaderKind = (ctx: DrillDownHeaderContext) => DrillDownHeader\n\n/**\n * Everything a filterStrategy needs to turn the currently-selected bar/sub-tab into a\n * TransactionFilter. Data-only so strategies stay pure and testable.\n */\nexport interface FilterContext {\n beat: Beat\n beatTransactions: Transaction[]\n dataSeries: ChartDataSeriesItem[]\n // The double-bar drawer's month columns (main / comparison per month, with their guids); empty\n // for every other top kind.\n comparisonBars: DataSet[]\n selectedIndex: number\n subIndex: number\n isLastTab: boolean\n instanceSlotData: InsightsInstanceSlotData\n spendCategoryGuids: string[]\n displayedDateRange: { start: Date; end: Date }\n}\n\n// Resolves the current selection into a TransactionFilter. Carried on each config row so behavior\n// lives next to the variant it belongs to (no separate strategy registry to chase).\nexport type FilterStrategy = (ctx: FilterContext) => TransactionFilter\n\nexport interface DrillDownVariantConfig {\n // `list`: no chart or tabs above the transaction list (an account's transactions for a window).\n top: 'singleBar' | 'upcomingBill' | 'doubleBar' | 'tabsOnly' | 'list'\n filterStrategy: FilterStrategy\n colors: ColorKind\n header?: HeaderKind\n tipSection?: (\n setCloseTipSection: (flag: boolean) => void,\n copy: InsightsFeedCopy,\n merchantName?: string,\n ) => TipSectionProps\n scope: 'store' | 'beat'\n filterMode: 'store' | 'local'\n // Double bar: accessible names for the series tabs ([0] main, [1] comparison), as legacy pulse.\n subTabAriaLabels?: (copy: InsightsFeedCopy) => (string | undefined)[]\n}\nconst categoryColor = (theme: Theme, categoryGuid?: string): string =>\n (categoryGuid && getCategoryColor(categoryGuid, theme)) || theme.palette.primary.main\n\nconst toLocalDate = (date: string | number | Date | undefined) =>\n typeof date === 'string' ? parseISO(date) : new Date(date ?? NaN)\n\nconst monthRange = (date: string | number | Date | undefined) => ({\n start: startOfMonth(toLocalDate(date)),\n end: endOfMonth(toLocalDate(date)),\n})\n\n// Scopes a filter to the beat's accounts when the beat carries account_guids; otherwise leaves\n// accounts unset so the store default (all accounts) applies.\nconst accountScope = (accountGuids?: string[]): Pick<TransactionFilter, 'accounts'> =>\n accountGuids?.length ? { accounts: accountGuids } : {}\n\n// Low Account Balance — `drilldown_data` names one account and a window (epoch seconds at UTC\n// midnight, to_date exclusive). Fails closed: a drawer that cannot name its rows shows none.\nconst accountWindowStrategy: FilterStrategy = ({ beat }) => {\n const { account_guid, from_date, to_date } = beat.insights_payload?.drilldown_data ?? {}\n if (\n typeof account_guid !== 'string' ||\n typeof from_date !== 'number' ||\n typeof to_date !== 'number' ||\n !Number.isFinite(from_date) ||\n !Number.isFinite(to_date) ||\n to_date <= from_date\n ) {\n return { accounts: [], custom: () => false }\n }\n\n return {\n accounts: [account_guid],\n dateRange: { start: fromUnixUTC(from_date), end: fromUnixUTC(to_date - 1) },\n }\n}\n\n// ── Single-bar filter strategies (this MR) ────────────────────────────────────────────────────\n\n// BillAmountNotStandard / UpcomingBill — the series carries a transaction (TRN) guid; match a single\n// transaction by guid within its month.\nconst transactionGuidStrategy: FilterStrategy = ({\n beatTransactions,\n dataSeries,\n selectedIndex,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n const seriesGuid = seriesItem?.guid\n const hasBeenSplit = beatTransactions.find((trn) => trn.guid === seriesGuid)?.has_been_split\n\n return {\n custom: (trn) => trn.guid === seriesGuid,\n dateRange: monthRange(seriesItem?.date),\n showSplits: !hasBeenSplit,\n }\n}\n\n// CategorySpendingV2 — match transactions in the beat's category (or whose top-level category is that\n// guid) within the month.\nconst categoryStrategy: FilterStrategy = ({ dataSeries, selectedIndex, instanceSlotData }) => {\n const seriesItem = dataSeries[selectedIndex]\n const categoryGuid = instanceSlotData.category_guid ?? seriesItem?.guid\n\n return {\n custom: (trn) =>\n trn.category_guid === categoryGuid || trn.top_level_category_guid === categoryGuid,\n dateRange: monthRange(seriesItem?.date),\n }\n}\n\n// MonthlySpendComparisonV2 — no per-bar guid; show all spending-category transactions\n// (income/transfers/investments excluded via spendCategoryGuids) within the month.\nconst spendCategoriesStrategy: FilterStrategy = ({\n dataSeries,\n selectedIndex,\n spendCategoryGuids,\n instanceSlotData,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n\n return {\n custom: (trn) =>\n !!trn.top_level_category_guid && spendCategoryGuids.includes(trn.top_level_category_guid),\n dateRange: monthRange(seriesItem?.date),\n ...accountScope(instanceSlotData.account_guids),\n }\n}\n\n// The beat's creation: tupac sends epoch seconds on the envelope and an ISO string on the wrapper.\nconst toCreatedAt = (createdAt: Beat['created_at']) =>\n typeof createdAt === 'number' ? fromUnixTime(createdAt) : parseISO(createdAt ?? '')\n\n// SavingsAccountBalancesSummary — balances, not categorized spend: the beat's account within the\n// month. Bars are snapshots, so the most recent month ends at the beat's creation (the partial month\n// its balance was taken in); an older month, or a beat created after its last month ended, keeps the\n// whole month.\nconst accountDateStrategy: FilterStrategy = ({\n beat,\n dataSeries,\n selectedIndex,\n isLastTab,\n instanceSlotData,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n const { start, end } = monthRange(seriesItem?.date)\n const createdAt = toCreatedAt(beat.created_at)\n\n return {\n dateRange: {\n start,\n end: isLastTab && isValid(createdAt) && createdAt < end ? createdAt : end,\n },\n ...accountScope(\n beat.account_guids?.length ? beat.account_guids : instanceSlotData.account_guids,\n ),\n }\n}\n\n// ── Double-bar strategies ──────────────────────────────────────────────────────────────────────\n\n// Monthly Spend to Income Comparison — the selected month's main (Spend, sub-tab 0) or comparison\n// (Income, sub-tab 1) transactions: membership in that bar's stored guids (data_series\n// aggregated_guids), within the month. Fails closed: a bar that names no guids for the tab shows none.\nconst comparisonGuidsStrategy: FilterStrategy = ({\n beat,\n comparisonBars,\n selectedIndex,\n subIndex,\n}) => {\n const bar = comparisonBars[selectedIndex]\n const guids = new Set(subIndex === 1 ? bar?.comparisonGuids : bar?.mainGuids)\n // parseISO reads the 'yyyy-MM-dd' bar date as a local calendar day, so the month never shifts with\n // the viewer's time zone; a missing bar, guid list or date fails closed.\n const month = parseISO(bar?.date ?? '')\n if (!guids.size || !isValid(month)) return { accounts: [], custom: () => false }\n\n return {\n custom: (trn) => guids.has(trn.guid),\n dateRange: { start: startOfMonth(month), end: endOfMonth(month) },\n // The V2 payload carries no account_guids (neither instance_slot.data nor insights_payload).\n ...accountScope(beat.account_guids),\n }\n}\n\n// TODO(next MR — tabsOnly): aggregatedGuids / depositSummary strategies for the donut-drawer beats.\n\nexport const layout: Partial<Record<DrillDownVariant, DrillDownVariantConfig>> = {\n [DRILLDOWN_VARIANTS.TRANSACTION]: {\n top: 'singleBar',\n scope: 'store',\n filterMode: 'store',\n filterStrategy: transactionGuidStrategy,\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n header: (ctx: DrillDownHeaderContext) => {\n const { title, subHeader } = ctx\n return {\n heading: title,\n subHeadingText: subHeader?.text || undefined,\n icon: (\n <MerchantLogo\n alt={subHeader?.text}\n categoryGuid={subHeader?.logo?.category_guid || ''}\n merchantGuid={subHeader?.logo?.merchant_guid || ''}\n size={16}\n />\n ),\n }\n },\n tipSection: (setCloseTipSection, copy, merchantName = '') => {\n return {\n message: buildDynamicCopy(\n copy.general.tip_section_message,\n <strong>{copy.general.tip_section_title}</strong>,\n <strong>{merchantName}</strong>,\n ),\n onDismiss: () => setCloseTipSection(true),\n } as TipSectionProps\n },\n },\n [DRILLDOWN_VARIANTS.CATEGORY_SPEND]: {\n top: 'singleBar',\n filterStrategy: categoryStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n header: (ctx: DrillDownHeaderContext) => {\n return {\n heading: ctx.categoryName,\n subHeadingText: ctx.selectedDate\n ? formatDate(toLocalDate(ctx.selectedDate), DATE_FORMATS_INTL.MONTH_LONG) || ''\n : '',\n icon: <Icon name=\"calendar_month\" size={16} />,\n }\n },\n },\n [DRILLDOWN_VARIANTS.MONTHLY_SPEND]: {\n top: 'singleBar',\n filterStrategy: spendCategoriesStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.chart.chart2 ?? theme.palette.primary.main],\n },\n [DRILLDOWN_VARIANTS.ACCOUNT_BALANCE]: {\n top: 'singleBar',\n filterStrategy: accountDateStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.success.main],\n },\n [DRILLDOWN_VARIANTS.UPCOMING_BILL]: {\n top: 'upcomingBill',\n filterStrategy: transactionGuidStrategy,\n scope: 'beat',\n filterMode: 'local',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n },\n\n // Low Account Balance's \"Transactions\" link: the account's transactions for the alert's window.\n [DRILLDOWN_VARIANTS.LOW_BALANCE]: {\n top: 'list',\n filterStrategy: accountWindowStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.primary.main],\n },\n\n // ── Double-bar comparison beats (month tabs + main / comparison sub-tabs) ────────────────────\n // Monthly Spend to Income Comparison: Spend vs Income per month, in the card block's palette.\n [DRILLDOWN_VARIANTS.SPEND_TO_INCOME]: {\n top: 'doubleBar',\n filterStrategy: comparisonGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => getDoubleBarLayoutConfig(theme, 'spend_to_income')?.color ?? [],\n subTabAriaLabels: (copy) => [copy.general.spend_transactions, copy.general.income_transactions],\n },\n // Cost of Living to Income: one living-cost category (Housing, Groceries, ...) vs Income per month.\n // The cost bar takes the beat category's colour and Income the legacy chart4, as the pulse drawer.\n [DRILLDOWN_VARIANTS.COST_OF_LIVING]: {\n top: 'doubleBar',\n filterStrategy: comparisonGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme, categoryGuid?: string) => [\n categoryColor(theme, categoryGuid),\n theme.palette.chart.chart4 ?? theme.palette.primary.main,\n ],\n subTabAriaLabels: (copy) => [undefined, copy.general.income_transactions],\n },\n // NEXT MR — the other double-bar beats reuse comparisonGuidsStrategy with their own palettes:\n // [DRILLDOWN_VARIANTS.SAVINGS_TO_INCOME]: comparison('savingsVsIncome'),\n // [DRILLDOWN_VARIANTS.DEBT_TO_INCOME]: comparison('debtVsIncome'),\n //\n // ── NEXT MR: tabsOnly donut-drawer beats (no top chart) ───────────────────────────────────\n // [DRILLDOWN_VARIANTS.NON_ESSENTIAL_CATEGORY]: { top: 'tabsOnly', ... },\n // [DRILLDOWN_VARIANTS.DEPOSIT_SUMMARY]: { top: 'tabsOnly', ... },\n}\n\n// Fallback for a missing/typo'd backend variant: a single-bar, store-scoped drawer filtered by the\n// beat's transaction guid and colored by category, so the drawer still renders instead of crashing.\nexport const FALLBACK: DrillDownVariantConfig = {\n top: 'singleBar',\n filterStrategy: transactionGuidStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n}\n"],"mappings":";;;;;;;;;AAqCA,IAAa,IAAqB;AAAA,EAChC,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,wBAAwB;AAAA,EACxB,iBAAiB;AAAA,EACjB,aAAa;AACf,GAwDM,IAAA,CAAiB,GAAc,MAClC,KAAgB,EAAiB,GAAc,CAAK,KAAM,EAAM,QAAQ,QAAQ,MAE7E,IAAA,CAAe,MACnB,OAAO,KAAS,WAAW,EAAS,CAAI,IAAI,IAAI,KAAK,KAAQ,GAAG,GAE5D,IAAA,CAAc,OAA8C;AAAA,EAChE,OAAO,EAAa,EAAY,CAAI,CAAC;AAAA,EACrC,KAAK,EAAW,EAAY,CAAI,CAAC;AACnC,IAIM,IAAA,CAAgB,MACpB,GAAc,SAAS,EAAE,UAAU,EAAa,IAAI,CAAC,GAIjD,IAAA,CAAyC,EAAE,MAAA,EAAA,MAAW;AAC1D,QAAM,EAAE,cAAA,GAAc,WAAA,GAAW,SAAA,EAAA,IAAY,EAAK,kBAAkB,kBAAkB,CAAC;AACvF,SACE,OAAO,KAAiB,YACxB,OAAO,KAAc,YACrB,OAAO,KAAY,YACnB,CAAC,OAAO,SAAS,CAAS,KAC1B,CAAC,OAAO,SAAS,CAAO,KACxB,KAAW,IAEJ;AAAA,IAAE,UAAU,CAAC;AAAA,IAAG,QAAA,MAAc;AAAA,EAAM,IAGtC;AAAA,IACL,UAAU,CAAC,CAAY;AAAA,I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;AAAA,IAChB,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,QAAA,CAAS,GAAc,MAA0B,CAAC,EAAc,GAAO,CAAY,CAAC;AAAA,EACtF;AAAA,EAGC,CAAA,EAAmB,WAAA,GAAc;AAAA,IAChC,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,QAAA,CAAS,MAAiB,CAAC,EAAM,QAAQ,QAAQ,IAAI;AAAA,EACvD;AAAA,EAIC,CAAA,EAAmB,eAAA,GAAkB;AAAA,IACpC,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,QAAA,CAAS,MAAiB,EAAyB,GAAO,iBAAiB,GAAG,SAAS,CAAC;AAAA,IACxF,kBAAA,CAAmB,MAAS,CAAC,EAAK,QAAQ,oBAAoB,EAAK,QAAQ,mBAAmB;AAAA,EAChG;AAAA,EAGC,CAAA,EAAmB,cAAA,GAAiB;AAAA,IACnC,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,QAAA,CAAS,GAAc,MAA0B,CAC/C,EAAc,GAAO,CAAY,GACjC,EAAM,QAAQ,MAAM,UAAU,EAAM,QAAQ,QAAQ,IACtD;AAAA,IACA,kBAAA,CAAmB,MAAS,CAAC,QAAW,EAAK,QAAQ,mBAAmB;AAAA,EAC1E;AAQF,GAIa,IAAmC;AAAA,EAC9C,KAAK;AAAA,EACL,gBAAgB;AAAA,EAChB,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,QAAA,CAAS,GAAc,MAA0B,CAAC,EAAc,GAAO,CAAY,CAAC;AACtF"}
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/layout.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { Theme } from '@mui/material/styles'\nimport { endOfMonth, fromUnixTime, isValid, parseISO, startOfMonth } from 'date-fns'\nimport { getCategoryColor } from '../../../core/utils/CategoryUtil'\nimport {\n type Beat,\n type InsightsFeedCopy,\n type Subtitle,\n type Transaction,\n buildDynamicCopy,\n} from '../../../core'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport type {\n DataSet,\n InsightsInstanceSlotData,\n} from '../../../core/types/InsightsInstanceSlotData'\nimport { MerchantLogo } from '@mxenabled/mxui'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport { fromUnixUTC } from '../../../core/utils/DateUtil'\nimport { Icon } from '@mxenabled/mx-icons'\nimport type { ChartDataSeriesItem } from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport { getLayoutConfig as getDoubleBarLayoutConfig } from '../../blocks/ChartBlocks/DoubleBarChartBlock/layout'\nimport type { TipSectionProps } from '../../../insights/components/shared/ChartDrawerTemplate/TipSection'\nimport {\n type BeatTransactionsResolver,\n buildProjectedBillTransaction,\n calendarDateOf,\n type DrillDownSlotData,\n finiteNumberOf,\n guidListOf,\n nonEmptyStringOf,\n type SlotDataResolver,\n} from './utils'\n\nexport interface DrillDownHeader {\n heading?: string\n subHeadingText?: string\n icon?: ReactNode\n}\n\nexport interface DrillDownHeaderContext {\n title?: string\n subHeader?: Subtitle\n categoryName: string\n selectedDate?: string | Date\n}\n\nexport const DRILLDOWN_VARIANTS = {\n TRANSACTION: 'not_standard_amount',\n CATEGORY_SPEND: 'category_spend',\n MONTHLY_SPEND: 'monthly_spend_comparison',\n ACCOUNT_BALANCE: 'account_balance',\n UPCOMING_BILL: 'upcoming_bill',\n SPEND_TO_INCOME: 'monthly_spend_to_income',\n SAVINGS_TO_INCOME: 'monthly_savings_to_income',\n DEBT_TO_INCOME: 'monthly_debt_to_income',\n COST_OF_LIVING: 'cost_living_to_income',\n NON_ESSENTIAL_CATEGORY: 'non_essential_category_summary',\n DEPOSIT_SUMMARY: 'monthly_deposit_summary',\n LOW_BALANCE: 'low_balance',\n} as const\n\nexport type DrillDownVariant = (typeof DRILLDOWN_VARIANTS)[keyof typeof DRILLDOWN_VARIANTS]\n\n/**\n * One row of the flattened data_series a filterStrategy indexes into: a single-bar monthly total or a\n * synthesized upcoming-bill bar. Fields are optional because the backend keys each row dynamically\n * from data_series.names and not every variant carries a guid/category. Double-bar comparison rows\n * will extend this in the next MR.\n */\n\n// Resolves the top-chart palette from the theme (and the beat's category, when relevant).\nexport type ColorKind = (theme: Theme, categoryGuid?: string) => string[]\n\n// Resolves the dynamic drawer header (heading/sub-heading/icon JSX) from the selection context.\nexport type HeaderKind = (ctx: DrillDownHeaderContext) => DrillDownHeader\n\n/**\n * Everything a filterStrategy needs to turn the currently-selected bar/sub-tab into a\n * TransactionFilter. Data-only so strategies stay pure and testable.\n */\nexport interface FilterContext {\n beat: Beat\n beatTransactions: Transaction[]\n dataSeries: ChartDataSeriesItem[]\n // The double-bar drawer's month columns (main / comparison per month, with their guids); empty\n // for every other top kind.\n comparisonBars: DataSet[]\n selectedIndex: number\n subIndex: number\n isLastTab: boolean\n instanceSlotData: InsightsInstanceSlotData\n spendCategoryGuids: string[]\n displayedDateRange: { start: Date; end: Date }\n}\n\n// Resolves the current selection into a TransactionFilter. Carried on each config row so behavior\n// lives next to the variant it belongs to (no separate strategy registry to chase).\nexport type FilterStrategy = (ctx: FilterContext) => TransactionFilter\n\nexport interface DrillDownVariantConfig {\n // `list`: no chart or tabs above the transaction list (an account's transactions for a window).\n top: 'singleBar' | 'upcomingBill' | 'doubleBar' | 'tabsOnly' | 'list'\n filterStrategy: FilterStrategy\n colors: ColorKind\n header?: HeaderKind\n // Where the drawer reads its facts. Absent: the bar chart's `instance_slot.data`.\n slotData?: SlotDataResolver\n // Builds the drawer's transactions from the beat's own. Absent: the beat's own, as they are.\n beatTransactions?: BeatTransactionsResolver\n // On open, returns the guids of the drawer's transactions to fetch by guid when the store lacks\n // them (older than its 90-day window), as pulse's BeatShell loads a legacy beat's: each drawer\n // reads them from wherever its beat keeps them. Absent: nothing is fetched.\n fetchMissingTransactions?: (beat: Beat) => unknown\n // undefined when the facts the tip needs are missing: the drawer shows no tip.\n tipSection?: (\n setCloseTipSection: (flag: boolean) => void,\n copy: InsightsFeedCopy,\n merchantName?: string,\n slotData?: DrillDownSlotData,\n ) => TipSectionProps | undefined\n scope: 'store' | 'beat'\n filterMode: 'store' | 'local'\n // Double bar: accessible names for the series tabs ([0] main, [1] comparison), as legacy pulse.\n subTabAriaLabels?: (copy: InsightsFeedCopy) => (string | undefined)[]\n}\nconst categoryColor = (theme: Theme, categoryGuid?: string): string =>\n (categoryGuid && getCategoryColor(categoryGuid, theme)) || theme.palette.primary.main\n\nconst toLocalDate = (date: string | number | Date | undefined) =>\n typeof date === 'string' ? parseISO(date) : new Date(date ?? NaN)\n\nconst monthRange = (date: string | number | Date | undefined) => ({\n start: startOfMonth(toLocalDate(date)),\n end: endOfMonth(toLocalDate(date)),\n})\n\n// Scopes a filter to the beat's accounts when the beat carries account_guids; otherwise leaves\n// accounts unset so the store default (all accounts) applies.\nconst accountScope = (accountGuids?: string[]): Pick<TransactionFilter, 'accounts'> =>\n accountGuids?.length ? { accounts: accountGuids } : {}\n\n// Low Account Balance — `drilldown_data` names one account and a window (epoch seconds at UTC\n// midnight, to_date exclusive). Fails closed: a drawer that cannot name its rows shows none.\nconst accountWindowStrategy: FilterStrategy = ({ beat }) => {\n const { account_guid, from_date, to_date } = beat.insights_payload?.drilldown_data ?? {}\n if (\n typeof account_guid !== 'string' ||\n typeof from_date !== 'number' ||\n typeof to_date !== 'number' ||\n !Number.isFinite(from_date) ||\n !Number.isFinite(to_date) ||\n to_date <= from_date\n ) {\n return { accounts: [], custom: () => false }\n }\n\n return {\n accounts: [account_guid],\n dateRange: { start: fromUnixUTC(from_date), end: fromUnixUTC(to_date - 1) },\n }\n}\n\n// Upcoming Bill: each `drilldown_data` fact is narrowed (utils.ts) and a missing or mistyped one is\n// dropped. A bad due date, amount or guid list draws no chart and lists no rows.\n\nexport const resolveUpcomingBillSlotData: SlotDataResolver = (payload) => {\n const data = payload?.drilldown_data ?? {}\n\n return {\n transaction_guids: guidListOf(data.transaction_guids),\n date: calendarDateOf(data.due_date),\n amount: finiteNumberOf(data.amount),\n category_guid: nonEmptyStringOf(data.category_guid),\n average_amount: finiteNumberOf(data.average_amount),\n merchant_name: nonEmptyStringOf(data.merchant_name),\n }\n}\n\n// Upcoming Bill: the paid bills plus the projected bill (due date, amount) appended last, so the\n// bars and the projected tab's \"Projected amount\" row read the one list.\nexport const resolveUpcomingBillTransactions: BeatTransactionsResolver = (\n transactions,\n slotData,\n) => {\n const projected = buildProjectedBillTransaction(transactions, slotData)\n\n return projected ? [...transactions, projected] : transactions\n}\n\nconst upcomingBillTipSection: DrillDownVariantConfig['tipSection'] = (\n setCloseTipSection,\n copy,\n _merchantName,\n slotData,\n) => {\n const merchantName = slotData?.merchant_name\n const dueDate = slotData?.date\n if (!merchantName || !dueDate) return undefined\n\n // No hard-coded English: no tip until the copy service carries the message.\n const message = copy.transaction_history_block?.upcoming_bill_tip_message\n if (!message) return undefined\n\n return {\n message: buildDynamicCopy(\n message,\n <strong>{copy.general.tip_section_title}</strong>,\n merchantName,\n formatDate(parseISO(dueDate), DATE_FORMATS_INTL.FULL_MONTH_DAY),\n ) as ReactNode,\n onDismiss: () => setCloseTipSection(true),\n }\n}\n\n// ── Single-bar filter strategies (this MR) ────────────────────────────────────────────────────\n\n// BillAmountNotStandard / UpcomingBill — the series carries a transaction (TRN) guid; match a single\n// transaction by guid within its month.\nconst transactionGuidStrategy: FilterStrategy = ({\n beatTransactions,\n dataSeries,\n selectedIndex,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n const seriesGuid = seriesItem?.guid\n const hasBeenSplit = beatTransactions.find((trn) => trn.guid === seriesGuid)?.has_been_split\n\n return {\n custom: (trn) => trn.guid === seriesGuid,\n dateRange: monthRange(seriesItem?.date),\n showSplits: !hasBeenSplit,\n }\n}\n\n// CategorySpendingV2 — match transactions in the beat's category (or whose top-level category is that\n// guid) within the month.\nconst categoryStrategy: FilterStrategy = ({ dataSeries, selectedIndex, instanceSlotData }) => {\n const seriesItem = dataSeries[selectedIndex]\n const categoryGuid = instanceSlotData.category_guid ?? seriesItem?.guid\n\n return {\n custom: (trn) =>\n trn.category_guid === categoryGuid || trn.top_level_category_guid === categoryGuid,\n dateRange: monthRange(seriesItem?.date),\n }\n}\n\n// MonthlySpendComparisonV2 — no per-bar guid; show all spending-category transactions\n// (income/transfers/investments excluded via spendCategoryGuids) within the month.\nconst spendCategoriesStrategy: FilterStrategy = ({\n dataSeries,\n selectedIndex,\n spendCategoryGuids,\n instanceSlotData,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n\n return {\n custom: (trn) =>\n !!trn.top_level_category_guid && spendCategoryGuids.includes(trn.top_level_category_guid),\n dateRange: monthRange(seriesItem?.date),\n ...accountScope(instanceSlotData.account_guids),\n }\n}\n\n// The beat's creation: tupac sends epoch seconds on the envelope and an ISO string on the wrapper.\nconst toCreatedAt = (createdAt: Beat['created_at']) =>\n typeof createdAt === 'number' ? fromUnixTime(createdAt) : parseISO(createdAt ?? '')\n\n// SavingsAccountBalancesSummary — balances, not categorized spend: the beat's account within the\n// month. Bars are snapshots, so the most recent month ends at the beat's creation (the partial month\n// its balance was taken in); an older month, or a beat created after its last month ended, keeps the\n// whole month.\nconst accountDateStrategy: FilterStrategy = ({\n beat,\n dataSeries,\n selectedIndex,\n isLastTab,\n instanceSlotData,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n const { start, end } = monthRange(seriesItem?.date)\n const createdAt = toCreatedAt(beat.created_at)\n\n return {\n dateRange: {\n start,\n end: isLastTab && isValid(createdAt) && createdAt < end ? createdAt : end,\n },\n ...accountScope(\n beat.account_guids?.length ? beat.account_guids : instanceSlotData.account_guids,\n ),\n }\n}\n\n// ── Double-bar strategies ──────────────────────────────────────────────────────────────────────\n\n// Monthly Spend to Income Comparison — the selected month's main (Spend, sub-tab 0) or comparison\n// (Income, sub-tab 1) transactions: membership in that bar's stored guids (data_series\n// aggregated_guids), within the month. Fails closed: a bar that names no guids for the tab shows none.\nconst comparisonGuidsStrategy: FilterStrategy = ({\n beat,\n comparisonBars,\n selectedIndex,\n subIndex,\n}) => {\n const bar = comparisonBars[selectedIndex]\n const guids = new Set(subIndex === 1 ? bar?.comparisonGuids : bar?.mainGuids)\n // parseISO reads the 'yyyy-MM-dd' bar date as a local calendar day, so the month never shifts with\n // the viewer's time zone; a missing bar, guid list or date fails closed.\n const month = parseISO(bar?.date ?? '')\n if (!guids.size || !isValid(month)) return { accounts: [], custom: () => false }\n\n return {\n custom: (trn) => guids.has(trn.guid),\n dateRange: { start: startOfMonth(month), end: endOfMonth(month) },\n // The V2 payload carries no account_guids (neither instance_slot.data nor insights_payload).\n ...accountScope(beat.account_guids),\n }\n}\n\n// ── Tabs-only strategies ───────────────────────────────────────────────────────────────────────\n\n// Monthly Non-Essential Category Summary — the series is the two sides of one month (non-essential /\n// essential), not a time series; each row names its own aggregated_guids. The selected sub-tab picks\n// the row, within the row's month. Fails closed, as comparisonGuidsStrategy does: a side that names\n// no guids or no readable date shows none, never the store's displayed range.\nconst aggregatedGuidsStrategy: FilterStrategy = ({ beat, dataSeries, subIndex }) => {\n const row = dataSeries[subIndex]\n const guids = new Set(row?.aggregated_guids)\n const month = parseISO(row?.date ?? '')\n if (!guids.size || !isValid(month)) return { accounts: [], custom: () => false }\n\n return {\n custom: (trn) => guids.has(trn.guid),\n dateRange: { start: startOfMonth(month), end: endOfMonth(month) },\n ...accountScope(beat.account_guids),\n }\n}\n\nexport const layout: Partial<Record<DrillDownVariant, DrillDownVariantConfig>> = {\n [DRILLDOWN_VARIANTS.TRANSACTION]: {\n top: 'singleBar',\n scope: 'store',\n filterMode: 'store',\n filterStrategy: transactionGuidStrategy,\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n header: (ctx: DrillDownHeaderContext) => {\n const { title, subHeader } = ctx\n return {\n heading: title,\n subHeadingText: subHeader?.text || undefined,\n icon: (\n <MerchantLogo\n alt={subHeader?.text}\n categoryGuid={subHeader?.logo?.category_guid || ''}\n merchantGuid={subHeader?.logo?.merchant_guid || ''}\n size={16}\n />\n ),\n }\n },\n tipSection: (setCloseTipSection, copy, merchantName = '') => {\n return {\n message: buildDynamicCopy(\n copy.general.tip_section_message,\n <strong>{copy.general.tip_section_title}</strong>,\n <strong>{merchantName}</strong>,\n ),\n onDismiss: () => setCloseTipSection(true),\n } as TipSectionProps\n },\n },\n [DRILLDOWN_VARIANTS.CATEGORY_SPEND]: {\n top: 'singleBar',\n filterStrategy: categoryStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n header: (ctx: DrillDownHeaderContext) => {\n return {\n heading: ctx.categoryName,\n subHeadingText: ctx.selectedDate\n ? formatDate(toLocalDate(ctx.selectedDate), DATE_FORMATS_INTL.MONTH_LONG) || ''\n : '',\n icon: <Icon name=\"calendar_month\" size={16} />,\n }\n },\n },\n [DRILLDOWN_VARIANTS.MONTHLY_SPEND]: {\n top: 'singleBar',\n filterStrategy: spendCategoriesStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.chart.chart2 ?? theme.palette.primary.main],\n },\n [DRILLDOWN_VARIANTS.ACCOUNT_BALANCE]: {\n top: 'singleBar',\n filterStrategy: accountDateStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.success.main],\n },\n // Upcoming Bill: one bar per paid bill plus the projected bill, all from `drilldown_data`; a bar's\n // tab lists that bill alone (filtered locally, as legacy pulse does).\n [DRILLDOWN_VARIANTS.UPCOMING_BILL]: {\n top: 'upcomingBill',\n filterStrategy: transactionGuidStrategy,\n scope: 'beat',\n filterMode: 'local',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n slotData: resolveUpcomingBillSlotData,\n beatTransactions: resolveUpcomingBillTransactions,\n fetchMissingTransactions: (beat) => beat.insights_payload?.drilldown_data?.transaction_guids,\n tipSection: upcomingBillTipSection,\n },\n\n // Low Account Balance's \"Transactions\" link: the account's transactions for the alert's window.\n [DRILLDOWN_VARIANTS.LOW_BALANCE]: {\n top: 'list',\n filterStrategy: accountWindowStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.primary.main],\n },\n\n // ── Double-bar comparison beats (month tabs + main / comparison sub-tabs) ────────────────────\n // Monthly Spend to Income Comparison: Spend vs Income per month, in the card block's palette.\n [DRILLDOWN_VARIANTS.SPEND_TO_INCOME]: {\n top: 'doubleBar',\n filterStrategy: comparisonGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => getDoubleBarLayoutConfig(theme, 'spend_to_income')?.color ?? [],\n subTabAriaLabels: (copy) => [copy.general.spend_transactions, copy.general.income_transactions],\n },\n // Cost of Living to Income: one living-cost category (Housing, Groceries, ...) vs Income per month.\n // The cost bar takes the beat category's colour and Income the legacy chart4, as the pulse drawer.\n [DRILLDOWN_VARIANTS.COST_OF_LIVING]: {\n top: 'doubleBar',\n filterStrategy: comparisonGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme, categoryGuid?: string) => [\n categoryColor(theme, categoryGuid),\n theme.palette.chart.chart4 ?? theme.palette.primary.main,\n ],\n subTabAriaLabels: (copy) => [undefined, copy.general.income_transactions],\n },\n // NEXT MR — the other double-bar beats reuse comparisonGuidsStrategy with their own palettes:\n // [DRILLDOWN_VARIANTS.SAVINGS_TO_INCOME]: comparison('savingsVsIncome'),\n // [DRILLDOWN_VARIANTS.DEBT_TO_INCOME]: comparison('debtVsIncome'),\n\n // ── Tabs-only beats (no chart; one side tab per series row) ─────────────────────────────────\n // Monthly Non-Essential Category Summary: the donut card's \"View more\" lists one month's spend by\n // side, Non-essential / Essential, each side its own aggregated_guids. The tabs are labelled by\n // the rows' pre-localized labels, in wire order; a row without one gets no tab.\n [DRILLDOWN_VARIANTS.NON_ESSENTIAL_CATEGORY]: {\n top: 'tabsOnly',\n filterStrategy: aggregatedGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.primary.main],\n },\n // NEXT MR — [DRILLDOWN_VARIANTS.DEPOSIT_SUMMARY] (WEC-2097, MR !1756).\n}\n\n// Fallback for a missing/typo'd backend variant: a single-bar, store-scoped drawer filtered by the\n// beat's transaction guid and colored by category, so the drawer still renders instead of crashing.\nexport const FALLBACK: DrillDownVariantConfig = {\n top: 'singleBar',\n filterStrategy: transactionGuidStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n}\n"],"mappings":";;;;;;;;;;AA+CA,IAAa,IAAqB;AAAA,EAChC,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,wBAAwB;AAAA,EACxB,iBAAiB;AAAA,EACjB,aAAa;AACf,GAkEM,IAAA,CAAiB,GAAc,MAClC,KAAgB,EAAiB,GAAc,CAAK,KAAM,EAAM,QAAQ,QAAQ,MAE7E,IAAA,CAAe,MACnB,OAAO,KAAS,WAAW,EAAS,CAAI,IAAI,IAAI,KAAK,KAAQ,GAAG,GAE5D,IAAA,CAAc,OAA8C;AAAA,EAChE,OAAO,EAAa,EAAY,CAAI,CAAC;AAAA,EACrC,KAAK,EAAW,EAAY,CAAI,CAAC;AACnC,IAIM,IAAA,CAAgB,MACpB,GAAc,SAAS,EAAE,UAAU,EAAa,IAAI,CAAC,GAIjD,IAAA,CAAyC,EAAE,MAAA,EAAA,MAAW;AAC1D,QAAM,EAAE,cAAA,GAAc,WAAA,GAAW,SAAA,EAAA,IAAY,EAAK,kBAAkB,kBAAkB,CAAC;AACvF,SACE,OAAO,KAAiB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CAAmB,MAAS,CAAC,QAAW,EAAK,QAAQ,mBAAmB;AAAA,EAC1E;AAAA,EASC,CAAA,EAAmB,sBAAA,GAAyB;AAAA,IAC3C,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,QAAA,CAAS,MAAiB,CAAC,EAAM,QAAQ,QAAQ,IAAI;AAAA,EACvD;AAEF,GAIa,KAAmC;AAAA,EAC9C,KAAK;AAAA,EACL,gBAAgB;AAAA,EAChB,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,QAAA,CAAS,GAAc,MAA0B,CAAC,EAAc,GAAO,CAAY,CAAC;AACtF"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { Beat } from '../../../core';
|
|
2
|
-
|
|
2
|
+
import { DrillDownVariantConfig } from './layout';
|
|
3
|
+
/**
|
|
4
|
+
* The drawer's facts and store reads. `slotData` and `beatTransactions` are the variant's resolvers
|
|
5
|
+
* from the drilldown registry (layout.tsx): a variant that names no `slotData` reads
|
|
6
|
+
* `instance_slot.data`, and one that names no `beatTransactions` gets the beat's own transactions.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useTransactionHistory: (beat: Beat, { slotData: resolveSlotData, beatTransactions: resolveBeatTransactions, }?: Pick<DrillDownVariantConfig, "slotData" | "beatTransactions">) => {
|
|
3
9
|
instanceSlotData: import('./utils').DrillDownSlotData;
|
|
4
10
|
beatTransactions: import('../../../core').Transaction[];
|
|
5
11
|
spendCategoryGuids: string[];
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { useAccountStore as
|
|
2
|
-
import { selectTransactionsByGuids as
|
|
3
|
-
import { toDrillDownSlotData as
|
|
4
|
-
import { useMemo as
|
|
5
|
-
var f = (n) => {
|
|
6
|
-
const
|
|
1
|
+
import { useAccountStore as g, useCategoryStore as m, useGlobalUiStore as l, useTransactionStore as p } from "../../../common/context/hooks.es.js";
|
|
2
|
+
import { selectTransactionsByGuids as y } from "../../CommonUtils.es.js";
|
|
3
|
+
import { toDrillDownSlotData as S } from "./utils.es.js";
|
|
4
|
+
import { useMemo as T } from "react";
|
|
5
|
+
var f = (o) => S(o?.instance_slot?.data ?? {}), b = (o, { slotData: s = f, beatTransactions: n } = {}) => {
|
|
6
|
+
const e = o.insights_payload, t = T(() => s(e), [e, s]), r = p(), u = g(), i = m(), { displayedDateRange: d } = l(), c = y(r.detailedTransactions, t?.transaction_guids);
|
|
7
7
|
return {
|
|
8
8
|
instanceSlotData: t,
|
|
9
|
-
beatTransactions:
|
|
10
|
-
spendCategoryGuids:
|
|
11
|
-
allAccountGuids:
|
|
12
|
-
categoryName:
|
|
13
|
-
displayedDateRange:
|
|
14
|
-
transactionStore:
|
|
9
|
+
beatTransactions: n ? n(c, t) : c,
|
|
10
|
+
spendCategoryGuids: i.spendCategories.map((a) => a.guid),
|
|
11
|
+
allAccountGuids: u.accounts.map((a) => a.guid),
|
|
12
|
+
categoryName: i.getCategoryName(t?.category_guid ?? "") || "",
|
|
13
|
+
displayedDateRange: d,
|
|
14
|
+
transactionStore: r
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
export {
|
|
18
|
-
|
|
18
|
+
b as useTransactionHistory
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
//# sourceMappingURL=useTransactionHistory.es.js.map
|
package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTransactionHistory.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport {\n useAccountStore,\n useCategoryStore,\n useGlobalUiStore,\n useTransactionStore,\n} from '../../../common'\nimport type { Beat } from '../../../core'\nimport type { BarChartBlockData } from '../../../core/types/InsightsInstanceSlotData'\nimport { selectTransactionsByGuids } from '../../CommonUtils'\nimport { toDrillDownSlotData } from './utils'\n\nexport const useTransactionHistory = (beat: Beat) => {\n // Memoised: the drawer's filter effect depends on this object's identity.\n const insightsPayload = beat.insights_payload\n const instanceSlotData = useMemo(\n () =>
|
|
1
|
+
{"version":3,"file":"useTransactionHistory.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport {\n useAccountStore,\n useCategoryStore,\n useGlobalUiStore,\n useTransactionStore,\n} from '../../../common'\nimport type { Beat } from '../../../core'\nimport type { BarChartBlockData } from '../../../core/types/InsightsInstanceSlotData'\nimport { selectTransactionsByGuids } from '../../CommonUtils'\nimport type { DrillDownVariantConfig } from './layout'\nimport { type SlotDataResolver, toDrillDownSlotData } from './utils'\n\n// The default source of the drawer's facts: the bar chart's `instance_slot.data`.\nconst fromInstanceSlot: SlotDataResolver = (payload) =>\n toDrillDownSlotData((payload?.instance_slot?.data ?? {}) as BarChartBlockData)\n\n/**\n * The drawer's facts and store reads. `slotData` and `beatTransactions` are the variant's resolvers\n * from the drilldown registry (layout.tsx): a variant that names no `slotData` reads\n * `instance_slot.data`, and one that names no `beatTransactions` gets the beat's own transactions.\n */\nexport const useTransactionHistory = (\n beat: Beat,\n {\n slotData: resolveSlotData = fromInstanceSlot,\n beatTransactions: resolveBeatTransactions,\n }: Pick<DrillDownVariantConfig, 'slotData' | 'beatTransactions'> = {},\n) => {\n // Memoised: the drawer's filter effect depends on this object's identity.\n const insightsPayload = beat.insights_payload\n const instanceSlotData = useMemo(\n () => resolveSlotData(insightsPayload),\n [insightsPayload, resolveSlotData],\n )\n\n const transactionStore = useTransactionStore()\n const accountStore = useAccountStore()\n const categoryStore = useCategoryStore()\n const { displayedDateRange } = useGlobalUiStore()\n\n const ownTransactions = selectTransactionsByGuids(\n transactionStore.detailedTransactions,\n instanceSlotData?.transaction_guids,\n )\n const beatTransactions = resolveBeatTransactions\n ? resolveBeatTransactions(ownTransactions, instanceSlotData)\n : ownTransactions\n\n const spendCategoryGuids = categoryStore.spendCategories.map((category) => category.guid)\n const allAccountGuids = accountStore.accounts.map((account) => account.guid)\n const categoryName = categoryStore.getCategoryName(instanceSlotData?.category_guid ?? '') || ''\n\n return {\n instanceSlotData,\n beatTransactions,\n spendCategoryGuids,\n allAccountGuids,\n categoryName,\n displayedDateRange,\n transactionStore,\n }\n}\n"],"mappings":";;;;AAeA,IAAM,IAAA,CAAsC,MAC1C,EAAqB,GAAS,eAAe,QAAQ,CAAC,CAAuB,GAOlE,IAAA,CACX,GACA,EACE,UAAU,IAAkB,GAC5B,kBAAkB,EAAA,IAC+C,CAAC,MACjE;AAEH,QAAM,IAAkB,EAAK,kBACvB,IAAmB,EAAA,MACjB,EAAgB,CAAe,GACrC,CAAC,GAAiB,CAAe,CACnC,GAEM,IAAmB,EAAoB,GACvC,IAAe,EAAgB,GAC/B,IAAgB,EAAiB,GACjC,EAAE,oBAAA,EAAA,IAAuB,EAAiB,GAE1C,IAAkB,EACtB,EAAiB,sBACjB,GAAkB,iBACpB;AASA,SAAO;AAAA,IACL,kBAAA;AAAA,IACA,kBAVuB,IACrB,EAAwB,GAAiB,CAAgB,IACzD;AAAA,IASF,oBAPyB,EAAc,gBAAgB,IAAA,CAAK,MAAa,EAAS,IAOlF;AAAA,IACA,iBAPsB,EAAa,SAAS,IAAA,CAAK,MAAY,EAAQ,IAOrE;AAAA,IACA,cAPmB,EAAc,gBAAgB,GAAkB,iBAAiB,EAAE,KAAK;AAAA,IAQ3F,oBAAA;AAAA,IACA,kBAAA;AAAA,EACF;AACF"}
|
package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ import { ActionBlockProps } from '../../mappings/blocks';
|
|
|
5
5
|
* mounted the transactions module has none of them. Loads only the missing pieces, so a host that
|
|
6
6
|
* seeded any of them through `GlobalStore.loadData` keeps what it seeded.
|
|
7
7
|
*/
|
|
8
|
-
export declare const useTransactionHistoryPrepare: (
|
|
8
|
+
export declare const useTransactionHistoryPrepare: ({ beat }: ActionBlockProps) => void;
|
package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { useTransactionStore as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { useInsightsV2Store as d, useTransactionStore as f } from "../../../common/context/hooks.es.js";
|
|
2
|
+
import { getDrillDownConfig as g, guidListOf as m } from "./utils.es.js";
|
|
3
|
+
import { getDynamicCtaBasedOnTriggers as p } from "../util.es.js";
|
|
4
|
+
import l from "react";
|
|
5
|
+
var w = ({ beat: t }) => {
|
|
6
|
+
const { isTransactionDataLoaded: o, loadMissingTransactionData: s, loadTransactionsByGuids: n } = f(), { actionDrawer: r } = d();
|
|
7
|
+
l.useEffect(() => {
|
|
8
|
+
const a = t?.insights_payload, c = p(r, a?.primary_cta, a?.secondary_cta, a?.in_description_cta)?.variant, { fetchMissingTransactions: e } = g(c ?? ""), i = m(e?.(t));
|
|
9
|
+
(async () => (o || await s(), i && await n(i)))();
|
|
7
10
|
}, []);
|
|
8
11
|
};
|
|
9
12
|
export {
|
|
10
|
-
|
|
13
|
+
w as useTransactionHistoryPrepare
|
|
11
14
|
};
|
|
12
15
|
|
|
13
16
|
//# sourceMappingURL=useTransactionHistoryPrepare.es.js.map
|
package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTransactionHistoryPrepare.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.ts"],"sourcesContent":["import React from 'react'\n\nimport { useTransactionStore } from '../../../common'\nimport type { ActionBlockProps } from '../../mappings/blocks'\n\n/**\n * Open-time load for the Transaction History drawer. The list reads `detailedTransactions`, which\n * stays empty until beats, tags, taggings, rules and transactions are all loaded; a feed that never\n * mounted the transactions module has none of them. Loads only the missing pieces, so a host that\n * seeded any of them through `GlobalStore.loadData` keeps what it seeded.\n */\nexport const useTransactionHistoryPrepare = (
|
|
1
|
+
{"version":3,"file":"useTransactionHistoryPrepare.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.ts"],"sourcesContent":["import React from 'react'\n\nimport { useInsightsV2Store, useTransactionStore } from '../../../common'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\nimport { getDrillDownConfig, guidListOf } from './utils'\n\n/**\n * Open-time load for the Transaction History drawer. The list reads `detailedTransactions`, which\n * stays empty until beats, tags, taggings, rules and transactions are all loaded; a feed that never\n * mounted the transactions module has none of them. Loads only the missing pieces, so a host that\n * seeded any of them through `GlobalStore.loadData` keeps what it seeded.\n */\nexport const useTransactionHistoryPrepare = ({ beat }: ActionBlockProps) => {\n const { isTransactionDataLoaded, loadMissingTransactionData, loadTransactionsByGuids } =\n useTransactionStore()\n const { actionDrawer } = useInsightsV2Store()\n\n React.useEffect(() => {\n // A drawer whose registry entry names `fetchMissingTransactions` (Upcoming Bill) also fetches by\n // guid the transactions it returns that the store lacks, so each older paid bill gets its bar.\n const payload = beat?.insights_payload\n const variant = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n payload?.primary_cta,\n payload?.secondary_cta,\n payload?.in_description_cta,\n )?.variant\n const { fetchMissingTransactions } = getDrillDownConfig(variant ?? '')\n // The same narrowing the drawer applies, so the fetch and the chart agree on a valid guid list.\n const guids = guidListOf(fetchMissingTransactions?.(beat))\n\n // The window load replaces the store's transactions, so it finishes before the by-guid fetch\n // adds the older ones; run together, it could wipe them out.\n const load = async () => {\n if (!isTransactionDataLoaded) await loadMissingTransactionData()\n if (guids) await loadTransactionsByGuids(guids)\n }\n void load()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n}\n"],"mappings":";;;;AAaA,IAAa,IAAA,CAAgC,EAAE,MAAA,EAAA,MAA6B;AAC1E,QAAM,EAAE,yBAAA,GAAyB,4BAAA,GAA4B,yBAAA,EAAA,IAC3D,EAAoB,GAChB,EAAE,cAAA,EAAA,IAAiB,EAAmB;AAE5C,EAAA,EAAM,UAAA,MAAgB;AAGpB,UAAM,IAAU,GAAM,kBAChB,IAAU,EACd,GACA,GAAS,aACT,GAAS,eACT,GAAS,kBACX,GAAG,SACG,EAAE,0BAAA,EAAA,IAA6B,EAAmB,KAAW,EAAE,GAE/D,IAAQ,EAAW,IAA2B,CAAI,CAAC;AAQzD,KAJa,aACN,KAAyB,MAAM,EAA2B,GAC3D,KAAO,MAAM,EAAwB,CAAK;AAAA,EAIlD,GAAG,CAAC,CAAC;AACP"}
|
|
@@ -16,39 +16,52 @@ export interface FlattenedDataSeries {
|
|
|
16
16
|
comparisonBars: DataSet[];
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Shapes the beat's raw data_series into the chart inputs for the variant's top kind
|
|
20
|
-
*
|
|
21
|
-
* for the next MR so the call site is already wired.
|
|
19
|
+
* Shapes the beat's raw data_series into the chart inputs for the variant's top kind: the single-bar
|
|
20
|
+
* family (singleBar / upcomingBill), the double bar's month columns, or a tabs-only drawer's sides.
|
|
22
21
|
*/
|
|
23
22
|
interface FlattenedDataSeriesInput {
|
|
24
23
|
data: DataSeries | undefined;
|
|
25
24
|
ariaLabel: string;
|
|
26
25
|
top: DrillDownVariantConfig['top'];
|
|
27
26
|
beatTransactions: Transaction[];
|
|
28
|
-
payload: {
|
|
29
|
-
date?: string;
|
|
30
|
-
amount?: number;
|
|
31
|
-
} | undefined;
|
|
32
27
|
}
|
|
33
|
-
export declare const getFlattenedDataSeries: ({ data, ariaLabel, top, beatTransactions,
|
|
28
|
+
export declare const getFlattenedDataSeries: ({ data, ariaLabel, top, beatTransactions, }: FlattenedDataSeriesInput) => FlattenedDataSeries;
|
|
34
29
|
export declare const PROJECTED_BILL_GUID = "TRN-projected-bill";
|
|
35
30
|
export interface UpcomingBillBar {
|
|
36
31
|
date: string;
|
|
37
32
|
amount: number;
|
|
38
33
|
guid: string;
|
|
39
34
|
category_guid?: string;
|
|
35
|
+
label?: string;
|
|
40
36
|
}
|
|
41
37
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* finds it in the store; the projected bar (cloned category from the latest bill) carries the
|
|
46
|
-
* PROJECTED_BILL_GUID sentinel. The result is sorted date-ascending so the projected bill lands last.
|
|
38
|
+
* Splits a drawer's transactions into the real ones and the synthesized projected bill, which a
|
|
39
|
+
* `beatTransactions` resolver (Upcoming Bill's) appends last under PROJECTED_BILL_GUID. Every other
|
|
40
|
+
* variant has no projected bill, so its transactions pass through untouched.
|
|
47
41
|
*/
|
|
48
|
-
export declare const
|
|
42
|
+
export declare const splitProjectedTransaction: (transactions: Transaction[]) => {
|
|
43
|
+
transactions: Transaction[];
|
|
44
|
+
projectedTransaction?: Transaction;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* UpcomingBill has no data_series: build the bar series from the drawer's transactions, its paid
|
|
48
|
+
* bills plus the projected bill last (mirrors pulse's magicTransactions). Paid bills are sorted and
|
|
49
|
+
* de-duped by date, each keeping its real guid so the guid filter finds it; the projected bar keeps
|
|
50
|
+
* the PROJECTED_BILL_GUID sentinel and lands last. No projected bill (a missing due date or amount),
|
|
51
|
+
* no bars. Bars are named by month; when two share a month, every bar is named by its day so no two
|
|
52
|
+
* tabs read the same.
|
|
53
|
+
*/
|
|
54
|
+
export declare const buildUpcomingBillSeries: (transactions?: Transaction[]) => UpcomingBillBar[];
|
|
55
|
+
/**
|
|
56
|
+
* The transaction behind UpcomingBill's projected bar, as legacy pulse's drawer lists it under
|
|
57
|
+
* "Projected amount": the latest paid bill's merchant and category with the due date and projected
|
|
58
|
+
* amount, on the PROJECTED_BILL_GUID sentinel. Its split / hidden / flagged state is cleared so the
|
|
59
|
+
* inert row never shows the paid bill's badges. Undefined without paid bills, a due date or amount.
|
|
60
|
+
*/
|
|
61
|
+
export declare const buildProjectedBillTransaction: (transactions: Transaction[] | undefined, payload: {
|
|
49
62
|
date?: string;
|
|
50
63
|
amount?: number;
|
|
51
|
-
} | undefined) =>
|
|
64
|
+
} | undefined) => Transaction | undefined;
|
|
52
65
|
export declare const getDrawerHeaderTitle: (variant: string | null | undefined, copy: GlobalCopy) => string;
|
|
53
66
|
export declare const toStoreFilter: (filter: TransactionFilter, defaults: {
|
|
54
67
|
allAccountGuids: string[];
|
|
@@ -61,9 +74,26 @@ export declare const getDefaultSelection: ({ chartTabCount, comparisonTabCount,
|
|
|
61
74
|
chartBarIndex: number;
|
|
62
75
|
subTabIndex: number;
|
|
63
76
|
};
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
/**
|
|
78
|
+
* The drawer's facts: the generic slot facts plus the bar chart's average, and the merchant a
|
|
79
|
+
* variant's tip names.
|
|
80
|
+
*/
|
|
81
|
+
export type DrillDownSlotData = InsightsInstanceSlotData & Pick<BarChartBlockData, 'average_amount'> & {
|
|
82
|
+
merchant_name?: string;
|
|
83
|
+
};
|
|
84
|
+
export declare const utcDayToUnix: (day: string) => number;
|
|
85
|
+
export declare const finiteNumberOf: (value: unknown) => number | undefined;
|
|
86
|
+
export declare const nonEmptyStringOf: (value: unknown) => string | undefined;
|
|
87
|
+
export declare const guidListOf: (value: unknown) => string[] | undefined;
|
|
88
|
+
export declare const calendarDateOf: (value: unknown) => string | undefined;
|
|
89
|
+
/** Resolves the drawer's facts (bars, guids, colour, average, tip values) from the beat's payload. */
|
|
90
|
+
export type SlotDataResolver = (payload: Partial<InsightsPayload> | undefined) => DrillDownSlotData;
|
|
91
|
+
/**
|
|
92
|
+
* Builds the drawer's transactions from the beat's own (its `transaction_guids` in the store) and
|
|
93
|
+
* its facts, e.g. Upcoming Bill appends its projected bill. Absent: the beat's own, as they are.
|
|
94
|
+
*/
|
|
95
|
+
export type BeatTransactionsResolver = (transactions: Transaction[], slotData: DrillDownSlotData) => Transaction[];
|
|
96
|
+
/** The drawer's facts from a bar chart's `instance_slot.data` (variants with no `slotData`). */
|
|
67
97
|
export declare const toDrillDownSlotData: ({ series, category_guid, average_amount, additional_data, }: BarChartBlockData) => DrillDownSlotData;
|
|
68
98
|
/** The drawer's sub-heading: the merchant name and logo. */
|
|
69
99
|
export declare const resolveDrillDownSubHeader: (payload: Partial<InsightsPayload> | undefined) => Subtitle | undefined;
|