@mx-cartographer/experiences 9.7.1 → 9.7.3
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 +11 -0
- package/dist/common/constants/Analytics.d.ts +1 -0
- package/dist/common/constants/Analytics.es.js +2 -1
- package/dist/common/constants/Analytics.es.js.map +1 -1
- package/dist/common/context/hooks.d.ts +1 -0
- package/dist/common/context/hooks.es.js +30 -29
- package/dist/common/context/hooks.es.js.map +1 -1
- package/dist/common/context/index.d.ts +1 -1
- package/dist/common/index.es.js +140 -139
- package/dist/core/api/AgreementApi.d.ts +7 -0
- package/dist/core/api/AgreementApi.es.js +14 -0
- package/dist/core/api/AgreementApi.es.js.map +1 -0
- package/dist/core/api/index.d.ts +1 -0
- package/dist/core/constants/ApiEndpoints.d.ts +1 -0
- package/dist/core/constants/ApiEndpoints.es.js +1 -0
- package/dist/core/constants/ApiEndpoints.es.js.map +1 -1
- package/dist/core/index.es.js +92 -88
- package/dist/core/stores/AgreementStore.d.ts +12 -0
- package/dist/core/stores/AgreementStore.es.js +35 -0
- package/dist/core/stores/AgreementStore.es.js.map +1 -0
- package/dist/core/stores/GlobalStore.d.ts +2 -1
- package/dist/core/stores/GlobalStore.es.js +32 -30
- package/dist/core/stores/GlobalStore.es.js.map +1 -1
- package/dist/core/stores/GlobalUiStore.d.ts +1 -0
- package/dist/core/stores/GlobalUiStore.es.js +9 -4
- package/dist/core/stores/GlobalUiStore.es.js.map +1 -1
- package/dist/core/stores/UserStore.d.ts +2 -1
- package/dist/core/stores/UserStore.es.js +42 -29
- package/dist/core/stores/UserStore.es.js.map +1 -1
- package/dist/core/stores/index.d.ts +1 -0
- package/dist/core/types/Agreement.d.ts +6 -0
- package/dist/core/types/InsightsInstanceSlotData.d.ts +6 -2
- package/dist/core/types/InsightsInstanceSlotData.es.js.map +1 -1
- package/dist/core/types/User.d.ts +1 -0
- package/dist/core/types/index.d.ts +1 -0
- package/dist/core/types/localization/CommonCopy.d.ts +15 -0
- package/dist/dashboard/Dashboard.es.js +68 -36
- package/dist/dashboard/Dashboard.es.js.map +1 -1
- package/dist/dashboard/WelcomeDialog.d.ts +7 -0
- package/dist/dashboard/WelcomeDialog.es.js +281 -0
- package/dist/dashboard/WelcomeDialog.es.js.map +1 -0
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.es.js +4 -2
- package/dist/finstrong/components/ManageDOB.es.js +16 -16
- package/dist/goals/components/GoalList.es.js +1 -1
- package/dist/goals/components/actions/BirthdayAction.es.js +11 -11
- package/dist/insights/components/insights/BillAmountNotStandard/BillAmountNotStandard.es.js +9 -9
- package/dist/insights/components/insights/BillAmountNotStandard/BillAmountNotStandardMUI.es.js +8 -8
- package/dist/insights/components/insights/MonthlySpendingComparisonV2/MonthlySpendingComparisonV2.es.js +9 -9
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/TransactionDetailsBlock.es.js +4 -4
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +58 -58
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.d.ts +1 -3
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js +14 -13
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +8 -2
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +56 -36
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.d.ts +7 -3
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js +30 -32
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.d.ts +3 -2
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js +16 -15
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/IconComponent.es.js +5 -5
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js +6 -6
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +4 -4
- package/dist/insights-v2/blocks/ComponentBlocks/UpcomingBillBlock/UpcomingBillBlock.es.js +6 -6
- package/dist/insights-v2/blocks/ComponentBlocks/UpcomingSubscriptionBlock/UpcomingSubscriptionBlock.es.js +1 -1
- package/dist/insights-v2/components/BaseLayout.es.js +24 -24
- package/dist/insights-v2/components/CompactInsightCard.d.ts +4 -2
- package/dist/insights-v2/components/CompactInsightCard.es.js +91 -59
- package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
- package/dist/insights-v2/components/chartblocks/EmptyBarChart.es.js +4 -4
- package/dist/insights-v2/index.es.js +122 -121
- package/dist/insights-v2/mappings/blocks.es.js +112 -99
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/dist/microinsights/cards/InsightCard.es.js +10 -10
- package/dist/recurringtransactions/components/PaymentSchedule.es.js +11 -11
- package/dist/recurringtransactions/components/RecurringTransactionDetails.es.js +16 -16
- package/dist/settings/components/profile/ProfileTab.es.js +33 -33
- package/dist/transactions/components/shared/TransactionDetails.es.js +5 -4
- package/dist/transactions/components/shared/TransactionDetails.es.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { useAccountStore as
|
|
2
|
-
import { selectTransactionsByGuids as
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { useAccountStore as c, useCategoryStore as u, useGlobalUiStore as d, useTransactionStore as g } from "../../../common/context/hooks.es.js";
|
|
2
|
+
import { selectTransactionsByGuids as l } from "../../CommonUtils.es.js";
|
|
3
|
+
import { toDrillDownSlotData as m } from "./utils.es.js";
|
|
4
|
+
import { useMemo as p } from "react";
|
|
5
|
+
var f = (n) => {
|
|
6
|
+
const a = n.insights_payload, t = p(() => m(a?.instance_slot?.data ?? {}), [a]), s = g(), r = c(), e = u(), { displayedDateRange: i } = d();
|
|
5
7
|
return {
|
|
6
|
-
instanceSlotData:
|
|
7
|
-
beatTransactions:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
transactionStore: o
|
|
8
|
+
instanceSlotData: t,
|
|
9
|
+
beatTransactions: l(s.detailedTransactions, t?.transaction_guids),
|
|
10
|
+
spendCategoryGuids: e.spendCategories.map((o) => o.guid),
|
|
11
|
+
allAccountGuids: r.accounts.map((o) => o.guid),
|
|
12
|
+
categoryName: e.getCategoryName(t?.category_guid ?? "") || "",
|
|
13
|
+
displayedDateRange: i,
|
|
14
|
+
transactionStore: s
|
|
14
15
|
};
|
|
15
16
|
};
|
|
16
17
|
export {
|
|
17
|
-
|
|
18
|
+
f as useTransactionHistory
|
|
18
19
|
};
|
|
19
20
|
|
|
20
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 {\n useAccountStore,\n useCategoryStore,\n useGlobalUiStore,\n useTransactionStore,\n} from '../../../common'\nimport type { Beat } from '../../../core'\nimport type {
|
|
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 () => toDrillDownSlotData((insightsPayload?.instance_slot?.data ?? {}) as BarChartBlockData),\n [insightsPayload],\n )\n\n const transactionStore = useTransactionStore()\n const accountStore = useAccountStore()\n const categoryStore = useCategoryStore()\n const { displayedDateRange } = useGlobalUiStore()\n\n const beatTransactions = selectTransactionsByGuids(\n transactionStore.detailedTransactions,\n instanceSlotData?.transaction_guids,\n )\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":";;;;AAaA,IAAa,IAAA,CAAyB,MAAe;AAEnD,QAAM,IAAkB,EAAK,kBACvB,IAAmB,EAAA,MACjB,EAAqB,GAAiB,eAAe,QAAQ,CAAC,CAAuB,GAC3F,CAAC,CAAe,CAClB,GAEM,IAAmB,EAAoB,GACvC,IAAe,EAAgB,GAC/B,IAAgB,EAAiB,GACjC,EAAE,oBAAA,EAAA,IAAuB,EAAiB;AAWhD,SAAO;AAAA,IACL,kBAAA;AAAA,IACA,kBAXuB,EACvB,EAAiB,sBACjB,GAAkB,iBASlB;AAAA,IACA,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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ActionDrawerState, DataSeries, GlobalCopy, Transaction } from '../../../core';
|
|
2
|
-
import { DataSet } from '../../../core/types/InsightsInstanceSlotData';
|
|
1
|
+
import { ActionDrawerState, DataSeries, GlobalCopy, InsightsPayload, Subtitle, Transaction } from '../../../core';
|
|
2
|
+
import { BarChartBlockData, DataSet, InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData';
|
|
3
3
|
import { TransactionFilter } from '../../../core/stores/TransactionStore';
|
|
4
4
|
import { buildChartData, ChartDataSeriesItem } from '../../blocks/ChartBlocks/BarchartBlock/utils';
|
|
5
5
|
import { DrillDownVariantConfig } from './layout';
|
|
@@ -61,4 +61,10 @@ export declare const getDefaultSelection: ({ chartTabCount, actionDrawer, beatGu
|
|
|
61
61
|
chartBarIndex: number;
|
|
62
62
|
subTabIndex: number;
|
|
63
63
|
};
|
|
64
|
+
/** The drawer's facts: the generic slot facts plus the bar chart's average. */
|
|
65
|
+
export type DrillDownSlotData = InsightsInstanceSlotData & Pick<BarChartBlockData, 'average_amount'>;
|
|
66
|
+
/** The drawer's facts from a bar chart's `instance_slot.data`. */
|
|
67
|
+
export declare const toDrillDownSlotData: ({ series, category_guid, average_amount, additional_data, }: BarChartBlockData) => DrillDownSlotData;
|
|
68
|
+
/** The drawer's sub-heading: the merchant name and logo. */
|
|
69
|
+
export declare const resolveDrillDownSubHeader: (payload: Partial<InsightsPayload> | undefined) => Subtitle | undefined;
|
|
64
70
|
export {};
|
|
@@ -1,67 +1,87 @@
|
|
|
1
|
-
import { DATE_FORMATS_INTL as
|
|
2
|
-
import { buildChartData as s, buildDataSeries as
|
|
3
|
-
import { DRILLDOWN_VARIANTS as
|
|
1
|
+
import { DATE_FORMATS_INTL as l } from "../../../core/constants/DateFormats.es.js";
|
|
2
|
+
import { buildChartData as s, buildDataSeries as u } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
|
|
3
|
+
import { DRILLDOWN_VARIANTS as g, FALLBACK as m, layout as _ } from "./layout.es.js";
|
|
4
4
|
import { format as h, fromUnixTime as D } from "date-fns";
|
|
5
|
-
var
|
|
5
|
+
var y = (t) => _[t] ?? m, I = ({ data: t, ariaLabel: e, top: r, beatTransactions: n, payload: a }) => {
|
|
6
6
|
if (r === "upcomingBill") {
|
|
7
|
-
const d =
|
|
7
|
+
const d = S(n, a);
|
|
8
8
|
return {
|
|
9
9
|
dataSeries: d,
|
|
10
|
-
chartData: s(d, e,
|
|
10
|
+
chartData: s(d, e, l.MONTH_DAY),
|
|
11
11
|
comparisonBars: []
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const o = [...u(t)].sort((d, i) => !d.date || !i.date ? 0 : new Date(d.date).getTime() - new Date(i.date).getTime());
|
|
15
15
|
return {
|
|
16
|
-
dataSeries:
|
|
17
|
-
chartData: s(
|
|
16
|
+
dataSeries: o,
|
|
17
|
+
chartData: s(o, e),
|
|
18
18
|
comparisonBars: []
|
|
19
19
|
};
|
|
20
|
-
},
|
|
20
|
+
}, f = "TRN-projected-bill", p = (t) => ({
|
|
21
21
|
date: h(D(t.date), "yyyy-MM-dd"),
|
|
22
22
|
amount: t.amount,
|
|
23
23
|
guid: t.guid,
|
|
24
24
|
category_guid: t.top_level_category_guid ?? t.category_guid
|
|
25
|
-
}),
|
|
25
|
+
}), S = (t = [], e) => {
|
|
26
26
|
if (!t.length || e?.date == null || e?.amount == null) return [];
|
|
27
|
-
const r = [...t].sort((i, c) => i.date - c.date),
|
|
27
|
+
const r = [...t].sort((i, c) => i.date - c.date), n = /* @__PURE__ */ new Set(), a = [];
|
|
28
28
|
for (const i of r)
|
|
29
|
-
|
|
30
|
-
const
|
|
29
|
+
n.has(i.date) || (n.add(i.date), a.push(p(i)));
|
|
30
|
+
const o = r[r.length - 1], d = {
|
|
31
31
|
date: e.date,
|
|
32
32
|
amount: e.amount,
|
|
33
|
-
guid:
|
|
34
|
-
category_guid:
|
|
33
|
+
guid: f,
|
|
34
|
+
category_guid: o.top_level_category_guid ?? o.category_guid
|
|
35
35
|
};
|
|
36
|
-
return [...
|
|
37
|
-
},
|
|
38
|
-
const r = e.insights_feed?.general?.transaction_history_title ?? "",
|
|
39
|
-
if (t ===
|
|
40
|
-
const
|
|
41
|
-
return
|
|
42
|
-
},
|
|
36
|
+
return [...a, d];
|
|
37
|
+
}, A = (t, e) => {
|
|
38
|
+
const r = e.insights_feed?.general?.transaction_history_title ?? "", n = e.insights_feed?.transaction_history_block;
|
|
39
|
+
if (t === g.TRANSACTION) return r;
|
|
40
|
+
const a = `${t}_drawer_title`;
|
|
41
|
+
return n?.[a] ?? r;
|
|
42
|
+
}, w = (t, e) => ({
|
|
43
43
|
accounts: t.accounts ?? e.allAccountGuids,
|
|
44
44
|
dateRange: t.dateRange ?? e.displayedDateRange,
|
|
45
45
|
custom: t.custom ?? (() => !0),
|
|
46
46
|
showSplits: t.showSplits ?? !1
|
|
47
|
-
}),
|
|
48
|
-
const
|
|
49
|
-
return
|
|
50
|
-
chartBarIndex: Math.min(Math.max(
|
|
51
|
-
subTabIndex:
|
|
47
|
+
}), R = ({ chartTabCount: t, actionDrawer: e, beatGuid: r }) => {
|
|
48
|
+
const n = e.guid === r && e.trigger === "chartBar", a = e.context, o = n ? a?.tabIndex ?? 0 : 0;
|
|
49
|
+
return n ? {
|
|
50
|
+
chartBarIndex: Math.min(Math.max(a?.chartBarIndex ?? 0, 0), Math.max(0, t - 1)),
|
|
51
|
+
subTabIndex: o
|
|
52
52
|
} : {
|
|
53
53
|
chartBarIndex: Math.max(0, t - 1),
|
|
54
|
-
subTabIndex:
|
|
54
|
+
subTabIndex: o
|
|
55
55
|
};
|
|
56
|
+
}, M = ({ series: t, category_guid: e, average_amount: r, additional_data: n }) => {
|
|
57
|
+
const a = u(t).map(({ guid: o }) => o).filter((o) => !!o);
|
|
58
|
+
return {
|
|
59
|
+
data_series: t,
|
|
60
|
+
category_guid: e,
|
|
61
|
+
average_amount: r,
|
|
62
|
+
legends: n,
|
|
63
|
+
transaction_guids: a.length ? a : void 0
|
|
64
|
+
};
|
|
65
|
+
}, b = (t) => {
|
|
66
|
+
if (t)
|
|
67
|
+
return {
|
|
68
|
+
text: t.subtitle ?? "",
|
|
69
|
+
logo: {
|
|
70
|
+
merchant_guid: t.logo?.guid,
|
|
71
|
+
category_guid: ""
|
|
72
|
+
}
|
|
73
|
+
};
|
|
56
74
|
};
|
|
57
75
|
export {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
f as PROJECTED_BILL_GUID,
|
|
77
|
+
S as buildUpcomingBillSeries,
|
|
78
|
+
R as getDefaultSelection,
|
|
79
|
+
A as getDrawerHeaderTitle,
|
|
80
|
+
y as getDrillDownConfig,
|
|
81
|
+
I as getFlattenedDataSeries,
|
|
82
|
+
b as resolveDrillDownSubHeader,
|
|
83
|
+
M as toDrillDownSlotData,
|
|
84
|
+
w as toStoreFilter
|
|
65
85
|
};
|
|
66
86
|
|
|
67
87
|
//# sourceMappingURL=utils.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/utils.ts"],"sourcesContent":["import { format, fromUnixTime } from 'date-fns'\n\nimport type {\n ActionDrawerState,\n DataSeries,\n DrilldownPayload,\n GlobalCopy,\n Transaction,\n} from '../../../core'\nimport { DATE_FORMATS_INTL } from '../../../core/constants'\nimport type { DataSet } from '../../../core/types/InsightsInstanceSlotData'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport {\n buildChartData,\n buildDataSeries,\n type ChartDataSeriesItem,\n} from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport {\n layout,\n FALLBACK,\n DRILLDOWN_VARIANTS,\n DrillDownVariant,\n DrillDownVariantConfig,\n} from './layout'\nimport { TransactionHistoryBlock } from '../../../core/types/localization/InsightsFeedCopy'\n\ninterface DefaultSelectionProp {\n chartTabCount: number\n comparisonTabCount: number\n actionDrawer: ActionDrawerState\n beatGuid: string\n}\nexport const getDrillDownConfig = (variant?: string): DrillDownVariantConfig =>\n layout[variant as DrillDownVariant] ?? FALLBACK\n\n// The shaped chart inputs a drill-down needs, derived once from the beat's data_series. `dataSeries`\n// is the flat per-bar source (indexes the filterStrategy); `chartData` feeds the single-bar chart;\n// `comparisonBars` is reserved for the double-bar MR (empty until then).\nexport interface FlattenedDataSeries {\n dataSeries: ChartDataSeriesItem[]\n chartData: ReturnType<typeof buildChartData>\n comparisonBars: DataSet[]\n}\n\n/**\n * Shapes the beat's raw data_series into the chart inputs for the variant's top kind. This MR handles\n * the single-bar family (singleBar / upcomingBill); the double-bar and tabsOnly branches are stubbed\n * for the next MR so the call site is already wired.\n */\ninterface FlattenedDataSeriesInput {\n data: DataSeries | undefined\n ariaLabel: string\n top: DrillDownVariantConfig['top']\n // UpcomingBill has no data_series; it builds its bars from these instead.\n beatTransactions: Transaction[]\n payload: { date?: string; amount?: number } | undefined\n}\n\nexport const getFlattenedDataSeries = ({\n data,\n ariaLabel,\n top,\n beatTransactions,\n payload,\n}: FlattenedDataSeriesInput): FlattenedDataSeries => {\n // UpcomingBill has no backend data_series: synthesize the bars from the beat's recurring-bill\n // transactions + the projected bill, and label each bar by day (MONTH_DAY) since a bar is one bill.\n if (top === 'upcomingBill') {\n const dataSeries = buildUpcomingBillSeries(beatTransactions, payload)\n return {\n dataSeries,\n chartData: buildChartData(dataSeries, ariaLabel, DATE_FORMATS_INTL.MONTH_DAY),\n comparisonBars: [],\n }\n }\n\n // Single-bar family (THIS MR): the backend sends data_series newest-first, so normalize it\n // date-ascending here. chartData/tabs and the filter's dataSeries[selectedIndex] indexing both read\n // this one array, so they stay aligned and the last tab is the most recent month.\n const dataSeries = [...buildDataSeries(data)].sort((a, b) => {\n if (!a.date || !b.date) return 0\n\n return new Date(a.date).getTime() - new Date(b.date).getTime()\n })\n\n // NEXT MR — double bar: comparison beats build paired bars instead of chartData.\n // if (top === \"doubleBar\") {\n // return { dataSeries, chartData: [], comparisonBars: buildComparisonSeries(data, ariaLabel) };\n // }\n //\n // NEXT MR — tabsOnly: donut-drawer beats render no top chart.\n // if (top === \"tabsOnly\") {\n // return { dataSeries, chartData: [], comparisonBars: [] };\n // }\n\n return { dataSeries, chartData: buildChartData(dataSeries, ariaLabel), comparisonBars: [] }\n}\n\n// Sentinel guid for the synthesized projected bill. It intentionally matches no real store\n// transaction, so the projected tab's guid filter yields an empty list (projected-bar-only scope).\nexport const PROJECTED_BILL_GUID = 'TRN-projected-bill'\n\n// One bar in the UpcomingBill chart. `date` is 'yyyy-MM-dd' so buildChartData/parseISO can read both\n// historical unix timestamps and the ISO payload date after normalization here.\nexport interface UpcomingBillBar {\n date: string\n amount: number\n guid: string\n category_guid?: string\n}\n\nconst toUpcomingBillBar = (transaction: Transaction): UpcomingBillBar => ({\n date: format(fromUnixTime(transaction.date), 'yyyy-MM-dd'),\n amount: transaction.amount,\n guid: transaction.guid,\n category_guid: transaction.top_level_category_guid ?? transaction.category_guid,\n})\n\n/**\n * UpcomingBill has no data_series: build the bar series straight from the beat's recurring-bill\n * transactions plus the synthesized projected bill from payload (mirrors pulse's magicTransactions).\n * Historical bills are de-duped by date and each keeps its real transaction guid so the guid filter\n * finds it in the store; the projected bar (cloned category from the latest bill) carries the\n * PROJECTED_BILL_GUID sentinel. The result is sorted date-ascending so the projected bill lands last.\n */\nexport const buildUpcomingBillSeries = (\n transactions: Transaction[] = [],\n payload: { date?: string; amount?: number } | undefined,\n): UpcomingBillBar[] => {\n if (!transactions.length || payload?.date == null || payload?.amount == null) {\n return []\n }\n\n const sorted = [...transactions].sort((a, b) => a.date - b.date)\n\n const seenDates = new Set<number>()\n const history: UpcomingBillBar[] = []\n for (const transaction of sorted) {\n if (seenDates.has(transaction.date)) continue\n seenDates.add(transaction.date)\n history.push(toUpcomingBillBar(transaction))\n }\n\n const latestBill = sorted[sorted.length - 1]\n const projected: UpcomingBillBar = {\n date: payload.date,\n amount: payload.amount,\n guid: PROJECTED_BILL_GUID,\n category_guid: latestBill.top_level_category_guid ?? latestBill.category_guid,\n }\n\n return [...history, projected]\n}\n\nexport const getDrawerHeaderTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n): string => {\n const transactionHistoryTitle = copy.insights_feed?.general?.transaction_history_title ?? ''\n const drawerTitleCopy = copy.insights_feed?.transaction_history_block as TransactionHistoryBlock\n\n if (variant === DRILLDOWN_VARIANTS.TRANSACTION) return transactionHistoryTitle\n\n // Safely access the drawer title from transaction_history_block\n const key = `${variant}_drawer_title` as keyof TransactionHistoryBlock\n return (drawerTitleCopy?.[key] as string) ?? transactionHistoryTitle\n}\n\nexport const toStoreFilter = (\n filter: TransactionFilter,\n defaults: { allAccountGuids: string[]; displayedDateRange: { start: Date; end: Date } },\n): TransactionFilter => ({\n accounts: filter.accounts ?? defaults.allAccountGuids,\n dateRange: filter.dateRange ?? defaults.displayedDateRange,\n custom: filter.custom ?? (() => true),\n showSplits: filter.showSplits ?? false,\n})\n\nexport const getDefaultSelection = ({\n chartTabCount,\n actionDrawer,\n beatGuid,\n}: DefaultSelectionProp): { chartBarIndex: number; subTabIndex: number } => {\n const openedViaChartBar = actionDrawer.guid === beatGuid && actionDrawer.trigger === 'chartBar'\n\n // actionDrawer.context is an opaque `unknown` bag; narrow it to the shape the chart blocks write.\n const context = actionDrawer.context as DrilldownPayload | undefined\n const subTabIndex = openedViaChartBar ? (context?.tabIndex ?? 0) : 0\n\n if (openedViaChartBar) {\n const clamped = Math.min(\n Math.max(context?.chartBarIndex ?? 0, 0),\n Math.max(0, chartTabCount - 1),\n )\n return { chartBarIndex: clamped, subTabIndex }\n }\n\n return { chartBarIndex: Math.max(0, chartTabCount - 1), subTabIndex }\n}\n"],"mappings":";;;;AAgCA,IAAa,IAAA,CAAsB,MACjC,EAAO,CAAA,KAAgC,GAyB5B,IAAA,CAA0B,EACrC,MAAA,GACA,WAAA,GACA,KAAA,GACA,kBAAA,GACA,SAAA,EAAA,MACmD;AAGnD,MAAI,MAAQ,gBAAgB;AAC1B,UAAM,IAAa,EAAwB,GAAkB,CAAO;AACpE,WAAO;AAAA,MACL,YAAA;AAAA,MACA,WAAW,EAAe,GAAY,GAAW,EAAkB,SAAS;AAAA,MAC5E,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAKA,QAAM,IAAa,CAAC,GAAG,EAAgB,CAAI,CAAC,EAAE,KAAA,CAAM,GAAG,MACjD,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAa,IAExB,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,IAAI,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,CAC9D;AAYD,SAAO;AAAA,IAAE,YAAA;AAAA,IAAY,WAAW,EAAe,GAAY,CAAS;AAAA,IAAG,gBAAgB,CAAC;AAAA,EAAE;AAC5F,GAIa,IAAsB,sBAW7B,IAAA,CAAqB,OAA+C;AAAA,EACxE,MAAM,EAAO,EAAa,EAAY,IAAI,GAAG,YAAY;AAAA,EACzD,QAAQ,EAAY;AAAA,EACpB,MAAM,EAAY;AAAA,EAClB,eAAe,EAAY,2BAA2B,EAAY;AACpE,IASa,IAAA,CACX,IAA8B,CAAC,GAC/B,MACsB;AACtB,MAAI,CAAC,EAAa,UAAU,GAAS,QAAQ,QAAQ,GAAS,UAAU,KACtE,QAAO,CAAC;AAGV,QAAM,IAAS,CAAC,GAAG,CAAY,EAAE,KAAA,CAAM,GAAG,MAAM,EAAE,OAAO,EAAE,IAAI,GAEzD,IAAY,oBAAI,IAAY,GAC5B,IAA6B,CAAC;AACpC,aAAW,KAAe;AACxB,IAAI,EAAU,IAAI,EAAY,IAAI,MAClC,EAAU,IAAI,EAAY,IAAI,GAC9B,EAAQ,KAAK,EAAkB,CAAW,CAAC;AAG7C,QAAM,IAAa,EAAO,EAAO,SAAS,CAAA,GACpC,IAA6B;AAAA,IACjC,MAAM,EAAQ;AAAA,IACd,QAAQ,EAAQ;AAAA,IAChB,MAAM;AAAA,IACN,eAAe,EAAW,2BAA2B,EAAW;AAAA,EAClE;AAEA,SAAO,CAAC,GAAG,GAAS,CAAS;AAC/B,GAEa,IAAA,CACX,GACA,MACW;AACX,QAAM,IAA0B,EAAK,eAAe,SAAS,6BAA6B,IACpF,IAAkB,EAAK,eAAe;AAE5C,MAAI,MAAY,EAAmB,YAAa,QAAO;AAGvD,QAAM,IAAM,GAAG,CAAA;AACf,SAAQ,IAAkB,CAAA,KAAmB;AAC/C,GAEa,IAAA,CACX,GACA,OACuB;AAAA,EACvB,UAAU,EAAO,YAAY,EAAS;AAAA,EACtC,WAAW,EAAO,aAAa,EAAS;AAAA,EACxC,QAAQ,EAAO,WAAA,MAAiB;AAAA,EAChC,YAAY,EAAO,cAAc;AACnC,IAEa,IAAA,CAAuB,EAClC,eAAA,GACA,cAAA,GACA,UAAA,EAAA,MAC0E;AAC1E,QAAM,IAAoB,EAAa,SAAS,KAAY,EAAa,YAAY,YAG/E,IAAU,EAAa,SACvB,IAAc,IAAqB,GAAS,YAAY,IAAK;AAEnE,SAAI,IAKK;AAAA,IAAE,eAJO,KAAK,IACnB,KAAK,IAAI,GAAS,iBAAiB,GAAG,CAAC,GACvC,KAAK,IAAI,GAAG,IAAgB,CAAC,CAEP;AAAA,IAAS,aAAA;AAAA,EAAY,IAGxC;AAAA,IAAE,eAAe,KAAK,IAAI,GAAG,IAAgB,CAAC;AAAA,IAAG,aAAA;AAAA,EAAY;AACtE"}
|
|
1
|
+
{"version":3,"file":"utils.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/utils.ts"],"sourcesContent":["import { format, fromUnixTime } from 'date-fns'\n\nimport type {\n ActionDrawerState,\n DataSeries,\n DrilldownPayload,\n GlobalCopy,\n InsightsPayload,\n Subtitle,\n Transaction,\n} from '../../../core'\nimport { DATE_FORMATS_INTL } from '../../../core/constants'\nimport type {\n BarChartBlockData,\n DataSet,\n InsightsInstanceSlotData,\n} from '../../../core/types/InsightsInstanceSlotData'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport {\n buildChartData,\n buildDataSeries,\n type ChartDataSeriesItem,\n} from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport {\n layout,\n FALLBACK,\n DRILLDOWN_VARIANTS,\n DrillDownVariant,\n DrillDownVariantConfig,\n} from './layout'\nimport { TransactionHistoryBlock } from '../../../core/types/localization/InsightsFeedCopy'\n\ninterface DefaultSelectionProp {\n chartTabCount: number\n comparisonTabCount: number\n actionDrawer: ActionDrawerState\n beatGuid: string\n}\nexport const getDrillDownConfig = (variant?: string): DrillDownVariantConfig =>\n layout[variant as DrillDownVariant] ?? FALLBACK\n\n// The shaped chart inputs a drill-down needs, derived once from the beat's data_series. `dataSeries`\n// is the flat per-bar source (indexes the filterStrategy); `chartData` feeds the single-bar chart;\n// `comparisonBars` is reserved for the double-bar MR (empty until then).\nexport interface FlattenedDataSeries {\n dataSeries: ChartDataSeriesItem[]\n chartData: ReturnType<typeof buildChartData>\n comparisonBars: DataSet[]\n}\n\n/**\n * Shapes the beat's raw data_series into the chart inputs for the variant's top kind. This MR handles\n * the single-bar family (singleBar / upcomingBill); the double-bar and tabsOnly branches are stubbed\n * for the next MR so the call site is already wired.\n */\ninterface FlattenedDataSeriesInput {\n data: DataSeries | undefined\n ariaLabel: string\n top: DrillDownVariantConfig['top']\n // UpcomingBill has no data_series; it builds its bars from these instead.\n beatTransactions: Transaction[]\n payload: { date?: string; amount?: number } | undefined\n}\n\nexport const getFlattenedDataSeries = ({\n data,\n ariaLabel,\n top,\n beatTransactions,\n payload,\n}: FlattenedDataSeriesInput): FlattenedDataSeries => {\n // UpcomingBill has no backend data_series: synthesize the bars from the beat's recurring-bill\n // transactions + the projected bill, and label each bar by day (MONTH_DAY) since a bar is one bill.\n if (top === 'upcomingBill') {\n const dataSeries = buildUpcomingBillSeries(beatTransactions, payload)\n return {\n dataSeries,\n chartData: buildChartData(dataSeries, ariaLabel, DATE_FORMATS_INTL.MONTH_DAY),\n comparisonBars: [],\n }\n }\n\n // Single-bar family (THIS MR): the backend sends data_series newest-first, so normalize it\n // date-ascending here. chartData/tabs and the filter's dataSeries[selectedIndex] indexing both read\n // this one array, so they stay aligned and the last tab is the most recent month.\n const dataSeries = [...buildDataSeries(data)].sort((a, b) => {\n if (!a.date || !b.date) return 0\n\n return new Date(a.date).getTime() - new Date(b.date).getTime()\n })\n\n // NEXT MR — double bar: comparison beats build paired bars instead of chartData.\n // if (top === \"doubleBar\") {\n // return { dataSeries, chartData: [], comparisonBars: buildComparisonSeries(data, ariaLabel) };\n // }\n //\n // NEXT MR — tabsOnly: donut-drawer beats render no top chart.\n // if (top === \"tabsOnly\") {\n // return { dataSeries, chartData: [], comparisonBars: [] };\n // }\n\n return { dataSeries, chartData: buildChartData(dataSeries, ariaLabel), comparisonBars: [] }\n}\n\n// Sentinel guid for the synthesized projected bill. It intentionally matches no real store\n// transaction, so the projected tab's guid filter yields an empty list (projected-bar-only scope).\nexport const PROJECTED_BILL_GUID = 'TRN-projected-bill'\n\n// One bar in the UpcomingBill chart. `date` is 'yyyy-MM-dd' so buildChartData/parseISO can read both\n// historical unix timestamps and the ISO payload date after normalization here.\nexport interface UpcomingBillBar {\n date: string\n amount: number\n guid: string\n category_guid?: string\n}\n\nconst toUpcomingBillBar = (transaction: Transaction): UpcomingBillBar => ({\n date: format(fromUnixTime(transaction.date), 'yyyy-MM-dd'),\n amount: transaction.amount,\n guid: transaction.guid,\n category_guid: transaction.top_level_category_guid ?? transaction.category_guid,\n})\n\n/**\n * UpcomingBill has no data_series: build the bar series straight from the beat's recurring-bill\n * transactions plus the synthesized projected bill from payload (mirrors pulse's magicTransactions).\n * Historical bills are de-duped by date and each keeps its real transaction guid so the guid filter\n * finds it in the store; the projected bar (cloned category from the latest bill) carries the\n * PROJECTED_BILL_GUID sentinel. The result is sorted date-ascending so the projected bill lands last.\n */\nexport const buildUpcomingBillSeries = (\n transactions: Transaction[] = [],\n payload: { date?: string; amount?: number } | undefined,\n): UpcomingBillBar[] => {\n if (!transactions.length || payload?.date == null || payload?.amount == null) {\n return []\n }\n\n const sorted = [...transactions].sort((a, b) => a.date - b.date)\n\n const seenDates = new Set<number>()\n const history: UpcomingBillBar[] = []\n for (const transaction of sorted) {\n if (seenDates.has(transaction.date)) continue\n seenDates.add(transaction.date)\n history.push(toUpcomingBillBar(transaction))\n }\n\n const latestBill = sorted[sorted.length - 1]\n const projected: UpcomingBillBar = {\n date: payload.date,\n amount: payload.amount,\n guid: PROJECTED_BILL_GUID,\n category_guid: latestBill.top_level_category_guid ?? latestBill.category_guid,\n }\n\n return [...history, projected]\n}\n\nexport const getDrawerHeaderTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n): string => {\n const transactionHistoryTitle = copy.insights_feed?.general?.transaction_history_title ?? ''\n const drawerTitleCopy = copy.insights_feed?.transaction_history_block as TransactionHistoryBlock\n\n if (variant === DRILLDOWN_VARIANTS.TRANSACTION) return transactionHistoryTitle\n\n // Safely access the drawer title from transaction_history_block\n const key = `${variant}_drawer_title` as keyof TransactionHistoryBlock\n return (drawerTitleCopy?.[key] as string) ?? transactionHistoryTitle\n}\n\nexport const toStoreFilter = (\n filter: TransactionFilter,\n defaults: { allAccountGuids: string[]; displayedDateRange: { start: Date; end: Date } },\n): TransactionFilter => ({\n accounts: filter.accounts ?? defaults.allAccountGuids,\n dateRange: filter.dateRange ?? defaults.displayedDateRange,\n custom: filter.custom ?? (() => true),\n showSplits: filter.showSplits ?? false,\n})\n\nexport const getDefaultSelection = ({\n chartTabCount,\n actionDrawer,\n beatGuid,\n}: DefaultSelectionProp): { chartBarIndex: number; subTabIndex: number } => {\n const openedViaChartBar = actionDrawer.guid === beatGuid && actionDrawer.trigger === 'chartBar'\n\n // actionDrawer.context is an opaque `unknown` bag; narrow it to the shape the chart blocks write.\n const context = actionDrawer.context as DrilldownPayload | undefined\n const subTabIndex = openedViaChartBar ? (context?.tabIndex ?? 0) : 0\n\n if (openedViaChartBar) {\n const clamped = Math.min(\n Math.max(context?.chartBarIndex ?? 0, 0),\n Math.max(0, chartTabCount - 1),\n )\n return { chartBarIndex: clamped, subTabIndex }\n }\n\n return { chartBarIndex: Math.max(0, chartTabCount - 1), subTabIndex }\n}\n\n/** The drawer's facts: the generic slot facts plus the bar chart's average. */\nexport type DrillDownSlotData = InsightsInstanceSlotData & Pick<BarChartBlockData, 'average_amount'>\n\n/** The drawer's facts from a bar chart's `instance_slot.data`. */\nexport const toDrillDownSlotData = ({\n series,\n category_guid,\n average_amount,\n additional_data,\n}: BarChartBlockData): DrillDownSlotData => {\n const transactionGuids = buildDataSeries(series)\n .map(({ guid }) => guid)\n .filter((guid): guid is string => !!guid)\n\n return {\n data_series: series,\n category_guid,\n average_amount,\n legends: additional_data,\n transaction_guids: transactionGuids.length ? transactionGuids : undefined,\n }\n}\n\n/** The drawer's sub-heading: the merchant name and logo. */\nexport const resolveDrillDownSubHeader = (\n payload: Partial<InsightsPayload> | undefined,\n): Subtitle | undefined => {\n if (!payload) return undefined\n\n return {\n text: payload.subtitle ?? '',\n logo: { merchant_guid: payload.logo?.guid, category_guid: '' },\n }\n}\n"],"mappings":";;;;AAsCA,IAAa,IAAA,CAAsB,MACjC,EAAO,CAAA,KAAgC,GAyB5B,IAAA,CAA0B,EACrC,MAAA,GACA,WAAA,GACA,KAAA,GACA,kBAAA,GACA,SAAA,EAAA,MACmD;AAGnD,MAAI,MAAQ,gBAAgB;AAC1B,UAAM,IAAa,EAAwB,GAAkB,CAAO;AACpE,WAAO;AAAA,MACL,YAAA;AAAA,MACA,WAAW,EAAe,GAAY,GAAW,EAAkB,SAAS;AAAA,MAC5E,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAKA,QAAM,IAAa,CAAC,GAAG,EAAgB,CAAI,CAAC,EAAE,KAAA,CAAM,GAAG,MACjD,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAa,IAExB,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,IAAI,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,CAC9D;AAYD,SAAO;AAAA,IAAE,YAAA;AAAA,IAAY,WAAW,EAAe,GAAY,CAAS;AAAA,IAAG,gBAAgB,CAAC;AAAA,EAAE;AAC5F,GAIa,IAAsB,sBAW7B,IAAA,CAAqB,OAA+C;AAAA,EACxE,MAAM,EAAO,EAAa,EAAY,IAAI,GAAG,YAAY;AAAA,EACzD,QAAQ,EAAY;AAAA,EACpB,MAAM,EAAY;AAAA,EAClB,eAAe,EAAY,2BAA2B,EAAY;AACpE,IASa,IAAA,CACX,IAA8B,CAAC,GAC/B,MACsB;AACtB,MAAI,CAAC,EAAa,UAAU,GAAS,QAAQ,QAAQ,GAAS,UAAU,KACtE,QAAO,CAAC;AAGV,QAAM,IAAS,CAAC,GAAG,CAAY,EAAE,KAAA,CAAM,GAAG,MAAM,EAAE,OAAO,EAAE,IAAI,GAEzD,IAAY,oBAAI,IAAY,GAC5B,IAA6B,CAAC;AACpC,aAAW,KAAe;AACxB,IAAI,EAAU,IAAI,EAAY,IAAI,MAClC,EAAU,IAAI,EAAY,IAAI,GAC9B,EAAQ,KAAK,EAAkB,CAAW,CAAC;AAG7C,QAAM,IAAa,EAAO,EAAO,SAAS,CAAA,GACpC,IAA6B;AAAA,IACjC,MAAM,EAAQ;AAAA,IACd,QAAQ,EAAQ;AAAA,IAChB,MAAM;AAAA,IACN,eAAe,EAAW,2BAA2B,EAAW;AAAA,EAClE;AAEA,SAAO,CAAC,GAAG,GAAS,CAAS;AAC/B,GAEa,IAAA,CACX,GACA,MACW;AACX,QAAM,IAA0B,EAAK,eAAe,SAAS,6BAA6B,IACpF,IAAkB,EAAK,eAAe;AAE5C,MAAI,MAAY,EAAmB,YAAa,QAAO;AAGvD,QAAM,IAAM,GAAG,CAAA;AACf,SAAQ,IAAkB,CAAA,KAAmB;AAC/C,GAEa,IAAA,CACX,GACA,OACuB;AAAA,EACvB,UAAU,EAAO,YAAY,EAAS;AAAA,EACtC,WAAW,EAAO,aAAa,EAAS;AAAA,EACxC,QAAQ,EAAO,WAAA,MAAiB;AAAA,EAChC,YAAY,EAAO,cAAc;AACnC,IAEa,IAAA,CAAuB,EAClC,eAAA,GACA,cAAA,GACA,UAAA,EAAA,MAC0E;AAC1E,QAAM,IAAoB,EAAa,SAAS,KAAY,EAAa,YAAY,YAG/E,IAAU,EAAa,SACvB,IAAc,IAAqB,GAAS,YAAY,IAAK;AAEnE,SAAI,IAKK;AAAA,IAAE,eAJO,KAAK,IACnB,KAAK,IAAI,GAAS,iBAAiB,GAAG,CAAC,GACvC,KAAK,IAAI,GAAG,IAAgB,CAAC,CAEP;AAAA,IAAS,aAAA;AAAA,EAAY,IAGxC;AAAA,IAAE,eAAe,KAAK,IAAI,GAAG,IAAgB,CAAC;AAAA,IAAG,aAAA;AAAA,EAAY;AACtE,GAMa,IAAA,CAAuB,EAClC,QAAA,GACA,eAAA,GACA,gBAAA,GACA,iBAAA,EAAA,MAC0C;AAC1C,QAAM,IAAmB,EAAgB,CAAM,EAC5C,IAAA,CAAK,EAAE,MAAA,EAAA,MAAW,CAAI,EACtB,OAAA,CAAQ,MAAyB,CAAC,CAAC,CAAI;AAE1C,SAAO;AAAA,IACL,aAAa;AAAA,IACb,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,SAAS;AAAA,IACT,mBAAmB,EAAiB,SAAS,IAAmB;AAAA,EAClE;AACF,GAGa,IAAA,CACX,MACyB;AACzB,MAAK;AAEL,WAAO;AAAA,MACL,MAAM,EAAQ,YAAY;AAAA,MAC1B,MAAM;AAAA,QAAE,eAAe,EAAQ,MAAM;AAAA,QAAM,eAAe;AAAA,MAAG;AAAA,IAC/D;AACF"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { InsightsPayload } from '../../../../core';
|
|
2
|
+
interface BarchartBlockProps {
|
|
3
|
+
payload: InsightsPayload;
|
|
4
|
+
beatGuid?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const BarchartBlock: (({ payload, beatGuid }: BarchartBlockProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
4
7
|
displayName: string;
|
|
5
8
|
};
|
|
9
|
+
export {};
|
|
@@ -1,51 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { formatCurrency as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { BarChartV2 as
|
|
6
|
-
import { EmptyBarChart as
|
|
7
|
-
import { ANALYTICS_EVENTS_CONFIG as
|
|
8
|
-
import { useAnalyticsEvent as
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import { observer as
|
|
12
|
-
import { jsx as
|
|
13
|
-
import { useTheme as
|
|
14
|
-
var
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const _ = [o.general.monthly_amount, o.general.trend], [A, y] = s.length ? s.map((r) => r.label) : _;
|
|
18
|
-
return t.length ? /* @__PURE__ */ e(E, {
|
|
1
|
+
import { useGlobalUiStore as _, useInsightsV2Store as b } from "../../../../common/context/hooks.es.js";
|
|
2
|
+
import { formatCurrency as B } from "../../../../core/utils/NumberFormatting.es.js";
|
|
3
|
+
import y from "../../../../common/components/Loader.es.js";
|
|
4
|
+
import { BAR_ARIA_LABEL as I, barChartVariant as L, buildChartData as T, buildDataSeries as S } from "./utils.es.js";
|
|
5
|
+
import { BarChartV2 as v } from "../../../components/chartblocks/BarchartV2.es.js";
|
|
6
|
+
import { EmptyBarChart as E } from "../../../components/chartblocks/EmptyBarChart.es.js";
|
|
7
|
+
import { ANALYTICS_EVENTS_CONFIG as R } from "../../../analytics/analyticsEventsConfig.es.js";
|
|
8
|
+
import { useAnalyticsEvent as N } from "../../../analytics/useAnalyticsEvent.es.js";
|
|
9
|
+
import { actionBlocksKey as x } from "../../../mappings/actionBlocksKey.es.js";
|
|
10
|
+
import D from "react";
|
|
11
|
+
import { observer as O } from "mobx-react-lite";
|
|
12
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
13
|
+
import { useTheme as k } from "@mui/material/styles";
|
|
14
|
+
var P = O(({ payload: a, beatGuid: n = "" }) => {
|
|
15
|
+
const m = k(), { openActionDrawer: i } = b(), { isCopyLoaded: s } = _(), { instance_slot: o, widget_type: c } = a, { series: l, category_guid: f, average_amount: e = 0, additional_data: d = [] } = o.data ?? {}, [p, u] = d, t = T(S(l), I), [A] = D.useState(t.length - 1), { color: h } = L(o, f, m), C = N();
|
|
16
|
+
return s ? t.length ? /* @__PURE__ */ r(v, {
|
|
19
17
|
amounts: {
|
|
20
|
-
average:
|
|
21
|
-
formattedAverage:
|
|
18
|
+
average: e,
|
|
19
|
+
formattedAverage: B(e, "0,0")
|
|
22
20
|
},
|
|
23
|
-
color:
|
|
21
|
+
color: h,
|
|
24
22
|
data: t,
|
|
25
|
-
monthlyAmountLabel:
|
|
23
|
+
monthlyAmountLabel: p?.label ?? "",
|
|
26
24
|
margin: {
|
|
27
25
|
bottom: 8,
|
|
28
26
|
left: 16,
|
|
29
27
|
right: 16,
|
|
30
28
|
top: 16
|
|
31
29
|
},
|
|
32
|
-
onBarClick: (
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
guid:
|
|
30
|
+
onBarClick: (g) => {
|
|
31
|
+
if (c !== "full") return !1;
|
|
32
|
+
C(R.CHART_BAR_CLICKED), i({
|
|
33
|
+
guid: n,
|
|
36
34
|
trigger: "chartBar",
|
|
37
35
|
context: {
|
|
38
|
-
chartBarIndex:
|
|
39
|
-
block:
|
|
36
|
+
chartBarIndex: g,
|
|
37
|
+
block: x.TRANSCATION_HISTORY_ACTION_BLOCK
|
|
40
38
|
}
|
|
41
39
|
});
|
|
42
40
|
},
|
|
43
|
-
selectedTabIndex:
|
|
44
|
-
trendAmountLabel:
|
|
45
|
-
}) : /* @__PURE__ */
|
|
41
|
+
selectedTabIndex: A,
|
|
42
|
+
trendAmountLabel: u?.label ?? ""
|
|
43
|
+
}) : /* @__PURE__ */ r(E, {}) : /* @__PURE__ */ r(y, {});
|
|
46
44
|
});
|
|
47
45
|
export {
|
|
48
|
-
|
|
46
|
+
P as BarchartBlock
|
|
49
47
|
};
|
|
50
48
|
|
|
51
49
|
//# sourceMappingURL=BarchartBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarchartBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.tsx"],"sourcesContent":["import React from 'react'\nimport { useTheme } from '@mui/material/styles'\nimport { observer } from 'mobx-react-lite'\n\nimport {
|
|
1
|
+
{"version":3,"file":"BarchartBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.tsx"],"sourcesContent":["import React from 'react'\nimport { useTheme } from '@mui/material/styles'\nimport { observer } from 'mobx-react-lite'\n\nimport { formatCurrency, Loader, useGlobalUiStore, useInsightsV2Store } from '../../../../common'\nimport type { DrilldownPayload, InsightsPayload } from '../../../../core'\nimport type { BarChartBlockData } from '../../../../core/types/InsightsInstanceSlotData'\n\nimport { BarChartV2 } from '../../../components/chartblocks/BarchartV2'\nimport { EmptyBarChart } from '../../../components/chartblocks/EmptyBarChart'\n\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../../analytics'\n\nimport { BAR_ARIA_LABEL, barChartVariant, buildChartData, buildDataSeries } from './utils'\nimport { actionBlocksKey } from '../../../mappings/actionBlocksKey'\n\ninterface BarchartBlockProps {\n payload: InsightsPayload\n beatGuid?: string\n}\n\nexport const BarchartBlock = observer(({ payload, beatGuid = '' }: BarchartBlockProps) => {\n const theme = useTheme()\n const { openActionDrawer } = useInsightsV2Store()\n const { isCopyLoaded } = useGlobalUiStore()\n const { instance_slot, widget_type } = payload\n const {\n series,\n category_guid,\n average_amount = 0,\n additional_data = [],\n } = (instance_slot.data ?? {}) as BarChartBlockData\n const [monthlyAmount, trend] = additional_data\n const chartData = buildChartData(buildDataSeries(series), BAR_ARIA_LABEL)\n const [selectedTabIndex] = React.useState(chartData.length - 1)\n const { color } = barChartVariant(instance_slot, category_guid, theme)\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n if (!isCopyLoaded) {\n return <Loader />\n }\n\n return chartData.length ? (\n <BarChartV2\n amounts={{\n average: average_amount,\n formattedAverage: formatCurrency(average_amount, '0,0'),\n }}\n color={color}\n data={chartData}\n monthlyAmountLabel={monthlyAmount?.label ?? ''}\n margin={{\n bottom: 8,\n left: 16,\n right: 16,\n top: 16,\n }}\n onBarClick={(index) => {\n if (widget_type !== 'full') return false\n\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.CHART_BAR_CLICKED)\n\n openActionDrawer({\n guid: beatGuid,\n trigger: 'chartBar',\n context: {\n chartBarIndex: index,\n block: actionBlocksKey.TRANSCATION_HISTORY_ACTION_BLOCK,\n } satisfies DrilldownPayload,\n })\n }}\n selectedTabIndex={selectedTabIndex}\n trendAmountLabel={trend?.label ?? ''}\n />\n ) : (\n <EmptyBarChart />\n )\n})\n"],"mappings":";;;;;;;;;;;;;AAqBA,IAAa,IAAgB,EAAA,CAAU,EAAE,SAAA,GAAS,UAAA,IAAW,GAAA,MAA6B;AACxF,QAAM,IAAQ,EAAS,GACjB,EAAE,kBAAA,EAAA,IAAqB,EAAmB,GAC1C,EAAE,cAAA,EAAA,IAAiB,EAAiB,GACpC,EAAE,eAAA,GAAe,aAAA,EAAA,IAAgB,GACjC,EACJ,QAAA,GACA,eAAA,GACA,gBAAA,IAAiB,GACjB,iBAAA,IAAkB,CAAC,EAAA,IAChB,EAAc,QAAQ,CAAC,GACtB,CAAC,GAAe,CAAA,IAAS,GACzB,IAAY,EAAe,EAAgB,CAAM,GAAG,CAAc,GAClE,CAAC,CAAA,IAAoB,EAAM,SAAS,EAAU,SAAS,CAAC,GACxD,EAAE,OAAA,EAAA,IAAU,EAAgB,GAAe,GAAe,CAAK,GAC/D,IAAqB,EAAkB;AAE7C,SAAK,IAIE,EAAU,SACf,gBAAA,EAAC,GAAD;AAAA,IACE,SAAS;AAAA,MACP,SAAS;AAAA,MACT,kBAAkB,EAAe,GAAgB,KAAK;AAAA,IACxD;AAAA,IACO,OAAA;AAAA,IACP,MAAM;AAAA,IACN,oBAAoB,GAAe,SAAS;AAAA,IAC5C,QAAQ;AAAA,MACN,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,MACP,KAAK;AAAA,IACP;AAAA,IACA,YAAA,CAAa,MAAU;AACrB,UAAI,MAAgB,OAAQ,QAAO;AAEnC,MAAA,EAAmB,EAAwB,iBAAiB,GAE5D,EAAiB;AAAA,QACf,MAAM;AAAA,QACN,SAAS;AAAA,QACT,SAAS;AAAA,UACP,eAAe;AAAA,UACf,OAAO,EAAgB;AAAA,QACzB;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACkB,kBAAA;AAAA,IAClB,kBAAkB,GAAO,SAAS;AAAA,EACnC,CAAA,IAED,gBAAA,EAAC,GAAD,CAAgB,CAAA,IApCT,gBAAA,EAAC,GAAD,CAAS,CAAA;AAsCpB,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Theme } from '@mui/material/styles';
|
|
2
2
|
import { formatDate } from '../../../../core/constants';
|
|
3
3
|
import { DataSeries, InstanceSlot } from '../../../../core';
|
|
4
|
-
import { InsightsInstanceSlotData } from '../../../../core/types/InsightsInstanceSlotData';
|
|
5
4
|
export declare const BAR_CHART_VARIANTS: {
|
|
6
5
|
CATEGORY_COLOR: string;
|
|
7
6
|
ACCOUNT_BALANCE: string;
|
|
@@ -16,6 +15,8 @@ export interface ChartDataSeriesItem {
|
|
|
16
15
|
localized_label?: string;
|
|
17
16
|
category_guid?: string;
|
|
18
17
|
}
|
|
18
|
+
/** Per-bar aria label, built in the frontend: "{month}: {amount}" (buildDynamicCopy placeholders). */
|
|
19
|
+
export declare const BAR_ARIA_LABEL = "_1{month}: _2{amount}";
|
|
19
20
|
export declare const buildDataSeries: (data: DataSeries | undefined) => ChartDataSeriesItem[];
|
|
20
21
|
export declare const buildChartData: (dataSeries: ChartDataSeriesItem[], ariaLabel: string, dateFormat?: Parameters<typeof formatDate>[1]) => {
|
|
21
22
|
ariaLabel: string;
|
|
@@ -24,6 +25,6 @@ export declare const buildChartData: (dataSeries: ChartDataSeriesItem[], ariaLab
|
|
|
24
25
|
value: number;
|
|
25
26
|
formattedAmount: string;
|
|
26
27
|
}[];
|
|
27
|
-
export declare const barChartVariant: (instanceSlot: InstanceSlot,
|
|
28
|
+
export declare const barChartVariant: (instanceSlot: InstanceSlot, categoryGuid: string | undefined, theme: Theme) => {
|
|
28
29
|
color: string;
|
|
29
30
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { buildDynamicCopy as i } from "../../../../core/utils/Localization.es.js";
|
|
2
|
-
import { DATE_FORMATS_INTL as u, formatDate as
|
|
2
|
+
import { DATE_FORMATS_INTL as u, formatDate as _ } from "../../../../core/constants/DateFormats.es.js";
|
|
3
3
|
import { formatCurrency as m } from "../../../../core/utils/NumberFormatting.es.js";
|
|
4
|
-
import { getCategoryColor as
|
|
5
|
-
import { getLayoutConfig as
|
|
6
|
-
import { parseISO as
|
|
7
|
-
var
|
|
4
|
+
import { getCategoryColor as A } from "../../../../core/utils/CategoryUtil.es.js";
|
|
5
|
+
import { getLayoutConfig as C } from "./layout.es.js";
|
|
6
|
+
import { parseISO as l } from "date-fns/parseISO";
|
|
7
|
+
var p = {
|
|
8
8
|
CATEGORY_COLOR: "category_color",
|
|
9
9
|
ACCOUNT_BALANCE: "account_balance",
|
|
10
10
|
MONTHLY_SPEND_COMPARISON: "monthly_spend_comparison"
|
|
11
|
-
},
|
|
11
|
+
}, d = "_1{month}: _2{amount}", L = (a) => a ? a.data ? a.data.map((o) => {
|
|
12
12
|
const e = {};
|
|
13
13
|
return a.names?.map((r, t) => {
|
|
14
14
|
e[r] = o[t];
|
|
15
15
|
}), e;
|
|
16
|
-
}) : [] : [],
|
|
17
|
-
const t = r.date ?
|
|
16
|
+
}) : [] : [], b = (a, o, e = u.MONTH_SHORT) => [...a].sort((r, t) => !r.date || !t.date ? 0 : new Date(r.date).getTime() - new Date(t.date).getTime()).map((r) => {
|
|
17
|
+
const t = r.date ? _(l(r.date), e) : r.label ?? "", n = r.amount ?? 0;
|
|
18
18
|
return {
|
|
19
19
|
ariaLabel: i(o, t, m(n, "0.00")),
|
|
20
20
|
date: r.date ?? null,
|
|
@@ -22,15 +22,16 @@ var l = {
|
|
|
22
22
|
value: n,
|
|
23
23
|
formattedAmount: m(n, "0,0")
|
|
24
24
|
};
|
|
25
|
-
}),
|
|
26
|
-
const { variant: r } = a, t =
|
|
27
|
-
return r ===
|
|
25
|
+
}), y = (a, o, e) => {
|
|
26
|
+
const { variant: r } = a, t = C(e);
|
|
27
|
+
return r === p.CATEGORY_COLOR && o ? { color: A(o, e) } : { color: t[r]?.color ?? e.palette.primary.main };
|
|
28
28
|
};
|
|
29
29
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
y as
|
|
33
|
-
|
|
30
|
+
d as BAR_ARIA_LABEL,
|
|
31
|
+
p as BAR_CHART_VARIANTS,
|
|
32
|
+
y as barChartVariant,
|
|
33
|
+
b as buildChartData,
|
|
34
|
+
L as buildDataSeries
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
//# sourceMappingURL=utils.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.ts"],"sourcesContent":["import { type Theme } from '@mui/material/styles'\n\nimport { parseISO } from 'date-fns/parseISO'\n\nimport { getCategoryColor } from '../../../../core/utils/CategoryUtil'\nimport { buildDynamicCopy } from '../../../../core/utils/Localization'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../../core/constants'\nimport type { DataSeries, InstanceSlot } from '../../../../core'\nimport
|
|
1
|
+
{"version":3,"file":"utils.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.ts"],"sourcesContent":["import { type Theme } from '@mui/material/styles'\n\nimport { parseISO } from 'date-fns/parseISO'\n\nimport { getCategoryColor } from '../../../../core/utils/CategoryUtil'\nimport { buildDynamicCopy } from '../../../../core/utils/Localization'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../../core/constants'\nimport type { DataSeries, InstanceSlot } from '../../../../core'\nimport { getLayoutConfig } from './layout'\n\nexport const BAR_CHART_VARIANTS = {\n CATEGORY_COLOR: 'category_color',\n ACCOUNT_BALANCE: 'account_balance',\n MONTHLY_SPEND_COMPARISON: 'monthly_spend_comparison',\n}\n\nexport interface ChartDataSeriesItem {\n date?: string\n amount?: number\n guid?: string\n label?: string\n aggregated_guids?: string[]\n localized_label?: string\n category_guid?: string\n}\n\n/** Per-bar aria label, built in the frontend: \"{month}: {amount}\" (buildDynamicCopy placeholders). */\nexport const BAR_ARIA_LABEL = '_1{month}: _2{amount}'\n\nexport const buildDataSeries = (data: DataSeries | undefined): ChartDataSeriesItem[] => {\n if (!data) {\n return []\n }\n\n if (data.data) {\n return data.data.map((d) => {\n const item: any = {}\n\n data.names?.map((name, index) => {\n item[name] = d[index]\n })\n return item\n })\n } else {\n return []\n }\n}\n\nexport const buildChartData = (\n dataSeries: ChartDataSeriesItem[],\n ariaLabel: string,\n dateFormat: Parameters<typeof formatDate>[1] = DATE_FORMATS_INTL.MONTH_SHORT,\n) => {\n const data = [...dataSeries]\n .sort((a, b) => {\n if (!a.date || !b.date) return 0\n\n return new Date(a.date).getTime() - new Date(b.date).getTime()\n })\n .map((total) => {\n const label = total.date ? formatDate(parseISO(total.date), dateFormat) : (total.label ?? '')\n const amount = total.amount ?? 0\n\n return {\n ariaLabel: buildDynamicCopy(ariaLabel, label, formatCurrency(amount, '0.00')) as string,\n date: total.date ?? null,\n label,\n value: amount,\n formattedAmount: formatCurrency(amount, '0,0'),\n }\n })\n\n return data\n}\n\nexport const barChartVariant = (\n instanceSlot: InstanceSlot,\n categoryGuid: string | undefined,\n theme: Theme,\n) => {\n const { variant } = instanceSlot\n const barChartLayout = getLayoutConfig(theme)\n if (variant === BAR_CHART_VARIANTS.CATEGORY_COLOR && categoryGuid) {\n return { color: getCategoryColor(categoryGuid, theme) }\n }\n return {\n color:\n barChartLayout[variant as keyof typeof barChartLayout]?.color ?? theme.palette.primary.main,\n }\n}\n"],"mappings":";;;;;;AAWA,IAAa,IAAqB;AAAA,EAChC,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,0BAA0B;AAC5B,GAaa,IAAiB,yBAEjB,IAAA,CAAmB,MACzB,IAID,EAAK,OACA,EAAK,KAAK,IAAA,CAAK,MAAM;AAC1B,QAAM,IAAY,CAAC;AAEnB,SAAA,EAAK,OAAO,IAAA,CAAK,GAAM,MAAU;AAC/B,IAAA,EAAK,CAAA,IAAQ,EAAE,CAAA;AAAA,EACjB,CAAC,GACM;AACT,CAAC,IAEM,CAAC,IAbD,CAAC,GAiBC,IAAA,CACX,GACA,GACA,IAA+C,EAAkB,gBAEpD,CAAC,GAAG,CAAU,EACxB,KAAA,CAAM,GAAG,MACJ,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAa,IAExB,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,IAAI,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,CAC9D,EACA,IAAA,CAAK,MAAU;AACd,QAAM,IAAQ,EAAM,OAAO,EAAW,EAAS,EAAM,IAAI,GAAG,CAAU,IAAK,EAAM,SAAS,IACpF,IAAS,EAAM,UAAU;AAE/B,SAAO;AAAA,IACL,WAAW,EAAiB,GAAW,GAAO,EAAe,GAAQ,MAAM,CAAC;AAAA,IAC5E,MAAM,EAAM,QAAQ;AAAA,IACpB,OAAA;AAAA,IACA,OAAO;AAAA,IACP,iBAAiB,EAAe,GAAQ,KAAK;AAAA,EAC/C;AACF,CAEK,GAGI,IAAA,CACX,GACA,GACA,MACG;AACH,QAAM,EAAE,SAAA,EAAA,IAAY,GACd,IAAiB,EAAgB,CAAK;AAC5C,SAAI,MAAY,EAAmB,kBAAkB,IAC5C,EAAE,OAAO,EAAiB,GAAc,CAAK,EAAE,IAEjD,EACL,OACE,EAAe,CAAA,GAAyC,SAAS,EAAM,QAAQ,QAAQ,KAC3F;AACF"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import l from "../../../../common/components/IconBacking.es.js";
|
|
2
|
-
import a from "
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
2
|
+
import { resolveVariantConfig as a } from "../../resolveVariantConfig.es.js";
|
|
3
|
+
import { getLayoutConfig as m } from "./layout.es.js";
|
|
4
|
+
import u from "../../../components/LogoFromGuid.es.js";
|
|
5
5
|
import { InstitutionLogo as g } from "@mxenabled/mxui";
|
|
6
6
|
import { Icon as e } from "@mxenabled/mx-icons";
|
|
7
7
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
8
|
import { useTheme as f } from "@mui/material/styles";
|
|
9
9
|
import { Stack as t } from "@mui/material";
|
|
10
10
|
var k = ({ slot: i, variant: c, logo: n }) => {
|
|
11
|
-
const d = f(), r = m(
|
|
11
|
+
const d = f(), r = a(m(d), c, "default", "AccountBlock");
|
|
12
12
|
return /^INS-[A-Za-z0-9-]+$/.test(n?.guid ?? "") ? /* @__PURE__ */ s(t, {
|
|
13
13
|
sx: {
|
|
14
14
|
alignItems: "center",
|
|
15
15
|
flexDirection: "row",
|
|
16
16
|
position: "relative"
|
|
17
17
|
},
|
|
18
|
-
children: [/* @__PURE__ */ o(
|
|
18
|
+
children: [/* @__PURE__ */ o(u, {
|
|
19
19
|
logo: n,
|
|
20
20
|
size: 48
|
|
21
21
|
}), r.badge && /* @__PURE__ */ o(l, {
|
|
@@ -2,9 +2,9 @@ import { DATE_FORMATS_INTL as R, formatDate as k } from "../../../../core/consta
|
|
|
2
2
|
import { useGlobalCopyStore as F } from "../../../../common/context/hooks.es.js";
|
|
3
3
|
import { slot as f } from "../../../../core/types/Insights.es.js";
|
|
4
4
|
import { formatCurrency as i, formatPercentage as N } from "../../../../core/utils/NumberFormatting.es.js";
|
|
5
|
-
import P from "../../../components/
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
5
|
+
import { DepositLogo as P } from "../../../components/ComponentBlocks/DepositLogo.es.js";
|
|
6
|
+
import { resolveVariantConfig as B } from "../../resolveVariantConfig.es.js";
|
|
7
|
+
import Y from "../../../components/LogoFromGuid.es.js";
|
|
8
8
|
import G from "../../../components/DebtPayoffCard.es.js";
|
|
9
9
|
import j from "../../../components/TransactionListCard.es.js";
|
|
10
10
|
import { parseDueDate as I } from "../UpcomingBillBlock/UpcomingBillBlock.es.js";
|
|
@@ -17,13 +17,13 @@ var U = 32, W = /* @__PURE__ */ new Set([
|
|
|
17
17
|
"credit_card",
|
|
18
18
|
"creditcard"
|
|
19
19
|
]), Z = (t) => W.has((t ?? "").trim().toLowerCase()) ? "credit_card" : "account_balance", $ = (t) => typeof t == "object" && t !== null && typeof t.primary_text == "string", q = (t) => !!t?.balance_label && !!t.payoff_date_label && !!t.monthly_payment_label && !!t.interest_rate_label, ct = ({ payload: t }) => {
|
|
20
|
-
const T = z(), o = F().insights_feed?.debts_block, { instance_slot: u } = t, { data: s, variant: A } = u, _ =
|
|
20
|
+
const T = z(), o = F().insights_feed?.debts_block, { instance_slot: u } = t, { data: s, variant: A } = u, _ = B(H, A, M.ProjectedPayoff, "DebtsBlock"), p = _.card === "summary", e = q(o) ? o : void 0, m = o?.total_balance_label, b = p ? !!m : !!e;
|
|
21
21
|
if (V.useEffect(() => {
|
|
22
22
|
b || console.warn(`debts_block: ${o ? "copy incomplete" : "copy namespace missing"}; rendering without its labelled figures`);
|
|
23
23
|
}, [o, b]), p) {
|
|
24
24
|
const r = f(s, "series"), O = (Array.isArray(r) ? r : []).filter($).map((a) => ({
|
|
25
25
|
amount: typeof a.amount == "number" ? i(a.amount, "0,0.00") : "",
|
|
26
|
-
leading: /* @__PURE__ */ l(
|
|
26
|
+
leading: /* @__PURE__ */ l(Y, {
|
|
27
27
|
logo: a.logo,
|
|
28
28
|
size: U
|
|
29
29
|
}),
|
|
@@ -59,7 +59,7 @@ var U = 32, W = /* @__PURE__ */ new Set([
|
|
|
59
59
|
..._.style,
|
|
60
60
|
balance: D ? i(y, "0,0.00") : void 0,
|
|
61
61
|
balanceLabel: D ? e.balance_label : void 0,
|
|
62
|
-
logo: /* @__PURE__ */ l(
|
|
62
|
+
logo: /* @__PURE__ */ l(P, {
|
|
63
63
|
iconName: Z(d),
|
|
64
64
|
institutionGuid: S ?? "",
|
|
65
65
|
institutionName: x ?? ""
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useCategoryStore as p } from "../../../../common/context/hooks.es.js";
|
|
2
2
|
import { slot as c } from "../../../../core/types/Insights.es.js";
|
|
3
3
|
import { formatCurrency as _ } from "../../../../core/utils/NumberFormatting.es.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { resolveVariantConfig as y } from "../../resolveVariantConfig.es.js";
|
|
5
|
+
import { logoFromRef as h } from "../../../components/shared/EntityLogo.es.js";
|
|
6
6
|
import x from "../../../components/TransactionListCard.es.js";
|
|
7
7
|
import { getLayoutConfig as v, transactionBlockVariant as C } from "./layout.es.js";
|
|
8
8
|
import { observer as I } from "mobx-react-lite";
|
|
@@ -12,7 +12,7 @@ import { jsx as o } from "react/jsx-runtime";
|
|
|
12
12
|
import { useTheme as b } from "@mui/material/styles";
|
|
13
13
|
import u from "@mui/material/Box";
|
|
14
14
|
var r = 32, k = Math.round(r * 0.625), z = (n, a) => {
|
|
15
|
-
const t =
|
|
15
|
+
const t = h(n.logo, n.primary_text);
|
|
16
16
|
if (t) {
|
|
17
17
|
if (t.logo_name) return /* @__PURE__ */ o(u, {
|
|
18
18
|
sx: {
|
|
@@ -54,7 +54,7 @@ var r = 32, k = Math.round(r * 0.625), z = (n, a) => {
|
|
|
54
54
|
}, F = I(({ payload: n }) => {
|
|
55
55
|
const a = b(), { getTopLevelCategoryGuid: t } = p(), { data: e, variant: d } = n.instance_slot, s = c(e, "series"), m = c(e, "header_text");
|
|
56
56
|
if (!Array.isArray(s) || !s.length) return null;
|
|
57
|
-
const { background: g, cardVariant: l, showHeader: f } =
|
|
57
|
+
const { background: g, cardVariant: l, showHeader: f } = y(v(a), d, C.NoHeader, "TransactionBlock");
|
|
58
58
|
return /* @__PURE__ */ o(x, {
|
|
59
59
|
background: g,
|
|
60
60
|
header: f && typeof m == "string" ? m : void 0,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { formatCurrency as u } from "../../../../core/utils/NumberFormatting.es.js";
|
|
2
|
-
import
|
|
3
|
-
import g from "../../../components/
|
|
4
|
-
import D from "
|
|
2
|
+
import d from "../../../components/LogoFromGuid.es.js";
|
|
3
|
+
import g from "../../../components/UpcomingBillCard.es.js";
|
|
4
|
+
import { createVariantBlock as D } from "../../createVariantBlock.es.js";
|
|
5
5
|
import { upcomingBillVariant as p } from "./layout.es.js";
|
|
6
6
|
import f from "@mui/material/Stack";
|
|
7
7
|
import { jsx as l } from "react/jsx-runtime";
|
|
@@ -45,10 +45,10 @@ var s = [
|
|
|
45
45
|
const { instance_slot: a } = t, { amount: e, due_date: o, merchant_guid: n, merchant_name: r } = a, i = o ? h(o) : null, c = i ? v(i) : y();
|
|
46
46
|
return /* @__PURE__ */ l(f, {
|
|
47
47
|
sx: { px: 16 },
|
|
48
|
-
children: /* @__PURE__ */ l(
|
|
48
|
+
children: /* @__PURE__ */ l(g, {
|
|
49
49
|
amount: u(e ?? 0, "0,0.00"),
|
|
50
50
|
days: c,
|
|
51
|
-
logo: n ? /* @__PURE__ */ l(
|
|
51
|
+
logo: n ? /* @__PURE__ */ l(d, {
|
|
52
52
|
logo: {
|
|
53
53
|
alt: r ?? "",
|
|
54
54
|
guid: n
|
|
@@ -65,7 +65,7 @@ var s = [
|
|
|
65
65
|
payload: t,
|
|
66
66
|
variant: e
|
|
67
67
|
});
|
|
68
|
-
}, B =
|
|
68
|
+
}, B = D({
|
|
69
69
|
variants: { [p.ProjectedBillPayment]: m },
|
|
70
70
|
fallback: m,
|
|
71
71
|
name: "UpcomingBillBlock"
|