@mx-cartographer/experiences 9.7.42 → 9.7.44
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 +12 -0
- package/dist/accounts/components/detailsdrawer/Accounts/AccountDetailsDrawer.es.js +3 -3
- package/dist/accounts/index.es.js +4 -4
- package/dist/core/types/InsightsInstanceSlotData.d.ts +3 -0
- package/dist/core/types/InsightsInstanceSlotData.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +3 -0
- package/dist/insights-v2/actionBlocks/AccountDetailsBlock/AccountDetailsBlock.d.ts +12 -0
- package/dist/insights-v2/actionBlocks/AccountDetailsBlock/AccountDetailsBlock.es.js +32 -0
- package/dist/insights-v2/actionBlocks/AccountDetailsBlock/AccountDetailsBlock.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/AccountDetailsBlock/index.d.ts +2 -0
- package/dist/insights-v2/actionBlocks/AccountDetailsBlock/layout.d.ts +3 -0
- package/dist/insights-v2/actionBlocks/AccountDetailsBlock/layout.es.js +10 -0
- package/dist/insights-v2/actionBlocks/AccountDetailsBlock/layout.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/AccountDetailsBlock/useAccountDetailsPrepare.d.ts +2 -0
- package/dist/insights-v2/actionBlocks/AccountDetailsBlock/useAccountDetailsPrepare.es.js +20 -0
- package/dist/insights-v2/actionBlocks/AccountDetailsBlock/useAccountDetailsPrepare.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.d.ts +3 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +85 -75
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +115 -93
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +3 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +66 -44
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +49 -44
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/analytics/analyticsEventsConfig.d.ts +4 -0
- package/dist/insights-v2/analytics/analyticsEventsConfig.es.js +4 -0
- package/dist/insights-v2/analytics/analyticsEventsConfig.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.d.ts +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js +19 -19
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.d.ts +8 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js +47 -31
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.d.ts +1 -5
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js +10 -6
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/components/SubTabs.d.ts +22 -0
- package/dist/insights-v2/components/SubTabs.es.js +38 -0
- package/dist/insights-v2/components/SubTabs.es.js.map +1 -0
- package/dist/insights-v2/components/chartblocks/ChartLegend.es.js +14 -18
- package/dist/insights-v2/components/chartblocks/ChartLegend.es.js.map +1 -1
- package/dist/insights-v2/components/chartblocks/DoubleBarChart.d.ts +5 -3
- package/dist/insights-v2/components/chartblocks/DoubleBarChart.es.js +108 -104
- package/dist/insights-v2/components/chartblocks/DoubleBarChart.es.js.map +1 -1
- package/dist/insights-v2/mappings/actionBlocksKey.d.ts +1 -0
- package/dist/insights-v2/mappings/actionBlocksKey.es.js +1 -0
- package/dist/insights-v2/mappings/actionBlocksKey.es.js.map +1 -1
- package/dist/insights-v2/mappings/blocks.es.js +73 -66
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,77 +1,98 @@
|
|
|
1
|
-
import { useGlobalCopyStore as
|
|
2
|
-
import { formatCurrency as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { BAR_ARIA_LABEL as
|
|
6
|
-
import { BarChartV2 as
|
|
7
|
-
import { EmptyBarChart as
|
|
8
|
-
import { ANALYTICS_EVENTS_CONFIG as
|
|
9
|
-
import { useAnalyticsEvent as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { useGlobalCopyStore as lt, useGlobalUiStore as ct, useInsightsV2Store as mt } from "../../../common/context/hooks.es.js";
|
|
2
|
+
import { formatCurrency as dt } from "../../../core/utils/NumberFormatting.es.js";
|
|
3
|
+
import ut from "../../../common/components/drawer/Drawer.es.js";
|
|
4
|
+
import gt from "../../../common/components/Loader.es.js";
|
|
5
|
+
import { BAR_ARIA_LABEL as pt } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
|
|
6
|
+
import { BarChartV2 as bt } from "../../components/chartblocks/BarchartV2.es.js";
|
|
7
|
+
import { EmptyBarChart as ft } from "../../components/chartblocks/EmptyBarChart.es.js";
|
|
8
|
+
import { ANALYTICS_EVENTS_CONFIG as k } from "../../analytics/analyticsEventsConfig.es.js";
|
|
9
|
+
import { useAnalyticsEvent as ht } from "../../analytics/useAnalyticsEvent.es.js";
|
|
10
|
+
import { DoubleBarChart as _t } from "../../components/chartblocks/DoubleBarChart.es.js";
|
|
11
|
+
import { toLegendItems as Ct } from "../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js";
|
|
12
|
+
import { TransactionDrillDown as yt } from "./TransactionDrillDown.es.js";
|
|
13
|
+
import { getDefaultSelection as Tt, getDrillDownConfig as At, getFlattenedDataSeries as St, resolveDrillDownSubHeader as Bt, toStoreFilter as Dt } from "./utils.es.js";
|
|
14
|
+
import { useTransactionHistory as Lt } from "./useTransactionHistory.es.js";
|
|
15
|
+
import { getDynamicCtaBasedOnTriggers as vt } from "../util.es.js";
|
|
16
|
+
import { TransactionDetailsBlock as It } from "../TransactionDetailsBlock/TransactionDetailsBlock.es.js";
|
|
17
|
+
import { useLayoutEffect as xt, useState as p } from "react";
|
|
18
|
+
import { observer as Et } from "mobx-react-lite";
|
|
19
|
+
import { Fragment as Rt, jsx as n, jsxs as Ft } from "react/jsx-runtime";
|
|
20
|
+
import { useTheme as Gt } from "@mui/material/styles";
|
|
21
|
+
var oe = Et(({ beat: r }) => {
|
|
22
|
+
const y = Gt(), { instanceSlotData: e, beatTransactions: m, spendCategoryGuids: T, allAccountGuids: A, categoryName: N, displayedDateRange: b, transactionStore: K } = Lt(r), { actionDrawer: S, setActionContext: B } = mt(), { common: V, insights_feed: i } = lt(), { isCopyLoaded: M } = ct(), [P, D] = p(!1), [U, W] = p(!1), L = ht(), { insights_payload: l } = r, Y = vt(S, l?.primary_cta, l?.secondary_cta, l?.in_description_cta)?.variant, { top: a, filterMode: d, header: $, colors: q, filterStrategy: z, tipSection: v, subTabAriaLabels: J } = At(Y ?? ""), { dataSeries: f, chartData: u, comparisonBars: s } = St({
|
|
21
23
|
data: e?.data_series,
|
|
22
|
-
ariaLabel:
|
|
23
|
-
top:
|
|
24
|
-
beatTransactions:
|
|
24
|
+
ariaLabel: a === "doubleBar" ? i?.general?.in_month_you_had_a_category_of_amount ?? "_1{month}, _2{category}: _3{amount}" : pt,
|
|
25
|
+
top: a,
|
|
26
|
+
beatTransactions: m,
|
|
25
27
|
payload: e
|
|
26
|
-
}), { chartBarIndex:
|
|
27
|
-
chartTabCount:
|
|
28
|
-
comparisonTabCount:
|
|
29
|
-
actionDrawer:
|
|
30
|
-
beatGuid:
|
|
31
|
-
}), [
|
|
32
|
-
beat:
|
|
33
|
-
beatTransactions:
|
|
34
|
-
dataSeries:
|
|
28
|
+
}), c = a === "doubleBar", h = c ? s : u, { chartBarIndex: Q, subTabIndex: X } = Tt({
|
|
29
|
+
chartTabCount: u.length,
|
|
30
|
+
comparisonTabCount: s.length,
|
|
31
|
+
actionDrawer: S,
|
|
32
|
+
beatGuid: r.guid
|
|
33
|
+
}), [o, I] = p(Q), [_, x] = p(X), E = (t) => z({
|
|
34
|
+
beat: r,
|
|
35
|
+
beatTransactions: m,
|
|
36
|
+
dataSeries: f,
|
|
37
|
+
comparisonBars: s,
|
|
35
38
|
selectedIndex: t,
|
|
36
|
-
subIndex:
|
|
37
|
-
isLastTab: t ===
|
|
39
|
+
subIndex: _,
|
|
40
|
+
isLastTab: t === h.length - 1,
|
|
38
41
|
instanceSlotData: e,
|
|
39
|
-
spendCategoryGuids:
|
|
40
|
-
displayedDateRange:
|
|
41
|
-
}),
|
|
42
|
-
|
|
43
|
-
allAccountGuids:
|
|
44
|
-
displayedDateRange:
|
|
42
|
+
spendCategoryGuids: T,
|
|
43
|
+
displayedDateRange: b
|
|
44
|
+
}), Z = m.map((t) => t.guid).join(","), tt = T.join(","), et = A.join(","), ot = a === "list" || f.length > 0, R = () => {
|
|
45
|
+
d !== "store" || !ot || K.setFilter(Dt(E(o), {
|
|
46
|
+
allAccountGuids: A,
|
|
47
|
+
displayedDateRange: b
|
|
45
48
|
}));
|
|
46
49
|
};
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
xt(() => {
|
|
51
|
+
R();
|
|
49
52
|
}, [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
d
|
|
53
|
+
r.guid,
|
|
54
|
+
o,
|
|
55
|
+
_,
|
|
56
|
+
d,
|
|
57
|
+
f.length,
|
|
54
58
|
e,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
b,
|
|
60
|
+
tt,
|
|
61
|
+
et,
|
|
62
|
+
Z,
|
|
63
|
+
a
|
|
60
64
|
]);
|
|
61
|
-
const
|
|
62
|
-
title:
|
|
63
|
-
subHeader:
|
|
64
|
-
categoryName:
|
|
65
|
-
selectedDate:
|
|
66
|
-
}),
|
|
67
|
-
if (!
|
|
68
|
-
const
|
|
65
|
+
const F = Bt(l), C = $?.({
|
|
66
|
+
title: l?.title,
|
|
67
|
+
subHeader: F,
|
|
68
|
+
categoryName: N,
|
|
69
|
+
selectedDate: u[o]?.date ?? void 0
|
|
70
|
+
}), G = q(y, e?.category_guid);
|
|
71
|
+
if (!M) return /* @__PURE__ */ n(gt, {});
|
|
72
|
+
const [O, H] = e?.legends ?? [], at = d === "local" ? (t) => E(t).custom ?? (() => !0) : void 0, nt = d === "local" ? m : void 0, w = (t, g) => {
|
|
73
|
+
L(k.DRAWER_CHART_BAR_CLICKED), I(t), g !== void 0 && x(g);
|
|
74
|
+
}, rt = (t) => {
|
|
75
|
+
L(k.TAB_SELECTED), I(t);
|
|
76
|
+
}, j = c ? Ct([{
|
|
77
|
+
...O,
|
|
78
|
+
value: s[o]?.main
|
|
79
|
+
}, {
|
|
80
|
+
...H,
|
|
81
|
+
value: s[o]?.comparison
|
|
82
|
+
}]) : void 0, it = J?.(i) ?? [], st = c || a === "singleBar" || a === "upcomingBill" ? h.length ? c ? /* @__PURE__ */ n(_t, {
|
|
83
|
+
bars: s,
|
|
84
|
+
colors: G,
|
|
85
|
+
legendPosition: "top",
|
|
86
|
+
legends: j,
|
|
87
|
+
onBarClick: w,
|
|
88
|
+
selectedIndex: o
|
|
89
|
+
}) : /* @__PURE__ */ n(bt, {
|
|
69
90
|
amounts: {
|
|
70
91
|
average: e?.average_amount,
|
|
71
|
-
formattedAverage:
|
|
92
|
+
formattedAverage: dt(e?.average_amount ?? 0, "0,0.00")
|
|
72
93
|
},
|
|
73
|
-
color:
|
|
74
|
-
data:
|
|
94
|
+
color: G[0] ?? y.palette.primary.main,
|
|
95
|
+
data: u,
|
|
75
96
|
legendPosition: "top",
|
|
76
97
|
heightOverride: 142,
|
|
77
98
|
margin: {
|
|
@@ -80,44 +101,45 @@ var Vt = bt(({ beat: o }) => {
|
|
|
80
101
|
left: 24,
|
|
81
102
|
right: 24
|
|
82
103
|
},
|
|
83
|
-
monthlyAmountLabel:
|
|
84
|
-
onBarClick:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
monthlyAmountLabel: O?.label ?? i.general.monthly_amount,
|
|
105
|
+
onBarClick: w,
|
|
106
|
+
selectedTabIndex: o,
|
|
107
|
+
trendAmountLabel: H?.label ?? i.general.trend
|
|
108
|
+
}) : /* @__PURE__ */ n(ft, {}) : null;
|
|
109
|
+
return /* @__PURE__ */ Ft(Rt, { children: [/* @__PURE__ */ n(yt, {
|
|
110
|
+
baseTransactions: nt,
|
|
111
|
+
heading: C?.heading,
|
|
112
|
+
icon: C?.icon,
|
|
113
|
+
onSelectionChange: rt,
|
|
114
|
+
selectedIndex: o,
|
|
115
|
+
subHeadingText: C?.subHeadingText,
|
|
116
|
+
tabs: h,
|
|
117
|
+
top: st,
|
|
118
|
+
...c && { subTabs: {
|
|
119
|
+
tabs: (j ?? []).map((t, g) => ({
|
|
120
|
+
label: t.label,
|
|
121
|
+
ariaLabel: it[g]
|
|
122
|
+
})),
|
|
123
|
+
selectedIndex: _,
|
|
124
|
+
onChange: x
|
|
125
|
+
} },
|
|
126
|
+
...v && { tipSection: !U && v(W, i, F?.text) },
|
|
127
|
+
transactionFilter: at,
|
|
106
128
|
onEachRowClick: (t) => {
|
|
107
|
-
|
|
129
|
+
B({ transaction_guid: t }), D(!0);
|
|
108
130
|
}
|
|
109
|
-
}), /* @__PURE__ */
|
|
110
|
-
ariaLabelClose:
|
|
111
|
-
isOpen:
|
|
131
|
+
}), /* @__PURE__ */ n(ut, {
|
|
132
|
+
ariaLabelClose: V.close_aria,
|
|
133
|
+
isOpen: P,
|
|
112
134
|
onClose: () => {
|
|
113
|
-
|
|
135
|
+
D(!1), B({ transaction_guid: void 0 }), R();
|
|
114
136
|
},
|
|
115
|
-
title:
|
|
116
|
-
children: /* @__PURE__ */
|
|
137
|
+
title: i.general.transaction_details_title,
|
|
138
|
+
children: /* @__PURE__ */ n(It, { beat: r })
|
|
117
139
|
})] });
|
|
118
140
|
});
|
|
119
141
|
export {
|
|
120
|
-
|
|
142
|
+
oe as TransactionHistoryBlock
|
|
121
143
|
};
|
|
122
144
|
|
|
123
145
|
//# sourceMappingURL=TransactionHistoryBlock.es.js.map
|
package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionHistoryBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.tsx"],"sourcesContent":["import { useLayoutEffect, useState } from 'react'\n\nimport { useTheme } from '@mui/material/styles'\nimport { observer } from 'mobx-react-lite'\n\nimport type { Beat, DataSeries, Transaction } from '../../../core'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { BarChartV2 } from '../../components/chartblocks/BarchartV2'\nimport { EmptyBarChart } from '../../components/chartblocks/EmptyBarChart'\nimport { BAR_ARIA_LABEL } from '../../blocks/ChartBlocks/BarchartBlock/utils'\n\nimport { TransactionDrillDown } from './TransactionDrillDown'\nimport { useTransactionHistory } from './useTransactionHistory'\nimport {\n getDefaultSelection,\n getDrillDownConfig,\n getFlattenedDataSeries,\n resolveDrillDownSubHeader,\n toStoreFilter,\n} from './utils'\nimport {\n Drawer,\n useInsightsV2Store,\n useGlobalCopyStore,\n useGlobalUiStore,\n Loader,\n} from '../../../common'\nimport { TransactionDetailsBlock } from '../TransactionDetailsBlock'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\ninterface TransactionHistoryProp {\n beat: Beat\n}\n\nexport const TransactionHistoryBlock = observer(({ beat }: TransactionHistoryProp) => {\n const theme = useTheme()\n const {\n instanceSlotData,\n beatTransactions,\n spendCategoryGuids,\n allAccountGuids,\n categoryName,\n displayedDateRange,\n transactionStore,\n } = useTransactionHistory(beat)\n\n const { actionDrawer, setActionContext } = useInsightsV2Store()\n\n const { common: commonCopy, insights_feed: insightsCopy } = useGlobalCopyStore()\n\n const { isCopyLoaded } = useGlobalUiStore()\n\n const [isTransactionDetailsOpen, setIsTransactionDetailsOpen] = useState(false)\n\n const [closeTipSection, setCloseTipSection] = useState(false)\n\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const { insights_payload } = beat\n\n const dynamicCtaVariant = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n insights_payload?.primary_cta,\n insights_payload?.secondary_cta,\n insights_payload?.in_description_cta,\n )?.variant\n\n const { top, filterMode, header, colors, filterStrategy, tipSection } = getDrillDownConfig(\n dynamicCtaVariant ?? '',\n )\n\n const { dataSeries, chartData, comparisonBars } = getFlattenedDataSeries({\n data: instanceSlotData?.data_series as DataSeries,\n ariaLabel: BAR_ARIA_LABEL,\n top,\n beatTransactions,\n payload: instanceSlotData,\n })\n\n const { chartBarIndex, subTabIndex } = getDefaultSelection({\n chartTabCount: chartData.length,\n comparisonTabCount: comparisonBars.length,\n actionDrawer,\n beatGuid: beat.guid,\n })\n\n const [selectedIndex, setSelectedIndex] = useState(chartBarIndex)\n\n const resolveFilter = (index: number) =>\n filterStrategy({\n beat,\n beatTransactions,\n dataSeries,\n selectedIndex: index,\n subIndex: subTabIndex,\n isLastTab: index === dataSeries.length - 1,\n instanceSlotData,\n spendCategoryGuids,\n displayedDateRange,\n })\n\n // Apply the current selection's filter. Store variants route through the store filter; local\n // (upcomingBill) variants filter beatTransactions directly and only backfill the cache when the\n // Stable primitive keys for the collections below: beatTransactions/spendCategoryGuids/\n // allAccountGuids are recomputed (new array identity) every render, so depending on them directly\n // re-fires the effect each render (REVIEW.md MEW-3732). Key on content instead.\n const beatTransactionGuidsKey = beatTransactions.map((transaction) => transaction.guid).join(',')\n const spendCategoryGuidsKey = spendCategoryGuids.join(',')\n const allAccountGuidsKey = allAccountGuids.join(',')\n\n // Re-applies the current selection's filter to the shared transactionStore. Called both by the\n // effect below (on selection change) and when the nested TransactionDetailsBlock drawer closes:\n // AddMerchantBudgetAction (opened from within that drawer) overwrites transactionStore.filter\n // with a merchant_guid-only filter while its own drawer is open, and never restores it — leaving\n // the row list stuck showing only that one merchant's transactions after backing all the way out.\n // Re-running this on close re-derives the filter fresh instead of relying on whatever the nested\n // drawers left behind.\n // A `list` drawer has no bars: it filters once from the beat alone.\n const canApplyFilter = top === 'list' || dataSeries.length > 0\n const applyCurrentSelectionFilter = () => {\n if (filterMode !== 'store' || !canApplyFilter) return\n transactionStore.setFilter(\n toStoreFilter(resolveFilter(selectedIndex), { allAccountGuids, displayedDateRange }),\n )\n }\n\n // store variants route the selection through the shared store filter; local (upcomingBill) variants\n // filter beatTransactions directly, so there's nothing to push to the store for them.\n useLayoutEffect(() => {\n applyCurrentSelectionFilter()\n }, [\n beat.guid,\n selectedIndex,\n filterMode,\n dataSeries.length,\n instanceSlotData,\n displayedDateRange,\n spendCategoryGuidsKey,\n allAccountGuidsKey,\n beatTransactionGuidsKey,\n top,\n ])\n\n const subHeader = resolveDrillDownSubHeader(insights_payload)\n\n const headerContent = header?.({\n title: insights_payload?.title,\n subHeader,\n categoryName,\n selectedDate: chartData[selectedIndex]?.date ?? undefined,\n })\n\n const barColors = colors(theme, instanceSlotData?.category_guid)\n\n if (!isCopyLoaded) return <Loader />\n\n // TODO: Temporary fallback while the backend doesn't always send `legends` on every beat/variant.\n // Remove this once the backend guarantees `legends` on the payload.\n const legendFallbackLabels = [insightsCopy.general.monthly_amount, insightsCopy.general.trend]\n\n const [monthlyAmountLabel, trendAmountLabel] = instanceSlotData?.legends?.length\n ? instanceSlotData.legends.map((legend) => legend.label)\n : legendFallbackLabels\n\n const transactionFilter =\n filterMode === 'local'\n ? (index: number) => resolveFilter(index).custom ?? (() => true)\n : undefined\n\n const baseTransactions: Transaction[] | undefined =\n filterMode === 'local' ? beatTransactions : undefined\n\n const isBarTop = top === 'singleBar' || top === 'upcomingBill'\n const chartTop = !isBarTop ? null : chartData.length ? (\n <BarChartV2\n amounts={{\n average: instanceSlotData?.average_amount,\n formattedAverage: formatCurrency(instanceSlotData?.average_amount ?? 0, '0,0.00'),\n }}\n color={barColors[0] ?? theme.palette.primary.main}\n data={chartData}\n legendPosition=\"top\"\n heightOverride={142}\n margin={{\n bottom: 8,\n top: 24,\n left: 24,\n right: 24,\n }}\n monthlyAmountLabel={monthlyAmountLabel}\n onBarClick={(index) => {\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.DRAWER_CHART_BAR_CLICKED)\n setSelectedIndex(index)\n }}\n selectedTabIndex={selectedIndex}\n trendAmountLabel={trendAmountLabel}\n />\n ) : (\n <EmptyBarChart />\n )\n\n return (\n <>\n <TransactionDrillDown\n baseTransactions={baseTransactions}\n heading={headerContent?.heading}\n icon={headerContent?.icon}\n onSelectionChange={(index) => {\n // MUI Tabs only fires onChange on real user selection, not on mount.\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.TAB_SELECTED)\n setSelectedIndex(index)\n }}\n selectedIndex={selectedIndex}\n subHeadingText={headerContent?.subHeadingText}\n tabs={chartData.map((bar) => ({\n ariaLabel: bar.ariaLabel,\n label: bar.label,\n }))}\n top={chartTop}\n {...(tipSection && {\n tipSection:\n !closeTipSection && tipSection(setCloseTipSection, insightsCopy, subHeader?.text),\n })}\n transactionFilter={transactionFilter}\n onEachRowClick={(guid) => {\n setActionContext({ transaction_guid: guid })\n setIsTransactionDetailsOpen(true)\n }}\n />\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isTransactionDetailsOpen}\n onClose={() => {\n setIsTransactionDetailsOpen(false)\n // Clear only the key this nested drawer owns — setActionContext merges, so an\n // explicit `{}` would be a no-op and leave transaction_guid stuck in the shared\n // context, and the outer drawer's own context (e.g. chartBarIndex) must survive.\n setActionContext({ transaction_guid: undefined })\n // Re-apply this block's own filter: a further-nested AddMerchantBudgetAction drawer may\n // have overwritten transactionStore.filter (merchant_guid-only) without restoring it.\n applyCurrentSelectionFilter()\n }}\n title={insightsCopy.general.transaction_details_title}\n >\n <TransactionDetailsBlock beat={beat} />\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmCA,IAAa,KAA0B,GAAA,CAAU,EAAE,MAAA,EAAA,MAAmC;AACpF,QAAM,IAAQ,GAAS,GACjB,EACJ,kBAAA,GACA,kBAAA,GACA,oBAAA,GACA,iBAAA,GACA,cAAA,GACA,oBAAA,GACA,kBAAA,EAAA,IACE,GAAsB,CAAI,GAExB,EAAE,cAAA,GAAc,kBAAA,EAAA,IAAqB,GAAmB,GAExD,EAAE,QAAQ,GAAY,eAAe,EAAA,IAAiB,EAAmB,GAEzE,EAAE,cAAA,EAAA,IAAiB,GAAiB,GAEpC,CAAC,GAA0B,CAAA,IAA+B,EAAS,EAAK,GAExE,CAAC,GAAiB,CAAA,IAAsB,EAAS,EAAK,GAEtD,IAAqB,GAAkB,GAEvC,EAAE,kB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,IAED,gBAAA,EAAC,IAAD,CAAgB,CAAA,IAzBW;AA4B7B,SACE,gBAAA,GAAA,IAAA,EAAA,UAAA,CACE,gBAAA,EAAC,IAAD;AAAA,IACoB,kBAAA;AAAA,IAClB,SAAS,GAAe;AAAA,IACxB,MAAM,GAAe;AAAA,IACrB,mBAAA,CAAoB,MAAU;AAE5B,MAAA,EAAmB,EAAwB,YAAY,GACvD,EAAiB,CAAK;AAAA,IACxB;AAAA,IACe,eAAA;AAAA,IACf,gBAAgB,GAAe;AAAA,IAC/B,MAAM,EAAU,IAAA,CAAK,OAAS;AAAA,MAC5B,WAAW,EAAI;AAAA,MACf,OAAO,EAAI;AAAA,IACb,EAAE;AAAA,IACF,KAAK;AAAA,IACL,GAAK,KAAc,EACjB,YACE,CAAC,KAAmB,EAAW,GAAoB,GAAc,GAAW,IAAI,EACpF;AAAA,IACmB,mBAAA;AAAA,IACnB,gBAAA,CAAiB,MAAS;AACxB,MAAA,EAAiB,EAAE,kBAAkB,EAAK,CAAC,GAC3C,EAA4B,EAAI;AAAA,IAClC;AAAA,EACD,CAAA,GACD,gBAAA,EAAC,IAAD;AAAA,IACE,gBAAgB,EAAW;AAAA,IAC3B,QAAQ;AAAA,IACR,SAAA,MAAe;AACb,MAAA,EAA4B,EAAK,GAIjC,EAAiB,EAAE,kBAAkB,OAAU,CAAC,GAGhD,EAA4B;AAAA,IAC9B;AAAA,IACA,OAAO,EAAa,QAAQ;AAAA,IAE5B,UAAA,gBAAA,EAAC,IAAD,EAA+B,MAAA,EAAO,CAAA;AAAA,EAChC,CAAA,CACR,EAAA,CAAA;AAEN,CAAC"}
|
|
1
|
+
{"version":3,"file":"TransactionHistoryBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.tsx"],"sourcesContent":["import { useLayoutEffect, useState } from 'react'\n\nimport { useTheme } from '@mui/material/styles'\nimport { observer } from 'mobx-react-lite'\n\nimport type { Beat, DataSeries, Transaction } from '../../../core'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { BarChartV2 } from '../../components/chartblocks/BarchartV2'\nimport { DoubleBarChart } from '../../components/chartblocks/DoubleBarChart'\nimport { EmptyBarChart } from '../../components/chartblocks/EmptyBarChart'\nimport { BAR_ARIA_LABEL } from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport {\n COMPARISON_BAR_ARIA_LABEL,\n toLegendItems,\n} from '../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils'\n\nimport { TransactionDrillDown } from './TransactionDrillDown'\nimport { useTransactionHistory } from './useTransactionHistory'\nimport {\n getDefaultSelection,\n getDrillDownConfig,\n getFlattenedDataSeries,\n resolveDrillDownSubHeader,\n toStoreFilter,\n} from './utils'\nimport {\n Drawer,\n useInsightsV2Store,\n useGlobalCopyStore,\n useGlobalUiStore,\n Loader,\n} from '../../../common'\nimport { TransactionDetailsBlock } from '../TransactionDetailsBlock'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\ninterface TransactionHistoryProp {\n beat: Beat\n}\n\nexport const TransactionHistoryBlock = observer(({ beat }: TransactionHistoryProp) => {\n const theme = useTheme()\n const {\n instanceSlotData,\n beatTransactions,\n spendCategoryGuids,\n allAccountGuids,\n categoryName,\n displayedDateRange,\n transactionStore,\n } = useTransactionHistory(beat)\n\n const { actionDrawer, setActionContext } = useInsightsV2Store()\n\n const { common: commonCopy, insights_feed: insightsCopy } = useGlobalCopyStore()\n\n const { isCopyLoaded } = useGlobalUiStore()\n\n const [isTransactionDetailsOpen, setIsTransactionDetailsOpen] = useState(false)\n\n const [closeTipSection, setCloseTipSection] = useState(false)\n\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const { insights_payload } = beat\n\n const dynamicCtaVariant = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n insights_payload?.primary_cta,\n insights_payload?.secondary_cta,\n insights_payload?.in_description_cta,\n )?.variant\n\n const { top, filterMode, header, colors, filterStrategy, tipSection, subTabAriaLabels } =\n getDrillDownConfig(dynamicCtaVariant ?? '')\n\n // `getFlattenedDataSeries` runs ahead of the copy-loaded guard below, hence the literal fallback.\n const { dataSeries, chartData, comparisonBars } = getFlattenedDataSeries({\n data: instanceSlotData?.data_series as DataSeries,\n ariaLabel:\n top === 'doubleBar'\n ? (insightsCopy?.general?.in_month_you_had_a_category_of_amount ??\n COMPARISON_BAR_ARIA_LABEL)\n : BAR_ARIA_LABEL,\n top,\n beatTransactions,\n payload: instanceSlotData,\n })\n\n const isDoubleBar = top === 'doubleBar'\n // The drawer's columns (and tabs): the double bar's month pairs, or the single bar's bars.\n const bars = isDoubleBar ? comparisonBars : chartData\n\n const { chartBarIndex, subTabIndex } = getDefaultSelection({\n chartTabCount: chartData.length,\n comparisonTabCount: comparisonBars.length,\n actionDrawer,\n beatGuid: beat.guid,\n })\n\n const [selectedIndex, setSelectedIndex] = useState(chartBarIndex)\n // The double-bar drawer's series tab (0 = main, e.g. Spend; 1 = comparison, e.g. Income).\n const [subIndex, setSubIndex] = useState(subTabIndex)\n\n const resolveFilter = (index: number) =>\n filterStrategy({\n beat,\n beatTransactions,\n dataSeries,\n comparisonBars,\n selectedIndex: index,\n subIndex,\n isLastTab: index === bars.length - 1,\n instanceSlotData,\n spendCategoryGuids,\n displayedDateRange,\n })\n\n // Apply the current selection's filter. Store variants route through the store filter; local\n // (upcomingBill) variants filter beatTransactions directly and only backfill the cache when the\n // Stable primitive keys for the collections below: beatTransactions/spendCategoryGuids/\n // allAccountGuids are recomputed (new array identity) every render, so depending on them directly\n // re-fires the effect each render (REVIEW.md MEW-3732). Key on content instead.\n const beatTransactionGuidsKey = beatTransactions.map((transaction) => transaction.guid).join(',')\n const spendCategoryGuidsKey = spendCategoryGuids.join(',')\n const allAccountGuidsKey = allAccountGuids.join(',')\n\n // Re-applies the current selection's filter to the shared transactionStore. Called both by the\n // effect below (on selection change) and when the nested TransactionDetailsBlock drawer closes:\n // AddMerchantBudgetAction (opened from within that drawer) overwrites transactionStore.filter\n // with a merchant_guid-only filter while its own drawer is open, and never restores it — leaving\n // the row list stuck showing only that one merchant's transactions after backing all the way out.\n // Re-running this on close re-derives the filter fresh instead of relying on whatever the nested\n // drawers left behind.\n // A `list` drawer has no bars: it filters once from the beat alone.\n const canApplyFilter = top === 'list' || dataSeries.length > 0\n const applyCurrentSelectionFilter = () => {\n if (filterMode !== 'store' || !canApplyFilter) return\n transactionStore.setFilter(\n toStoreFilter(resolveFilter(selectedIndex), { allAccountGuids, displayedDateRange }),\n )\n }\n\n // store variants route the selection through the shared store filter; local (upcomingBill) variants\n // filter beatTransactions directly, so there's nothing to push to the store for them.\n useLayoutEffect(() => {\n applyCurrentSelectionFilter()\n }, [\n beat.guid,\n selectedIndex,\n subIndex,\n filterMode,\n dataSeries.length,\n instanceSlotData,\n displayedDateRange,\n spendCategoryGuidsKey,\n allAccountGuidsKey,\n beatTransactionGuidsKey,\n top,\n ])\n\n const subHeader = resolveDrillDownSubHeader(insights_payload)\n\n const headerContent = header?.({\n title: insights_payload?.title,\n subHeader,\n categoryName,\n selectedDate: chartData[selectedIndex]?.date ?? undefined,\n })\n\n const barColors = colors(theme, instanceSlotData?.category_guid)\n\n if (!isCopyLoaded) return <Loader />\n\n // `legends` is the block's additional_data ([0] main, [1] second series), as BarchartBlock reads it.\n const [mainLegend, comparisonLegend] = instanceSlotData?.legends ?? []\n\n const transactionFilter =\n filterMode === 'local'\n ? (index: number) => resolveFilter(index).custom ?? (() => true)\n : undefined\n\n const baseTransactions: Transaction[] | undefined =\n filterMode === 'local' ? beatTransactions : undefined\n\n // A chart bar click selects its column (and, on the double bar, its series); a month tab change\n // selects the month. MUI Tabs only fires onChange on real user selection, not on mount. The\n // series (Spend / Income) tab fires its own analytics via the shared SubTabs component.\n const selectBar = (index: number, seriesIndex?: number) => {\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.DRAWER_CHART_BAR_CLICKED)\n setSelectedIndex(index)\n if (seriesIndex !== undefined) setSubIndex(seriesIndex)\n }\n const selectMonth = (index: number) => {\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.TAB_SELECTED)\n setSelectedIndex(index)\n }\n\n // Double bar: the Spend / Income labels come from copy (additional_data); the legend carries the\n // selected month's two totals, and its labels name the series tabs.\n const doubleBarLegends = isDoubleBar\n ? toLegendItems([\n { ...mainLegend, value: comparisonBars[selectedIndex]?.main },\n { ...comparisonLegend, value: comparisonBars[selectedIndex]?.comparison },\n ])\n : undefined\n\n // Legacy pulse named these tabs \"Spend transactions\" / \"Income transactions\" for screen readers.\n const seriesAriaLabels = subTabAriaLabels?.(insightsCopy) ?? []\n\n const renderChart = () => {\n if (!bars.length) return <EmptyBarChart />\n\n return isDoubleBar ? (\n <DoubleBarChart\n bars={comparisonBars}\n colors={barColors}\n legendPosition=\"top\"\n legends={doubleBarLegends}\n onBarClick={selectBar}\n selectedIndex={selectedIndex}\n />\n ) : (\n <BarChartV2\n amounts={{\n average: instanceSlotData?.average_amount,\n formattedAverage: formatCurrency(instanceSlotData?.average_amount ?? 0, '0,0.00'),\n }}\n color={barColors[0] ?? theme.palette.primary.main}\n data={chartData}\n legendPosition=\"top\"\n heightOverride={142}\n margin={{\n bottom: 8,\n top: 24,\n left: 24,\n right: 24,\n }}\n // TODO: Temporary fallback while the backend doesn't always send `legends` on every\n // beat/variant. Remove this once the backend guarantees `legends` on the payload.\n monthlyAmountLabel={mainLegend?.label ?? insightsCopy.general.monthly_amount}\n onBarClick={selectBar}\n selectedTabIndex={selectedIndex}\n trendAmountLabel={comparisonLegend?.label ?? insightsCopy.general.trend}\n />\n )\n }\n\n // `list` drawers (e.g. Low Account Balance) have no chart above their transaction list.\n const chartTop =\n isDoubleBar || top === 'singleBar' || top === 'upcomingBill' ? renderChart() : null\n\n return (\n <>\n <TransactionDrillDown\n baseTransactions={baseTransactions}\n heading={headerContent?.heading}\n icon={headerContent?.icon}\n onSelectionChange={selectMonth}\n selectedIndex={selectedIndex}\n subHeadingText={headerContent?.subHeadingText}\n tabs={bars}\n top={chartTop}\n {...(isDoubleBar && {\n subTabs: {\n tabs: (doubleBarLegends ?? []).map((legend, index) => ({\n label: legend.label,\n ariaLabel: seriesAriaLabels[index],\n })),\n selectedIndex: subIndex,\n onChange: setSubIndex,\n },\n })}\n {...(tipSection && {\n tipSection:\n !closeTipSection && tipSection(setCloseTipSection, insightsCopy, subHeader?.text),\n })}\n transactionFilter={transactionFilter}\n onEachRowClick={(guid) => {\n setActionContext({ transaction_guid: guid })\n setIsTransactionDetailsOpen(true)\n }}\n />\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isTransactionDetailsOpen}\n onClose={() => {\n setIsTransactionDetailsOpen(false)\n // Clear only the key this nested drawer owns — setActionContext merges, so an\n // explicit `{}` would be a no-op and leave transaction_guid stuck in the shared\n // context, and the outer drawer's own context (e.g. chartBarIndex) must survive.\n setActionContext({ transaction_guid: undefined })\n // Re-apply this block's own filter: a further-nested AddMerchantBudgetAction drawer may\n // have overwritten transactionStore.filter (merchant_guid-only) without restoring it.\n applyCurrentSelectionFilter()\n }}\n title={insightsCopy.general.transaction_details_title}\n >\n <TransactionDetailsBlock beat={beat} />\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,KAA0B,GAAA,CAAU,EAAE,MAAA,EAAA,MAAmC;AACpF,QAAM,IAAQ,GAAS,GACjB,EACJ,kBAAA,GACA,kBAAA,GACA,oBAAA,GACA,iBAAA,GACA,cAAA,GACA,oBAAA,GACA,kBAAA,EAAA,IACE,GAAsB,CAAI,GAExB,EAAE,cAAA,GAAc,kBAAA,EAAA,IAAqB,GAAmB,GAExD,EAAE,QAAQ,GAAY,eAAe,EAAA,IAAiB,GAAmB,GAEzE,EAAE,cAAA,EAAA,IAAiB,GAAiB,GAEpC,CAAC,GAA0B,CAAA,IAA+B,EAAS,EAAK,GAExE,CAAC,GAAiB,CA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KAAc,EACjB,YACE,CAAC,KAAmB,EAAW,GAAoB,GAAc,GAAW,IAAI,EACpF;AAAA,IACmB,mBAAA;AAAA,IACnB,gBAAA,CAAiB,MAAS;AACxB,MAAA,EAAiB,EAAE,kBAAkB,EAAK,CAAC,GAC3C,EAA4B,EAAI;AAAA,IAClC;AAAA,EACD,CAAA,GACD,gBAAA,EAAC,IAAD;AAAA,IACE,gBAAgB,EAAW;AAAA,IAC3B,QAAQ;AAAA,IACR,SAAA,MAAe;AACb,MAAA,EAA4B,EAAK,GAIjC,EAAiB,EAAE,kBAAkB,OAAU,CAAC,GAGhD,EAA4B;AAAA,IAC9B;AAAA,IACA,OAAO,EAAa,QAAQ;AAAA,IAE5B,UAAA,gBAAA,EAAC,IAAD,EAA+B,MAAA,EAAO,CAAA;AAAA,EAChC,CAAA,CACR,EAAA,CAAA;AAEN,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { Theme } from '@mui/material/styles';
|
|
3
3
|
import { Beat, InsightsFeedCopy, Subtitle, Transaction } from '../../../core';
|
|
4
4
|
import { TransactionFilter } from '../../../core/stores/TransactionStore';
|
|
5
|
-
import { InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData';
|
|
5
|
+
import { DataSet, InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData';
|
|
6
6
|
import { ChartDataSeriesItem } from '../../blocks/ChartBlocks/BarchartBlock/utils';
|
|
7
7
|
import { TipSectionProps } from '../../../insights/components/shared/ChartDrawerTemplate/TipSection';
|
|
8
8
|
export interface DrillDownHeader {
|
|
@@ -47,6 +47,7 @@ export interface FilterContext {
|
|
|
47
47
|
beat: Beat;
|
|
48
48
|
beatTransactions: Transaction[];
|
|
49
49
|
dataSeries: ChartDataSeriesItem[];
|
|
50
|
+
comparisonBars: DataSet[];
|
|
50
51
|
selectedIndex: number;
|
|
51
52
|
subIndex: number;
|
|
52
53
|
isLastTab: boolean;
|
|
@@ -66,6 +67,7 @@ export interface DrillDownVariantConfig {
|
|
|
66
67
|
tipSection?: (setCloseTipSection: (flag: boolean) => void, copy: InsightsFeedCopy, merchantName?: string) => TipSectionProps;
|
|
67
68
|
scope: 'store' | 'beat';
|
|
68
69
|
filterMode: 'store' | 'local';
|
|
70
|
+
subTabAriaLabels?: (copy: InsightsFeedCopy) => (string | undefined)[];
|
|
69
71
|
}
|
|
70
72
|
export declare const layout: Partial<Record<DrillDownVariant, DrillDownVariantConfig>>;
|
|
71
73
|
export declare const FALLBACK: DrillDownVariantConfig;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { buildDynamicCopy as
|
|
2
|
-
import { DATE_FORMATS_INTL as
|
|
3
|
-
import { fromUnixUTC as
|
|
4
|
-
import { getCategoryColor as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { buildDynamicCopy as N } from "../../../core/utils/Localization.es.js";
|
|
2
|
+
import { DATE_FORMATS_INTL as f, formatDate as S } from "../../../core/constants/DateFormats.es.js";
|
|
3
|
+
import { fromUnixUTC as u } from "../../../core/utils/DateUtil.es.js";
|
|
4
|
+
import { getCategoryColor as O } from "../../../core/utils/CategoryUtil.es.js";
|
|
5
|
+
import { getLayoutConfig as C } from "../../blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js";
|
|
6
|
+
import { MerchantLogo as T } from "@mxenabled/mxui";
|
|
7
|
+
import { Icon as A } from "@mxenabled/mx-icons";
|
|
7
8
|
import { jsx as c } from "react/jsx-runtime";
|
|
8
|
-
import { endOfMonth as
|
|
9
|
-
var
|
|
9
|
+
import { endOfMonth as p, isValid as h, parseISO as I, startOfMonth as y } from "date-fns";
|
|
10
|
+
var i = {
|
|
10
11
|
TRANSACTION: "not_standard_amount",
|
|
11
12
|
CATEGORY_SPEND: "category_spend",
|
|
12
13
|
MONTHLY_SPEND: "monthly_spend_comparison",
|
|
@@ -19,10 +20,10 @@ var s = {
|
|
|
19
20
|
NON_ESSENTIAL_CATEGORY: "non_essential_category_summary",
|
|
20
21
|
DEPOSIT_SUMMARY: "monthly_deposit_summary",
|
|
21
22
|
LOW_BALANCE: "low_balance"
|
|
22
|
-
}, l = (e, t) => t &&
|
|
23
|
-
start:
|
|
24
|
-
end:
|
|
25
|
-
}), m = (e) => e?.length ? { accounts: e } : {},
|
|
23
|
+
}, l = (e, t) => t && O(t, e) || e.palette.primary.main, _ = (e) => ({
|
|
24
|
+
start: y(new Date(e ?? NaN)),
|
|
25
|
+
end: p(new Date(e ?? NaN))
|
|
26
|
+
}), m = (e) => e?.length ? { accounts: e } : {}, L = ({ beat: e }) => {
|
|
26
27
|
const { account_guid: t, from_date: o, to_date: r } = e.insights_payload?.drilldown_data ?? {};
|
|
27
28
|
return typeof t != "string" || typeof o != "number" || typeof r != "number" || !Number.isFinite(o) || !Number.isFinite(r) || r <= o ? {
|
|
28
29
|
accounts: [],
|
|
@@ -30,41 +31,54 @@ var s = {
|
|
|
30
31
|
} : {
|
|
31
32
|
accounts: [t],
|
|
32
33
|
dateRange: {
|
|
33
|
-
start:
|
|
34
|
-
end:
|
|
34
|
+
start: u(o),
|
|
35
|
+
end: u(r - 1)
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
38
|
}, g = ({ beatTransactions: e, dataSeries: t, selectedIndex: o }) => {
|
|
38
|
-
const r = t[o], a = r?.guid,
|
|
39
|
+
const r = t[o], a = r?.guid, s = e.find((n) => n.guid === a)?.has_been_split;
|
|
39
40
|
return {
|
|
40
|
-
custom: (
|
|
41
|
+
custom: (n) => n.guid === a,
|
|
41
42
|
dateRange: _(r?.date),
|
|
42
|
-
showSplits: !
|
|
43
|
+
showSplits: !s
|
|
43
44
|
};
|
|
44
|
-
},
|
|
45
|
+
}, M = ({ dataSeries: e, selectedIndex: t, instanceSlotData: o }) => {
|
|
45
46
|
const r = e[t], a = o.category_guid ?? r?.guid;
|
|
46
47
|
return {
|
|
47
|
-
custom: (
|
|
48
|
+
custom: (s) => s.category_guid === a || s.top_level_category_guid === a,
|
|
48
49
|
dateRange: _(r?.date)
|
|
49
50
|
};
|
|
50
|
-
},
|
|
51
|
+
}, E = ({ dataSeries: e, selectedIndex: t, spendCategoryGuids: o, instanceSlotData: r }) => {
|
|
51
52
|
const a = e[t];
|
|
52
53
|
return {
|
|
53
|
-
custom: (
|
|
54
|
+
custom: (s) => !!s.top_level_category_guid && o.includes(s.top_level_category_guid),
|
|
54
55
|
dateRange: _(a?.date),
|
|
55
56
|
...m(r.account_guids)
|
|
56
57
|
};
|
|
57
|
-
},
|
|
58
|
-
const
|
|
58
|
+
}, D = ({ beat: e, dataSeries: t, selectedIndex: o, isLastTab: r, instanceSlotData: a }) => {
|
|
59
|
+
const s = t[o], { start: n, end: d } = _(s?.date);
|
|
59
60
|
return {
|
|
60
61
|
dateRange: {
|
|
61
|
-
start:
|
|
62
|
-
end: r && e.created_at ? new Date(e.created_at) :
|
|
62
|
+
start: n,
|
|
63
|
+
end: r && e.created_at ? new Date(e.created_at) : d
|
|
63
64
|
},
|
|
64
65
|
...m(a.account_guids)
|
|
65
66
|
};
|
|
66
|
-
},
|
|
67
|
-
[s
|
|
67
|
+
}, b = ({ beat: e, comparisonBars: t, selectedIndex: o, subIndex: r }) => {
|
|
68
|
+
const a = t[o], s = new Set(r === 1 ? a?.comparisonGuids : a?.mainGuids), n = I(a?.date ?? "");
|
|
69
|
+
return !s.size || !h(n) ? {
|
|
70
|
+
accounts: [],
|
|
71
|
+
custom: () => !1
|
|
72
|
+
} : {
|
|
73
|
+
custom: (d) => s.has(d.guid),
|
|
74
|
+
dateRange: {
|
|
75
|
+
start: y(n),
|
|
76
|
+
end: p(n)
|
|
77
|
+
},
|
|
78
|
+
...m(e.account_guids)
|
|
79
|
+
};
|
|
80
|
+
}, x = {
|
|
81
|
+
[i.TRANSACTION]: {
|
|
68
82
|
top: "singleBar",
|
|
69
83
|
scope: "store",
|
|
70
84
|
filterMode: "store",
|
|
@@ -75,7 +89,7 @@ var s = {
|
|
|
75
89
|
return {
|
|
76
90
|
heading: t,
|
|
77
91
|
subHeadingText: o?.text || void 0,
|
|
78
|
-
icon: /* @__PURE__ */ c(
|
|
92
|
+
icon: /* @__PURE__ */ c(T, {
|
|
79
93
|
alt: o?.text,
|
|
80
94
|
categoryGuid: o?.logo?.category_guid || "",
|
|
81
95
|
merchantGuid: o?.logo?.merchant_guid || "",
|
|
@@ -84,54 +98,62 @@ var s = {
|
|
|
84
98
|
};
|
|
85
99
|
},
|
|
86
100
|
tipSection: (e, t, o = "") => ({
|
|
87
|
-
message:
|
|
101
|
+
message: N(t.general.tip_section_message, /* @__PURE__ */ c("strong", { children: t.general.tip_section_title }), /* @__PURE__ */ c("strong", { children: o })),
|
|
88
102
|
onDismiss: () => e(!0)
|
|
89
103
|
})
|
|
90
104
|
},
|
|
91
|
-
[
|
|
105
|
+
[i.CATEGORY_SPEND]: {
|
|
92
106
|
top: "singleBar",
|
|
93
|
-
filterStrategy:
|
|
107
|
+
filterStrategy: M,
|
|
94
108
|
scope: "store",
|
|
95
109
|
filterMode: "store",
|
|
96
110
|
colors: (e, t) => [l(e, t)],
|
|
97
111
|
header: (e) => ({
|
|
98
112
|
heading: e.categoryName,
|
|
99
|
-
subHeadingText: e.selectedDate &&
|
|
100
|
-
icon: /* @__PURE__ */ c(
|
|
113
|
+
subHeadingText: e.selectedDate && S(e.selectedDate, f.MONTH_LONG) || "",
|
|
114
|
+
icon: /* @__PURE__ */ c(A, {
|
|
101
115
|
name: "calendar_month",
|
|
102
116
|
size: 16
|
|
103
117
|
})
|
|
104
118
|
})
|
|
105
119
|
},
|
|
106
|
-
[
|
|
120
|
+
[i.MONTHLY_SPEND]: {
|
|
107
121
|
top: "singleBar",
|
|
108
|
-
filterStrategy:
|
|
122
|
+
filterStrategy: E,
|
|
109
123
|
scope: "store",
|
|
110
124
|
filterMode: "store",
|
|
111
125
|
colors: (e) => [e.palette.chart.chart2 ?? e.palette.primary.main]
|
|
112
126
|
},
|
|
113
|
-
[
|
|
127
|
+
[i.ACCOUNT_BALANCE]: {
|
|
114
128
|
top: "singleBar",
|
|
115
|
-
filterStrategy:
|
|
129
|
+
filterStrategy: D,
|
|
116
130
|
scope: "store",
|
|
117
131
|
filterMode: "store",
|
|
118
132
|
colors: (e) => [e.palette.success.main]
|
|
119
133
|
},
|
|
120
|
-
[
|
|
134
|
+
[i.UPCOMING_BILL]: {
|
|
121
135
|
top: "upcomingBill",
|
|
122
136
|
filterStrategy: g,
|
|
123
137
|
scope: "beat",
|
|
124
138
|
filterMode: "local",
|
|
125
139
|
colors: (e, t) => [l(e, t)]
|
|
126
140
|
},
|
|
127
|
-
[
|
|
141
|
+
[i.LOW_BALANCE]: {
|
|
128
142
|
top: "list",
|
|
129
|
-
filterStrategy:
|
|
143
|
+
filterStrategy: L,
|
|
130
144
|
scope: "store",
|
|
131
145
|
filterMode: "store",
|
|
132
146
|
colors: (e) => [e.palette.primary.main]
|
|
147
|
+
},
|
|
148
|
+
[i.SPEND_TO_INCOME]: {
|
|
149
|
+
top: "doubleBar",
|
|
150
|
+
filterStrategy: b,
|
|
151
|
+
scope: "store",
|
|
152
|
+
filterMode: "store",
|
|
153
|
+
colors: (e) => C(e, "spend_to_income")?.color ?? [],
|
|
154
|
+
subTabAriaLabels: (e) => [e.general.spend_transactions, e.general.income_transactions]
|
|
133
155
|
}
|
|
134
|
-
},
|
|
156
|
+
}, F = {
|
|
135
157
|
top: "singleBar",
|
|
136
158
|
filterStrategy: g,
|
|
137
159
|
scope: "store",
|
|
@@ -139,9 +161,9 @@ var s = {
|
|
|
139
161
|
colors: (e, t) => [l(e, t)]
|
|
140
162
|
};
|
|
141
163
|
export {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
164
|
+
i as DRILLDOWN_VARIANTS,
|
|
165
|
+
F as FALLBACK,
|
|
166
|
+
x as layout
|
|
145
167
|
};
|
|
146
168
|
|
|
147
169
|
//# sourceMappingURL=layout.es.js.map
|