@mx-cartographer/experiences 9.7.87 → 9.7.88-alpha-usp-ram1
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 +6 -0
- package/dist/core/stores/InsightsV2Store.d.ts +2 -2
- package/dist/core/stores/InsightsV2Store.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js +80 -70
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +44 -43
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.d.ts +2 -0
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js +1 -0
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/components/TransactionListCard.es.js +32 -28
- package/dist/insights-v2/components/TransactionListCard.es.js.map +1 -1
- package/dist/insights-v2/components/shared/StatusSnackbar.d.ts +11 -1
- package/dist/insights-v2/components/shared/StatusSnackbar.es.js +31 -11
- package/dist/insights-v2/components/shared/StatusSnackbar.es.js.map +1 -1
- package/dist/insights-v2/components/shared/elevation.d.ts +16 -0
- package/dist/insights-v2/components/shared/elevation.es.js +15 -0
- package/dist/insights-v2/components/shared/elevation.es.js.map +1 -0
- package/dist/insights-v2/ctaActions/ctaConfig.es.js +16 -8
- package/dist/insights-v2/ctaActions/ctaConfig.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/index.d.ts +2 -2
- package/dist/insights-v2/ctaActions/runCtaAction.d.ts +7 -1
- package/dist/insights-v2/ctaActions/runCtaAction.es.js +110 -68
- package/dist/insights-v2/ctaActions/runCtaAction.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/subscriptionAnswer.es.js +53 -49
- package/dist/insights-v2/ctaActions/subscriptionAnswer.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/types.d.ts +6 -2
- package/dist/insights-v2/ctaActions/useCtaAction.es.js.map +1 -1
- package/dist/insights-v2/index.d.ts +2 -2
- package/dist/insights-v2/index.es.js +132 -130
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [9.7.88] - 11-03-2026
|
|
2
|
+
|
|
3
|
+
- **ADDED** - Insights 2.0 `runInDescriptionCta({ beat, stores, hostActions })` for a pinned beat's auto-open (the external flow): runs the micro card action's `action_key` step and opens its block per the runner's rules, with no press analytics, first click or post message. A presenter step acts only while unanswered (an answered subscription opens nothing; its card shows the status), and `atomic_flow` runs with no drawer. It never rejects (failures are reported) and leaves a pending press or an open drawer alone. pulse calls it from `useOpenPinnedInsightAction` (WEC-2017)
|
|
4
|
+
- **FIXED** - An `inDescriptionCta` drawer opener can pass the link's `action_key`, so a survey opened that way saves through its step (Subscription Detected's `user_response`) instead of beat feedback (WEC-2017)
|
|
5
|
+
- **CHANGED** - A CTA step's `prepare` may return a promise; the subscription step shares one in-flight repeating-transactions load (WEC-2017)
|
|
6
|
+
|
|
1
7
|
## [9.7.87] - 11-03-2026
|
|
2
8
|
|
|
3
9
|
- **ADDED** - Storybook QA pages showing every supported size and state for 18 more Insights 2.0 insights, from ditto, tupac and mrs_content, with shared fixture helpers in `mock/BlockBeatsData/widgetBeats.ts` (MEW2-3424)
|
|
@@ -27,8 +27,8 @@ export interface ActionDrawerState {
|
|
|
27
27
|
cta?: DrawerCta;
|
|
28
28
|
}
|
|
29
29
|
export declare const CLOSED_ACTION_DRAWER: ActionDrawerState;
|
|
30
|
-
/**
|
|
31
|
-
export type DrawerCta = Pick<InDescriptionCTA, 'block' | 'variant'>;
|
|
30
|
+
/** What an `inDescriptionCta` opener picks: the block, its variant and step (`action_key`). */
|
|
31
|
+
export type DrawerCta = Pick<InDescriptionCTA, 'block' | 'variant' | 'action_key'>;
|
|
32
32
|
type OpenActionDrawerArgs = {
|
|
33
33
|
guid: string;
|
|
34
34
|
context?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InsightsV2Store.es.js","names":[],"sources":["../../../src/core/stores/InsightsV2Store.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport type { InDescriptionCTA } from '../types/Insights'\n\nimport type { GlobalStore } from './GlobalStore'\n\n// `inDescriptionCta`: the link inside a card's description (`insights_payload.in_description_cta`).\nexport type ActionDrawerTrigger = 'primaryCta' | 'secondaryCta' | 'chartBar' | 'inDescriptionCta'\n\nexport interface ActionDrawerState {\n isDrawerOpen: boolean\n trigger: ActionDrawerTrigger\n guid: string\n /**\n * Block-specific drilldown data for the current drawer SESSION, opaque to the\n * store. Each action block defines and reads its own shape (via\n * useActionContext<T>()). Chart drilldowns put `{ chartBarIndex, tabIndex }`\n * here; CTAs carry none.\n *\n * This is an accumulating bag, not a single owner's value: a nested drawer\n * (e.g. TransactionDetailsBlock opened from a row inside TransactionHistory\n * Block) adds its own key via `setActionContext` ON TOP of whatever the outer\n * drawer already put here, so the outer block's own context survives while the\n * nested block is open. It resets to a clean slate only when a NEW drawer\n * session starts (`openActionDrawer`/`openCtaDrawer`, which fully replace the\n * envelope) — not on every `setActionContext` call.\n */\n context: unknown\n /**\n * Block and variant an `inDescriptionCta` drawer runs; without it the beat's own\n * `in_description_cta` is used. Replaced on each open, kept through close like `trigger`.\n */\n cta?: DrawerCta\n}\n\nexport const CLOSED_ACTION_DRAWER: ActionDrawerState = {\n isDrawerOpen: false,\n trigger: 'primaryCta',\n guid: '',\n context: undefined,\n cta: undefined,\n}\n\n/**
|
|
1
|
+
{"version":3,"file":"InsightsV2Store.es.js","names":[],"sources":["../../../src/core/stores/InsightsV2Store.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport type { InDescriptionCTA } from '../types/Insights'\n\nimport type { GlobalStore } from './GlobalStore'\n\n// `inDescriptionCta`: the link inside a card's description (`insights_payload.in_description_cta`).\nexport type ActionDrawerTrigger = 'primaryCta' | 'secondaryCta' | 'chartBar' | 'inDescriptionCta'\n\nexport interface ActionDrawerState {\n isDrawerOpen: boolean\n trigger: ActionDrawerTrigger\n guid: string\n /**\n * Block-specific drilldown data for the current drawer SESSION, opaque to the\n * store. Each action block defines and reads its own shape (via\n * useActionContext<T>()). Chart drilldowns put `{ chartBarIndex, tabIndex }`\n * here; CTAs carry none.\n *\n * This is an accumulating bag, not a single owner's value: a nested drawer\n * (e.g. TransactionDetailsBlock opened from a row inside TransactionHistory\n * Block) adds its own key via `setActionContext` ON TOP of whatever the outer\n * drawer already put here, so the outer block's own context survives while the\n * nested block is open. It resets to a clean slate only when a NEW drawer\n * session starts (`openActionDrawer`/`openCtaDrawer`, which fully replace the\n * envelope) — not on every `setActionContext` call.\n */\n context: unknown\n /**\n * Block and variant an `inDescriptionCta` drawer runs; without it the beat's own\n * `in_description_cta` is used. Replaced on each open, kept through close like `trigger`.\n */\n cta?: DrawerCta\n}\n\nexport const CLOSED_ACTION_DRAWER: ActionDrawerState = {\n isDrawerOpen: false,\n trigger: 'primaryCta',\n guid: '',\n context: undefined,\n cta: undefined,\n}\n\n/** What an `inDescriptionCta` opener picks: the block, its variant and step (`action_key`). */\nexport type DrawerCta = Pick<InDescriptionCTA, 'block' | 'variant' | 'action_key'>\n\n// Only the `inDescriptionCta` trigger accepts a `cta`.\ntype OpenActionDrawerArgs = {\n guid: string\n context?: unknown\n} & (\n | { trigger: 'inDescriptionCta'; cta?: DrawerCta }\n | { trigger: Exclude<ActionDrawerTrigger, 'inDescriptionCta'>; cta?: never }\n)\n\n/** Lifecycle of a beat's CTA action (see insights-v2/ctaActions), keyed by beat guid. */\nexport type CtaStatus = 'pending' | 'done' | 'error'\n\n/**\n * UI state shared across the insights-v2 widget tree. Owns the action drawer so\n * cards, charts, and action blocks coordinate through the store instead of prop\n * drilling. The drawer state is a fixed envelope (isDrawerOpen/guid/trigger) plus\n * an opaque `context` bag, so per-block drilldown data never leaks into this shape.\n */\nexport class InsightsV2Store {\n globalStore: GlobalStore\n\n actionDrawer: ActionDrawerState = CLOSED_ACTION_DRAWER\n\n /**\n * CTA action status per beat guid. Keyed by guid (not block) so a block shared by many\n * insights never reflects another card's pending or error state.\n */\n ctaStatus: Record<string, CtaStatus> = {}\n\n /**\n * Per-beat scratch input collected on the card or in its blocks (e.g. the account a user\n * picked before pressing Save), keyed by beat guid. Unlike `actionDrawer.context`, which is\n * replaced whenever any drawer session starts, this survives other cards' drawers opening.\n * CTA steps read it via `disabledWhen` and their `params` callback (`beatContextOf`). Ships\n * ahead of its first block writer (Designate's account picker) on purpose: it is the layer's\n * only way to keep a pick alive across other cards' drawer sessions.\n */\n beatContext: Record<string, Record<string, unknown>> = {}\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n\n makeAutoObservable(this)\n }\n\n setCtaStatus = (guid: string, status: CtaStatus) => {\n this.ctaStatus = { ...this.ctaStatus, [guid]: status }\n }\n\n /** Merges `values` into the beat's scratch input. */\n setBeatContext = (guid: string, values: Record<string, unknown>) => {\n this.beatContext = { ...this.beatContext, [guid]: { ...this.beatContext[guid], ...values } }\n }\n\n /**\n * Merges keys into the current drawer session's context bag — it does NOT\n * replace it. A nested drawer (e.g. a row click inside TransactionHistoryBlock\n * opening TransactionDetailsBlock) calls this to layer its own key (e.g.\n * `transaction_guid`) on top of whatever context the outer drawer already set\n * (e.g. `chartBarIndex`), so the outer block keeps reading its own keys via\n * useActionContext while the nested block is open. The bag only returns to a\n * clean slate when a new drawer session starts via `openActionDrawer`/\n * `openCtaDrawer`, which fully replace the envelope.\n */\n setActionContext = (context: Record<string, unknown>) => {\n this.actionDrawer = {\n ...this.actionDrawer,\n context: {\n ...(this.actionDrawer.context as Record<string, unknown> | undefined),\n ...context,\n },\n }\n }\n\n /**\n * Generic drawer opener — the only opener a new action block needs. Pass the\n * beat guid, the CTA/source that triggered it, and (optionally) a block-specific\n * context object the block reads back via useActionContext. `cta` overrides the CTA an\n * `inDescriptionCta` drawer runs, for this session only.\n */\n openActionDrawer = ({ guid, trigger, context, cta }: OpenActionDrawerArgs) => {\n this.actionDrawer = { isDrawerOpen: true, trigger, guid, context, cta }\n }\n\n /** Convenience opener for CTA drawers (no drilldown context). */\n openCtaDrawer = (guid: string, trigger: 'primaryCta' | 'secondaryCta') => {\n this.openActionDrawer({ guid, trigger })\n }\n\n closeActionDrawer = () => {\n // Preserve `trigger`, `context` and `cta` so the drawer keeps its variant-specific\n // title/content through the slide-out animation (ActionBlockLayer stays\n // mounted while closing). Only flip isDrawerOpen off and clear the beat guid.\n this.actionDrawer = { ...this.actionDrawer, isDrawerOpen: false, guid: '' }\n }\n}\n"],"mappings":";AAmCA,IAAa,IAA0C;AAAA,EACrD,cAAc;AAAA,EACd,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,KAAK;AACP,GAuBa,IAAb,MAA6B;AAAA,EAC3B;AAAA,EAEA,eAAkC;AAAA,EAMlC,YAAuC,CAAC;AAAA,EAUxC,cAAuD,CAAC;AAAA,EAExD,YAAY,GAA0B;AACpC,SAAK,cAAc,GAEnB,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,eAAA,CAAgB,GAAc,MAAsB;AAClD,SAAK,YAAY;AAAA,MAAE,GAAG,KAAK;AAAA,MAAY,CAAA,CAAA,GAAO;AAAA,IAAO;AAAA,EACvD;AAAA,EAGA,iBAAA,CAAkB,GAAc,MAAoC;AAClE,SAAK,cAAc;AAAA,MAAE,GAAG,KAAK;AAAA,MAAc,CAAA,CAAA,GAAO;AAAA,QAAE,GAAG,KAAK,YAAY,CAAA;AAAA,QAAO,GAAG;AAAA,MAAO;AAAA,IAAE;AAAA,EAC7F;AAAA,EAYA,mBAAA,CAAoB,MAAqC;AACvD,SAAK,eAAe;AAAA,MAClB,GAAG,KAAK;AAAA,MACR,SAAS;AAAA,QACP,GAAI,KAAK,aAAa;AAAA,QACtB,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EAQA,mBAAA,CAAoB,EAAE,MAAA,GAAM,SAAA,GAAS,SAAA,GAAS,KAAA,EAAA,MAAgC;AAC5E,SAAK,eAAe;AAAA,MAAE,cAAc;AAAA,MAAM,SAAA;AAAA,MAAS,MAAA;AAAA,MAAM,SAAA;AAAA,MAAS,KAAA;AAAA,IAAI;AAAA,EACxE;AAAA,EAGA,gBAAA,CAAiB,GAAc,MAA2C;AACxE,SAAK,iBAAiB;AAAA,MAAE,MAAA;AAAA,MAAM,SAAA;AAAA,IAAQ,CAAC;AAAA,EACzC;AAAA,EAEA,oBAAA,MAA0B;AAIxB,SAAK,eAAe;AAAA,MAAE,GAAG,KAAK;AAAA,MAAc,cAAc;AAAA,MAAO,MAAM;AAAA,IAAG;AAAA,EAC5E;AACF"}
|
|
@@ -1,113 +1,119 @@
|
|
|
1
|
-
import { useGlobalCopyStore as
|
|
1
|
+
import { useGlobalCopyStore as z, useGlobalStore as X, useInsightsV2Store as $ } from "../../common/context/hooks.es.js";
|
|
2
2
|
import { slot as d } from "../../core/types/Insights.es.js";
|
|
3
3
|
import { formatCurrency as q } from "../../core/utils/NumberFormatting.es.js";
|
|
4
|
-
import
|
|
4
|
+
import N from "../../common/components/dialog/Dialog.es.js";
|
|
5
5
|
import { useBeatActions as Z } from "../beatActions.es.js";
|
|
6
6
|
import { USER_RESPONSE as f, answerSubscription as J, repeatingTransactionOf as K, reportSubscriptionMarkedIncorrect as Q } from "../ctaActions/subscriptionAnswer.es.js";
|
|
7
7
|
import Y from "../components/LogoFromGuid.es.js";
|
|
8
8
|
import "../components/celebrationGradients.es.js";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
9
|
+
import { ELEVATION_SHADOW as tt } from "../components/shared/elevation.es.js";
|
|
10
|
+
import rt from "../components/TransactionListCard.es.js";
|
|
11
|
+
import { subscriptionFrequency as ot } from "../components/SubscriptionStatus/subscriptionFrequency.es.js";
|
|
12
|
+
import et from "../components/shared/StatusSnackbar.es.js";
|
|
13
|
+
import { getDynamicCtaBasedOnTriggers as st } from "./util.es.js";
|
|
14
|
+
import { useEffect as it, useRef as R, useState as T } from "react";
|
|
15
|
+
import { observer as nt } from "mobx-react-lite";
|
|
15
16
|
import B from "@mui/material/Stack";
|
|
16
|
-
import { Text as
|
|
17
|
-
import { Icon as
|
|
18
|
-
import { Fragment as
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
var
|
|
17
|
+
import { Text as at } from "@mxenabled/mxui";
|
|
18
|
+
import { Icon as ct } from "@mxenabled/mx-icons";
|
|
19
|
+
import { Fragment as lt, jsx as o, jsxs as x } from "react/jsx-runtime";
|
|
20
|
+
import ut from "@mui/material/Divider";
|
|
21
|
+
import mt from "@mui/material/ButtonBase";
|
|
22
|
+
var pt = 32, G = {
|
|
22
23
|
backgroundColor: "background.paper",
|
|
23
|
-
borderRadius: 1
|
|
24
|
+
borderRadius: 1,
|
|
25
|
+
boxShadow: tt[16]
|
|
24
26
|
}, L = {
|
|
25
27
|
"& .MuiDialog-paper": G,
|
|
26
|
-
"& .MuiDialogContent-root": { p: 0 }
|
|
27
|
-
|
|
28
|
+
"& .MuiDialogContent-root": { p: 0 },
|
|
29
|
+
"& .MuiDialogContent-root ~ .MuiStack-root .MuiButton-root": {
|
|
30
|
+
px: 16,
|
|
31
|
+
py: 12
|
|
32
|
+
}
|
|
33
|
+
}, dt = [
|
|
28
34
|
["never_subscribed", f.NEVER_SUBSCRIBED],
|
|
29
35
|
["cancelled", f.CANCELLED],
|
|
30
36
|
["one_time_purchase", f.ONE_TIME_PURCHASE]
|
|
31
|
-
],
|
|
32
|
-
const P = X(), { insights_feed: _, recurring:
|
|
33
|
-
const p = t
|
|
37
|
+
], r = (n) => typeof n == "string" && n.trim() ? n : void 0, Lt = nt(function({ beat: C }) {
|
|
38
|
+
const P = X(), { insights_feed: _, recurring: W } = z(), { actionDrawer: F, closeActionDrawer: g } = $(), H = Z(), [E, b] = T("answers"), [e, a] = T(null), c = R(!1), y = R(!1), t = _?.subscription_status_modal, l = C.insights_payload, S = dt.flatMap(([s, m]) => {
|
|
39
|
+
const p = r(t?.[s]);
|
|
34
40
|
return p ? [{
|
|
35
41
|
label: p,
|
|
36
42
|
userResponse: m
|
|
37
43
|
}] : [];
|
|
38
|
-
}), D = !!t
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
}, [
|
|
42
|
-
const h = t
|
|
43
|
-
beat:
|
|
44
|
+
}), D = !!r(t?.title) && !!r(t?.subscribed_answer) && !!r(t?.not_subscribed_answer) && S.length > 0, O = !!_ && !D;
|
|
45
|
+
if (it(() => {
|
|
46
|
+
O && (console.warn("[SubscriptionStatusModalBlock] subscription_status_modal is missing its title, answers or reasons; closing."), g());
|
|
47
|
+
}, [O, g]), !l || !t || !D) return null;
|
|
48
|
+
const h = r(t.close_aria) ?? r(t.toast_close_aria) ?? r(_?.settings_menu?.close) ?? "", I = e && r(e.severity === "success" ? t.success_message : t.error_message), v = {
|
|
49
|
+
beat: C,
|
|
44
50
|
stores: P,
|
|
45
|
-
hostActions:
|
|
46
|
-
}, u =
|
|
51
|
+
hostActions: H
|
|
52
|
+
}, u = st(F, l.primary_cta, l.secondary_cta, l.in_description_cta)?.drilldown_data ?? {}, M = d(u, "logo"), A = d(u, "primary_text"), k = d(u, "amount"), w = async (s) => {
|
|
47
53
|
if (!y.current) {
|
|
48
54
|
y.current = !0, a(null), b("saving");
|
|
49
55
|
try {
|
|
50
|
-
await J(v, s), t
|
|
56
|
+
await J(v, s), r(t.success_message) ? a({ severity: "success" }) : i();
|
|
51
57
|
} catch {
|
|
52
|
-
t
|
|
58
|
+
r(t.error_message) ? a({
|
|
53
59
|
severity: "error",
|
|
54
60
|
retry: s
|
|
55
|
-
}) :
|
|
61
|
+
}) : i();
|
|
56
62
|
} finally {
|
|
57
63
|
y.current = !1;
|
|
58
64
|
}
|
|
59
65
|
b("done");
|
|
60
66
|
}
|
|
61
|
-
},
|
|
67
|
+
}, i = () => {
|
|
62
68
|
a(null), g();
|
|
63
|
-
},
|
|
69
|
+
}, U = () => {
|
|
64
70
|
c.current = !0, Q(v), b("reasons");
|
|
65
|
-
},
|
|
66
|
-
c.current = !0,
|
|
67
|
-
},
|
|
71
|
+
}, j = () => {
|
|
72
|
+
c.current = !0, w(f.CONFIRMED);
|
|
73
|
+
}, V = () => {
|
|
68
74
|
if (c.current) {
|
|
69
75
|
c.current = !1;
|
|
70
76
|
return;
|
|
71
77
|
}
|
|
72
|
-
|
|
78
|
+
i();
|
|
73
79
|
};
|
|
74
|
-
return /* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
80
|
+
return /* @__PURE__ */ x(lt, { children: [
|
|
81
|
+
/* @__PURE__ */ o(N, {
|
|
76
82
|
copy: {
|
|
77
|
-
title:
|
|
83
|
+
title: t.title,
|
|
78
84
|
close_aria: h
|
|
79
85
|
},
|
|
80
86
|
fullWidth: !0,
|
|
81
87
|
isOpen: E === "answers",
|
|
82
|
-
onClose:
|
|
83
|
-
onPrimaryAction:
|
|
84
|
-
onSecondaryAction:
|
|
85
|
-
primaryText:
|
|
86
|
-
secondaryText:
|
|
88
|
+
onClose: V,
|
|
89
|
+
onPrimaryAction: j,
|
|
90
|
+
onSecondaryAction: U,
|
|
91
|
+
primaryText: t.subscribed_answer,
|
|
92
|
+
secondaryText: t.not_subscribed_answer,
|
|
87
93
|
sx: L,
|
|
88
|
-
children: typeof
|
|
94
|
+
children: typeof A == "string" && A && /* @__PURE__ */ o(rt, {
|
|
89
95
|
background: "linear-gradient(201deg, rgba(255, 170, 0, 0.25) 1.86%, rgba(255, 68, 0, 0.25) 101.54%)",
|
|
90
96
|
elevated: !0,
|
|
91
97
|
rows: [{
|
|
92
|
-
amount: typeof
|
|
93
|
-
amountCaption:
|
|
94
|
-
leading:
|
|
95
|
-
logo:
|
|
96
|
-
size:
|
|
98
|
+
amount: typeof k == "number" ? q(k, "0,0.00") : "",
|
|
99
|
+
amountCaption: ot(W, K(v)),
|
|
100
|
+
leading: M ? /* @__PURE__ */ o(Y, {
|
|
101
|
+
logo: M,
|
|
102
|
+
size: pt
|
|
97
103
|
}) : void 0,
|
|
98
104
|
subtitle: d(u, "secondary_text") ?? "",
|
|
99
|
-
title:
|
|
105
|
+
title: A
|
|
100
106
|
}]
|
|
101
107
|
})
|
|
102
108
|
}),
|
|
103
|
-
/* @__PURE__ */
|
|
109
|
+
/* @__PURE__ */ o(N, {
|
|
104
110
|
copy: {
|
|
105
|
-
title:
|
|
111
|
+
title: t.title,
|
|
106
112
|
close_aria: h
|
|
107
113
|
},
|
|
108
114
|
fullWidth: !0,
|
|
109
115
|
isOpen: E === "reasons",
|
|
110
|
-
onClose:
|
|
116
|
+
onClose: i,
|
|
111
117
|
showActions: !1,
|
|
112
118
|
sx: {
|
|
113
119
|
...L,
|
|
@@ -116,9 +122,9 @@ var mr = 32, G = {
|
|
|
116
122
|
pb: 16
|
|
117
123
|
}
|
|
118
124
|
},
|
|
119
|
-
children: /* @__PURE__ */
|
|
125
|
+
children: /* @__PURE__ */ o(B, { children: S.map(({ label: s, userResponse: m }, p) => /* @__PURE__ */ x(B, { children: [/* @__PURE__ */ x(mt, {
|
|
120
126
|
onClick: () => {
|
|
121
|
-
|
|
127
|
+
w(m);
|
|
122
128
|
},
|
|
123
129
|
sx: {
|
|
124
130
|
gap: 12,
|
|
@@ -129,33 +135,37 @@ var mr = 32, G = {
|
|
|
129
135
|
textAlign: "left",
|
|
130
136
|
width: "100%"
|
|
131
137
|
},
|
|
132
|
-
children: [/* @__PURE__ */
|
|
138
|
+
children: [/* @__PURE__ */ o(at, {
|
|
133
139
|
variant: "body1",
|
|
134
140
|
children: s
|
|
135
|
-
}), /* @__PURE__ */
|
|
141
|
+
}), /* @__PURE__ */ o(ct, {
|
|
136
142
|
"aria-hidden": !0,
|
|
137
143
|
name: "chevron_right",
|
|
138
144
|
size: 24,
|
|
139
145
|
sx: { color: "action.active" }
|
|
140
146
|
})]
|
|
141
|
-
}), p < S.length - 1 && /* @__PURE__ */
|
|
147
|
+
}), p < S.length - 1 && /* @__PURE__ */ o(ut, { sx: {
|
|
148
|
+
ml: 24,
|
|
149
|
+
mt: "-1px"
|
|
150
|
+
} })] }, m)) })
|
|
142
151
|
}),
|
|
143
|
-
|
|
144
|
-
actionText:
|
|
145
|
-
closeAriaLabel: t
|
|
146
|
-
message:
|
|
147
|
-
onActionClick:
|
|
148
|
-
|
|
152
|
+
e && I && /* @__PURE__ */ o(et, {
|
|
153
|
+
actionText: e.retry ? r(t.try_again) : void 0,
|
|
154
|
+
closeAriaLabel: r(t.toast_close_aria) ?? h,
|
|
155
|
+
message: I,
|
|
156
|
+
onActionClick: e.retry ? () => {
|
|
157
|
+
w(e.retry);
|
|
149
158
|
} : void 0,
|
|
150
|
-
onClose:
|
|
159
|
+
onClose: i,
|
|
151
160
|
open: !0,
|
|
152
|
-
severity:
|
|
161
|
+
severity: e.severity,
|
|
162
|
+
variant: "strong"
|
|
153
163
|
})
|
|
154
164
|
] });
|
|
155
165
|
});
|
|
156
166
|
export {
|
|
157
|
-
|
|
158
|
-
|
|
167
|
+
Lt as SubscriptionStatusModalBlock,
|
|
168
|
+
Lt as default
|
|
159
169
|
};
|
|
160
170
|
|
|
161
171
|
//# sourceMappingURL=SubscriptionStatusModalBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionStatusModalBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/SubscriptionStatusModalBlock.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport ButtonBase from '@mui/material/ButtonBase'\nimport Divider from '@mui/material/Divider'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { Text } from '@mxenabled/mxui'\n\nimport { Dialog, useGlobalCopyStore, useGlobalStore, useInsightsV2Store } from '../../common'\nimport { slot } from '../../core'\nimport type { LogoRef } from '../../core'\nimport { formatCurrency } from '../../core/utils/NumberFormatting'\nimport { useBeatActions } from '../beatActions'\nimport { WARNING_WASH_GRADIENT } from '../components/celebrationGradients'\nimport LogoFromGuid from '../components/LogoFromGuid'\nimport StatusSnackbar from '../components/shared/StatusSnackbar'\nimport { subscriptionFrequency } from '../components/SubscriptionStatus/subscriptionFrequency'\nimport TransactionListCard from '../components/TransactionListCard'\nimport {\n answerSubscription,\n repeatingTransactionOf,\n reportSubscriptionMarkedIncorrect,\n USER_RESPONSE,\n} from '../ctaActions/subscriptionAnswer'\nimport type { ActionBlockProps } from '../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from './util'\n\nconst ROW_LOGO_SIZE = 32\n\n// White paper, full-bleed content, 4px radius.\nconst DIALOG_PAPER_SX = { backgroundColor: 'background.paper', borderRadius: 1 }\nconst SUBSCRIPTION_DIALOG_SX = {\n '& .MuiDialog-paper': DIALOG_PAPER_SX,\n '& .MuiDialogContent-root': { p: 0 },\n}\n\n// The reasons in Figma order; a reason with no word drops its row.\nconst REASONS = [\n ['never_subscribed', USER_RESPONSE.NEVER_SUBSCRIBED],\n ['cancelled', USER_RESPONSE.CANCELLED],\n ['one_time_purchase', USER_RESPONSE.ONE_TIME_PURCHASE],\n] as const\n\n/** A non-empty word, or undefined. */\nconst word = (value?: string): string | undefined =>\n typeof value === 'string' && value.trim() ? value : undefined\n\ntype Phase = 'answers' | 'reasons' | 'saving' | 'done'\ninterface Notice {\n severity: 'success' | 'error'\n retry?: string\n}\n\n/** Unexpected Subscription Payment's Subscription Status modal. */\nexport const SubscriptionStatusModalBlock = observer(function SubscriptionStatusModalBlock({\n beat,\n}: ActionBlockProps) {\n const stores = useGlobalStore()\n const { insights_feed, recurring } = useGlobalCopyStore()\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n const beatActions = useBeatActions()\n const [phase, setPhase] = useState<Phase>('answers')\n const [notice, setNotice] = useState<Notice | null>(null)\n // The Dialog calls onClose after its actions; keep the flow open.\n const actionTaken = useRef(false)\n // One save at a time: a double tap (a closing dialog is still clickable) or Try Again sends one PUT.\n const saving = useRef(false)\n\n const copy = insights_feed?.subscription_status_modal\n const payload = beat.insights_payload\n // Only the words needed to answer: the title, both answers and at least one reason. The rest\n // (snackbar words, close labels, reviewed_title, a key added later) never block the modal.\n const reasons = REASONS.flatMap(([key, userResponse]) => {\n const label = word(copy?.[key])\n\n return label ? [{ label, userResponse }] : []\n })\n const ready =\n !!word(copy?.title) &&\n !!word(copy?.subscribed_answer) &&\n !!word(copy?.not_subscribed_answer) &&\n reasons.length > 0\n // Copy loaded (insights_feed is there) but incomplete: say so and close, not a silent open drawer.\n const incomplete = !!insights_feed && !ready\n\n useEffect(() => {\n if (!incomplete) return\n console.warn(\n '[SubscriptionStatusModalBlock] subscription_status_modal is missing its title, answers or reasons; closing.',\n )\n closeActionDrawer()\n }, [incomplete, closeActionDrawer])\n\n if (!payload || !copy || !ready) return null\n\n const closeLabel =\n word(copy.close_aria) ??\n word(copy.toast_close_aria) ??\n word(insights_feed?.settings_menu?.close) ??\n ''\n const noticeMessage =\n notice && word(notice.severity === 'success' ? copy.success_message : copy.error_message)\n\n const ctx = { beat, stores, hostActions: beatActions }\n const cta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n payload.primary_cta,\n payload.secondary_cta,\n payload.in_description_cta,\n )\n const row = cta?.drilldown_data ?? {}\n const logo = slot<LogoRef>(row, 'logo')\n const title = slot<string>(row, 'primary_text')\n const amount = slot<number>(row, 'amount')\n\n const save = async (userResponse: string) => {\n if (saving.current) return\n saving.current = true\n setNotice(null)\n setPhase('saving')\n try {\n await answerSubscription(ctx, userResponse)\n // No snackbar word: the save stands, the flow just ends without the snackbar.\n if (word(copy.success_message)) setNotice({ severity: 'success' })\n else finish()\n } catch {\n if (word(copy.error_message)) setNotice({ severity: 'error', retry: userResponse })\n else finish()\n } finally {\n saving.current = false\n }\n setPhase('done')\n }\n\n const finish = () => {\n setNotice(null)\n closeActionDrawer()\n }\n\n const chooseNotSubscribed = () => {\n actionTaken.current = true\n reportSubscriptionMarkedIncorrect(ctx)\n setPhase('reasons')\n }\n\n const chooseSubscribed = () => {\n actionTaken.current = true\n void save(USER_RESPONSE.CONFIRMED)\n }\n\n const closeAnswers = () => {\n if (actionTaken.current) {\n actionTaken.current = false\n return\n }\n finish()\n }\n\n return (\n <>\n <Dialog\n copy={{ title: copy.title, close_aria: closeLabel }}\n fullWidth={true}\n isOpen={phase === 'answers'}\n onClose={closeAnswers}\n onPrimaryAction={chooseSubscribed}\n onSecondaryAction={chooseNotSubscribed}\n primaryText={copy.subscribed_answer}\n secondaryText={copy.not_subscribed_answer}\n // Full-bleed wash between title and actions.\n sx={SUBSCRIPTION_DIALOG_SX}\n >\n {typeof title === 'string' && title && (\n <TransactionListCard\n background={WARNING_WASH_GRADIENT}\n elevated={true}\n rows={[\n {\n amount: typeof amount === 'number' ? formatCurrency(amount, '0,0.00') : '',\n amountCaption: subscriptionFrequency(recurring, repeatingTransactionOf(ctx)),\n leading: logo ? <LogoFromGuid logo={logo} size={ROW_LOGO_SIZE} /> : undefined,\n subtitle: slot<string>(row, 'secondary_text') ?? '',\n title,\n },\n ]}\n />\n )}\n </Dialog>\n\n <Dialog\n copy={{ title: copy.title, close_aria: closeLabel }}\n fullWidth={true}\n isOpen={phase === 'reasons'}\n onClose={finish}\n showActions={false}\n // Space under the list.\n sx={{ ...SUBSCRIPTION_DIALOG_SX, '& .MuiDialog-paper': { ...DIALOG_PAPER_SX, pb: 16 } }}\n >\n <Stack>\n {reasons.map(({ label, userResponse }, index) => (\n <Stack key={userResponse}>\n <ButtonBase\n onClick={() => void save(userResponse)}\n sx={{\n gap: 12,\n justifyContent: 'space-between',\n minHeight: 44,\n px: 24,\n py: 8,\n textAlign: 'left',\n width: '100%',\n }}\n >\n <Text variant=\"body1\">{label}</Text>\n <Icon\n aria-hidden={true}\n name=\"chevron_right\"\n size={24}\n sx={{ color: 'action.active' }}\n />\n </ButtonBase>\n {/* Between rows only. */}\n {index < reasons.length - 1 && <Divider sx={{ ml: 24 }} />}\n </Stack>\n ))}\n </Stack>\n </Dialog>\n\n {notice && noticeMessage && (\n <StatusSnackbar\n actionText={notice.retry ? word(copy.try_again) : undefined}\n closeAriaLabel={word(copy.toast_close_aria) ?? closeLabel}\n message={noticeMessage}\n onActionClick={notice.retry ? () => void save(notice.retry as string) : undefined}\n onClose={finish}\n open={true}\n severity={notice.severity}\n />\n )}\n </>\n )\n})\n\nexport default SubscriptionStatusModalBlock\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6BA,IAAM,KAAgB,IAGhB,IAAkB;AAAA,EAAE,iBAAiB;AAAA,EAAoB,cAAc;AAAE,GACzE,IAAyB;AAAA,EAC7B,sBAAsB;AAAA,EACtB,4BAA4B,EAAE,GAAG,EAAE;AACrC,GAGM,KAAU;AAAA,EACd,CAAC,oBAAoB,EAAc,gBAAgB;AAAA,EACnD,CAAC,aAAa,EAAc,SAAS;AAAA,EACrC,CAAC,qBAAqB,EAAc,iBAAiB;AACvD,GAGM,IAAA,CAAQ,MACZ,OAAO,KAAU,YAAY,EAAM,KAAK,IAAI,IAAQ,QASzC,KAA+B,GAAS,SAAsC,EACzF,MAAA,EAAA,GACmB;AACnB,QAAM,IAAS,EAAe,GACxB,EAAE,eAAA,GAAe,WAAA,EAAA,IAAc,EAAmB,GAClD,EAAE,cAAA,GAAc,mBAAA,EAAA,IAAsB,EAAmB,GACzD,IAAc,EAAe,GAC7B,CAAC,GAAO,CAAA,IAAY,EAAgB,SAAS,GAC7C,CAAC,GAAQ,CAAA,IAAa,EAAwB,IAAI,GAElD,IAAc,EAAO,EAAK,GAE1B,IAAS,EAAO,EAAK,GAErB,IAAO,GAAe,2BACtB,IAAU,EAAK,kBAGf,IAAU,GAAQ,QAAA,CAAS,CAAC,GAAK,CAAA,MAAkB;AACvD,UAAM,IAAQ,EAAK,IAAO,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A,MACT,eAAe,EAAO,QAAA,MAAA;AAAc,QAAK,EAAK,EAAO,KAAe;AAAA,UAAI;AAAA,MACxE,SAAS;AAAA,MACT,MAAM;AAAA,MACN,UAAU,EAAO;AAAA,IAClB,CAAA;AAAA,EAEH,EAAA,CAAA;AAEN,CAAC"}
|
|
1
|
+
{"version":3,"file":"SubscriptionStatusModalBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/SubscriptionStatusModalBlock.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport ButtonBase from '@mui/material/ButtonBase'\nimport Divider from '@mui/material/Divider'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { Text } from '@mxenabled/mxui'\n\nimport { Dialog, useGlobalCopyStore, useGlobalStore, useInsightsV2Store } from '../../common'\nimport { slot } from '../../core'\nimport type { LogoRef } from '../../core'\nimport { formatCurrency } from '../../core/utils/NumberFormatting'\nimport { useBeatActions } from '../beatActions'\nimport { WARNING_WASH_GRADIENT } from '../components/celebrationGradients'\nimport LogoFromGuid from '../components/LogoFromGuid'\nimport { ELEVATION_SHADOW } from '../components/shared/elevation'\nimport StatusSnackbar from '../components/shared/StatusSnackbar'\nimport { subscriptionFrequency } from '../components/SubscriptionStatus/subscriptionFrequency'\nimport TransactionListCard from '../components/TransactionListCard'\nimport {\n answerSubscription,\n repeatingTransactionOf,\n reportSubscriptionMarkedIncorrect,\n USER_RESPONSE,\n} from '../ctaActions/subscriptionAnswer'\nimport type { ActionBlockProps } from '../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from './util'\n\nconst ROW_LOGO_SIZE = 32\n\n// Figma Dialog: white paper, 4px radius, elevation/16; full-bleed content; 12/16 action buttons.\nconst DIALOG_PAPER_SX = {\n backgroundColor: 'background.paper',\n borderRadius: 1,\n boxShadow: ELEVATION_SHADOW[16],\n}\nconst SUBSCRIPTION_DIALOG_SX = {\n '& .MuiDialog-paper': DIALOG_PAPER_SX,\n '& .MuiDialogContent-root': { p: 0 },\n '& .MuiDialogContent-root ~ .MuiStack-root .MuiButton-root': { px: 16, py: 12 },\n}\n\n// The reasons in Figma order; a reason with no word drops its row.\nconst REASONS = [\n ['never_subscribed', USER_RESPONSE.NEVER_SUBSCRIBED],\n ['cancelled', USER_RESPONSE.CANCELLED],\n ['one_time_purchase', USER_RESPONSE.ONE_TIME_PURCHASE],\n] as const\n\n/** A non-empty word, or undefined. */\nconst word = (value?: string): string | undefined =>\n typeof value === 'string' && value.trim() ? value : undefined\n\ntype Phase = 'answers' | 'reasons' | 'saving' | 'done'\ninterface Notice {\n severity: 'success' | 'error'\n retry?: string\n}\n\n/** Unexpected Subscription Payment's Subscription Status modal. */\nexport const SubscriptionStatusModalBlock = observer(function SubscriptionStatusModalBlock({\n beat,\n}: ActionBlockProps) {\n const stores = useGlobalStore()\n const { insights_feed, recurring } = useGlobalCopyStore()\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n const beatActions = useBeatActions()\n const [phase, setPhase] = useState<Phase>('answers')\n const [notice, setNotice] = useState<Notice | null>(null)\n // The Dialog calls onClose after its actions; keep the flow open.\n const actionTaken = useRef(false)\n // One save at a time: a double tap (a closing dialog is still clickable) or Try Again sends one PUT.\n const saving = useRef(false)\n\n const copy = insights_feed?.subscription_status_modal\n const payload = beat.insights_payload\n // Only the words needed to answer: the title, both answers and at least one reason. The rest\n // (snackbar words, close labels, reviewed_title, a key added later) never block the modal.\n const reasons = REASONS.flatMap(([key, userResponse]) => {\n const label = word(copy?.[key])\n\n return label ? [{ label, userResponse }] : []\n })\n const ready =\n !!word(copy?.title) &&\n !!word(copy?.subscribed_answer) &&\n !!word(copy?.not_subscribed_answer) &&\n reasons.length > 0\n // Copy loaded (insights_feed is there) but incomplete: say so and close, not a silent open drawer.\n const incomplete = !!insights_feed && !ready\n\n useEffect(() => {\n if (!incomplete) return\n console.warn(\n '[SubscriptionStatusModalBlock] subscription_status_modal is missing its title, answers or reasons; closing.',\n )\n closeActionDrawer()\n }, [incomplete, closeActionDrawer])\n\n if (!payload || !copy || !ready) return null\n\n const closeLabel =\n word(copy.close_aria) ??\n word(copy.toast_close_aria) ??\n word(insights_feed?.settings_menu?.close) ??\n ''\n const noticeMessage =\n notice && word(notice.severity === 'success' ? copy.success_message : copy.error_message)\n\n const ctx = { beat, stores, hostActions: beatActions }\n const cta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n payload.primary_cta,\n payload.secondary_cta,\n payload.in_description_cta,\n )\n const row = cta?.drilldown_data ?? {}\n const logo = slot<LogoRef>(row, 'logo')\n const title = slot<string>(row, 'primary_text')\n const amount = slot<number>(row, 'amount')\n\n const save = async (userResponse: string) => {\n if (saving.current) return\n saving.current = true\n setNotice(null)\n setPhase('saving')\n try {\n await answerSubscription(ctx, userResponse)\n // No snackbar word: the save stands, the flow just ends without the snackbar.\n if (word(copy.success_message)) setNotice({ severity: 'success' })\n else finish()\n } catch {\n if (word(copy.error_message)) setNotice({ severity: 'error', retry: userResponse })\n else finish()\n } finally {\n saving.current = false\n }\n setPhase('done')\n }\n\n const finish = () => {\n setNotice(null)\n closeActionDrawer()\n }\n\n const chooseNotSubscribed = () => {\n actionTaken.current = true\n reportSubscriptionMarkedIncorrect(ctx)\n setPhase('reasons')\n }\n\n const chooseSubscribed = () => {\n actionTaken.current = true\n void save(USER_RESPONSE.CONFIRMED)\n }\n\n const closeAnswers = () => {\n if (actionTaken.current) {\n actionTaken.current = false\n return\n }\n finish()\n }\n\n return (\n <>\n <Dialog\n copy={{ title: copy.title, close_aria: closeLabel }}\n fullWidth={true}\n isOpen={phase === 'answers'}\n onClose={closeAnswers}\n onPrimaryAction={chooseSubscribed}\n onSecondaryAction={chooseNotSubscribed}\n primaryText={copy.subscribed_answer}\n secondaryText={copy.not_subscribed_answer}\n // Full-bleed wash between title and actions.\n sx={SUBSCRIPTION_DIALOG_SX}\n >\n {typeof title === 'string' && title && (\n <TransactionListCard\n background={WARNING_WASH_GRADIENT}\n elevated={true}\n rows={[\n {\n amount: typeof amount === 'number' ? formatCurrency(amount, '0,0.00') : '',\n amountCaption: subscriptionFrequency(recurring, repeatingTransactionOf(ctx)),\n leading: logo ? <LogoFromGuid logo={logo} size={ROW_LOGO_SIZE} /> : undefined,\n subtitle: slot<string>(row, 'secondary_text') ?? '',\n title,\n },\n ]}\n />\n )}\n </Dialog>\n\n <Dialog\n copy={{ title: copy.title, close_aria: closeLabel }}\n fullWidth={true}\n isOpen={phase === 'reasons'}\n onClose={finish}\n showActions={false}\n // Space under the list.\n sx={{ ...SUBSCRIPTION_DIALOG_SX, '& .MuiDialog-paper': { ...DIALOG_PAPER_SX, pb: 16 } }}\n >\n <Stack>\n {reasons.map(({ label, userResponse }, index) => (\n <Stack key={userResponse}>\n <ButtonBase\n onClick={() => void save(userResponse)}\n sx={{\n gap: 12,\n justifyContent: 'space-between',\n minHeight: 44,\n px: 24,\n py: 8,\n textAlign: 'left',\n width: '100%',\n }}\n >\n <Text variant=\"body1\">{label}</Text>\n <Icon\n aria-hidden={true}\n name=\"chevron_right\"\n size={24}\n sx={{ color: 'action.active' }}\n />\n </ButtonBase>\n {/* Between rows only, drawn over the row edge (as Figma) so rows stay 44px apart. */}\n {index < reasons.length - 1 && <Divider sx={{ ml: 24, mt: '-1px' }} />}\n </Stack>\n ))}\n </Stack>\n </Dialog>\n\n {notice && noticeMessage && (\n <StatusSnackbar\n actionText={notice.retry ? word(copy.try_again) : undefined}\n closeAriaLabel={word(copy.toast_close_aria) ?? closeLabel}\n message={noticeMessage}\n onActionClick={notice.retry ? () => void save(notice.retry as string) : undefined}\n onClose={finish}\n open={true}\n severity={notice.severity}\n variant=\"strong\"\n />\n )}\n </>\n )\n})\n\nexport default SubscriptionStatusModalBlock\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8BA,IAAM,KAAgB,IAGhB,IAAkB;AAAA,EACtB,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,WAAW,GAAiB,E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,GAAD,EAAA,UAAA,CACE,gBAAA,EAAC,IAAD;AAAA,QACE,SAAA,MAAA;AAAe,UAAK,EAAK,CAAY;AAAA;AAAA,QACrC,IAAI;AAAA,UACF,KAAK;AAAA,UACL,gBAAgB;AAAA,UAChB,WAAW;AAAA,UACX,IAAI;AAAA,UACJ,IAAI;AAAA,UACJ,WAAW;AAAA,UACX,OAAO;AAAA,QACT;AAAA,QAVF,UAAA,CAYE,gBAAA,EAAC,IAAD;AAAA,UAAM,SAAQ;AAAA,UAAS,UAAA;AAAA,QAAY,CAAA,GACnC,gBAAA,EAAC,IAAD;AAAA,UACE,eAAa;AAAA,UACb,MAAK;AAAA,UACL,MAAM;AAAA,UACN,IAAI,EAAE,OAAO,gBAAgB;AAAA,QAC9B,CAAA,CACS;AAAA,MAEX,CAAA,GAAA,IAAQ,EAAQ,SAAS,KAAK,gBAAA,EAAC,IAAD,EAAS,IAAI;AAAA,QAAE,IAAI;AAAA,QAAI,IAAI;AAAA,MAAO,EAAI,CAAA,CAChE,EAAA,GAvBK,CAuBL,CACR,EACI,CAAA;AAAA,IACD,CAAA;AAAA,IAEP,KAAU,KACT,gBAAA,EAAC,IAAD;AAAA,MACE,YAAY,EAAO,QAAQ,EAAK,EAAK,SAAS,IAAI;AAAA,MAClD,gBAAgB,EAAK,EAAK,gBAAgB,KAAK;AAAA,MAC/C,SAAS;AAAA,MACT,eAAe,EAAO,QAAA,MAAA;AAAc,QAAK,EAAK,EAAO,KAAe;AAAA,UAAI;AAAA,MACxE,SAAS;AAAA,MACT,MAAM;AAAA,MACN,UAAU,EAAO;AAAA,MACjB,SAAQ;AAAA,IACT,CAAA;AAAA,EAEH,EAAA,CAAA;AAEN,CAAC"}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { useCategoryStore as
|
|
1
|
+
import { useCategoryStore as M, useGlobalCopyStore as Z, useGlobalStore as $ } from "../../../../common/context/hooks.es.js";
|
|
2
2
|
import { slot as a } from "../../../../core/types/Insights.es.js";
|
|
3
3
|
import { formatCurrency as x } from "../../../../core/utils/NumberFormatting.es.js";
|
|
4
|
-
import { useBeatActions as
|
|
5
|
-
import { USER_RESPONSE as
|
|
6
|
-
import { logoFromRef as
|
|
7
|
-
import
|
|
8
|
-
import { statusIconName as
|
|
9
|
-
import { resolveVariantConfig as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { subscriptionFrequency as
|
|
13
|
-
import { getLayoutConfig as
|
|
14
|
-
import { observer as
|
|
15
|
-
import { CategoryIcon as
|
|
4
|
+
import { useBeatActions as j } from "../../../beatActions.es.js";
|
|
5
|
+
import { USER_RESPONSE as q, repeatingTransactionOf as D } from "../../../ctaActions/subscriptionAnswer.es.js";
|
|
6
|
+
import { logoFromRef as H } from "../../../components/shared/EntityLogo.es.js";
|
|
7
|
+
import P from "../../../components/LogoFromGuid.es.js";
|
|
8
|
+
import { statusIconName as V, statusIconPalette as b } from "../../../components/statusIcon.es.js";
|
|
9
|
+
import { resolveVariantConfig as U } from "../../resolveVariantConfig.es.js";
|
|
10
|
+
import W from "../../../components/TransactionListCard.es.js";
|
|
11
|
+
import Y from "../../../components/StatusMessageCard.es.js";
|
|
12
|
+
import { subscriptionFrequency as J } from "../../../components/SubscriptionStatus/subscriptionFrequency.es.js";
|
|
13
|
+
import { getLayoutConfig as K, transactionBlockVariant as Q } from "./layout.es.js";
|
|
14
|
+
import { observer as X } from "mobx-react-lite";
|
|
15
|
+
import { CategoryIcon as oo, InstitutionLogo as to, MerchantLogo as ro } from "@mxenabled/mxui";
|
|
16
16
|
import { Icon as I } from "@mxenabled/mx-icons";
|
|
17
17
|
import { jsx as t } from "react/jsx-runtime";
|
|
18
|
-
import { useTheme as
|
|
18
|
+
import { useTheme as eo } from "@mui/material/styles";
|
|
19
19
|
import u from "@mui/material/Box";
|
|
20
|
-
var s = 32,
|
|
21
|
-
const n =
|
|
20
|
+
var s = 32, no = Math.round(s * 0.625), io = 24, v = 32, ao = 20, so = ({ icon: e }) => {
|
|
21
|
+
const n = V(e?.guid);
|
|
22
22
|
return n ? /* @__PURE__ */ t(u, {
|
|
23
23
|
"aria-hidden": !0,
|
|
24
24
|
"data-icon": n,
|
|
@@ -35,12 +35,12 @@ var s = 32, eo = Math.round(s * 0.625), no = 24, v = 32, io = 20, ao = ({ icon:
|
|
|
35
35
|
children: /* @__PURE__ */ t(I, {
|
|
36
36
|
fill: !0,
|
|
37
37
|
name: n,
|
|
38
|
-
size:
|
|
38
|
+
size: ao,
|
|
39
39
|
sx: { color: `${b(e?.color)}.contrastText` }
|
|
40
40
|
})
|
|
41
41
|
}) : null;
|
|
42
|
-
},
|
|
43
|
-
const o =
|
|
42
|
+
}, co = (e, n) => {
|
|
43
|
+
const o = H(e.logo, e.primary_text);
|
|
44
44
|
if (o) {
|
|
45
45
|
if (o.logo_name) return /* @__PURE__ */ t(u, {
|
|
46
46
|
sx: {
|
|
@@ -52,17 +52,17 @@ var s = 32, eo = Math.round(s * 0.625), no = 24, v = 32, io = 20, ao = ({ icon:
|
|
|
52
52
|
},
|
|
53
53
|
children: /* @__PURE__ */ t(I, {
|
|
54
54
|
name: o.logo_name,
|
|
55
|
-
size:
|
|
55
|
+
size: no,
|
|
56
56
|
sx: { color: o.logo_color }
|
|
57
57
|
})
|
|
58
58
|
});
|
|
59
|
-
if (o.merchant_guid) return /* @__PURE__ */ t(
|
|
59
|
+
if (o.merchant_guid) return /* @__PURE__ */ t(ro, {
|
|
60
60
|
alt: o.merchant_name ?? "",
|
|
61
61
|
categoryGuid: o.category_guid ? n(o.category_guid) : "",
|
|
62
62
|
merchantGuid: o.merchant_guid,
|
|
63
63
|
size: s
|
|
64
64
|
});
|
|
65
|
-
if (o.institution_guid) return /* @__PURE__ */ t(
|
|
65
|
+
if (o.institution_guid) return /* @__PURE__ */ t(to, {
|
|
66
66
|
alt: o.institution_name ?? "",
|
|
67
67
|
institutionGuid: o.institution_guid,
|
|
68
68
|
size: s
|
|
@@ -72,27 +72,27 @@ var s = 32, eo = Math.round(s * 0.625), no = 24, v = 32, io = 20, ao = ({ icon:
|
|
|
72
72
|
return /* @__PURE__ */ t(u, {
|
|
73
73
|
"data-testid": `category-icon-${c}`,
|
|
74
74
|
sx: { display: "flex" },
|
|
75
|
-
children: /* @__PURE__ */ t(
|
|
75
|
+
children: /* @__PURE__ */ t(oo, {
|
|
76
76
|
categoryGuid: c,
|
|
77
77
|
size: s
|
|
78
78
|
})
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
},
|
|
83
|
-
const n =
|
|
82
|
+
}, ko = X(({ payload: e }) => {
|
|
83
|
+
const n = eo(), { getTopLevelCategoryGuid: o } = M(), c = $(), { recurring: S } = Z(), { beat: l } = j(), { data: i, variant: C } = e.instance_slot, { answeredBackground: f, background: m, cardVariant: G, elevated: E, followsSubscription: d, raised: T, showFooter: B, showFrequency: p, showHeader: k, statusMessage: L, sx: O } = U(K(n), C, Q.NoHeader, "TransactionBlock"), _ = (p || d) && l ? D({
|
|
84
84
|
beat: l,
|
|
85
85
|
stores: c
|
|
86
|
-
}) : void 0, y = !!d && _?.user_response ===
|
|
87
|
-
if (
|
|
86
|
+
}) : void 0, y = !!d && _?.user_response === q.CONFIRMED;
|
|
87
|
+
if (L) {
|
|
88
88
|
const r = a(i, "message");
|
|
89
|
-
return typeof r != "string" || !r.trim() ? (console.warn("[TransactionBlock] status_message has no message — rendering nothing."), null) : /* @__PURE__ */ t(
|
|
89
|
+
return typeof r != "string" || !r.trim() ? (console.warn("[TransactionBlock] status_message has no message — rendering nothing."), null) : /* @__PURE__ */ t(Y, {
|
|
90
90
|
icon: /* @__PURE__ */ t(u, {
|
|
91
91
|
"aria-hidden": "true",
|
|
92
92
|
sx: { display: "flex" },
|
|
93
|
-
children: /* @__PURE__ */ t(
|
|
93
|
+
children: /* @__PURE__ */ t(P, {
|
|
94
94
|
logo: a(i, "icon"),
|
|
95
|
-
size:
|
|
95
|
+
size: io
|
|
96
96
|
})
|
|
97
97
|
}),
|
|
98
98
|
message: r,
|
|
@@ -104,29 +104,30 @@ var s = 32, eo = Math.round(s * 0.625), no = 24, v = 32, io = 20, ao = ({ icon:
|
|
|
104
104
|
}
|
|
105
105
|
const g = a(i, "series"), h = a(i, "header_text");
|
|
106
106
|
if (!Array.isArray(g) || !g.length) return null;
|
|
107
|
-
const
|
|
108
|
-
label:
|
|
109
|
-
amount: x(
|
|
110
|
-
} : void 0,
|
|
111
|
-
return /* @__PURE__ */ t(
|
|
107
|
+
const R = k && typeof h == "string" ? h : void 0, A = a(i, "footer_text"), w = a(i, "footer_amount"), z = B ? {
|
|
108
|
+
label: A,
|
|
109
|
+
amount: x(w, "0,0.00")
|
|
110
|
+
} : void 0, F = p ? J(S, _) : void 0, N = d ? /* @__PURE__ */ t(so, { icon: a(i, y ? "reviewed_icon" : "icon") }) : void 0;
|
|
111
|
+
return /* @__PURE__ */ t(W, {
|
|
112
112
|
background: y && f ? f : m,
|
|
113
|
-
badge:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
badge: N,
|
|
114
|
+
elevated: E,
|
|
115
|
+
footer: z,
|
|
116
|
+
header: R,
|
|
117
|
+
raised: T,
|
|
118
|
+
sx: O,
|
|
118
119
|
variant: G,
|
|
119
120
|
rows: g.map((r) => ({
|
|
120
121
|
amount: typeof r.amount == "number" ? x(r.amount, "0,0.00") : "",
|
|
121
|
-
amountCaption:
|
|
122
|
-
leading:
|
|
122
|
+
amountCaption: F,
|
|
123
|
+
leading: co(r, o),
|
|
123
124
|
subtitle: r.secondary_text ?? "",
|
|
124
125
|
title: r.primary_text ?? ""
|
|
125
126
|
}))
|
|
126
127
|
});
|
|
127
128
|
});
|
|
128
129
|
export {
|
|
129
|
-
|
|
130
|
+
ko as TransactionBlock
|
|
130
131
|
};
|
|
131
132
|
|
|
132
133
|
//# sourceMappingURL=TransactionBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport { useTheme } from '@mui/material/styles'\n\nimport { CategoryIcon, InstitutionLogo, MerchantLogo } from '@mxenabled/mxui'\nimport { Icon } from '@mxenabled/mx-icons'\n\nimport { useCategoryStore, useGlobalCopyStore, useGlobalStore } from '../../../../common'\nimport { slot } from '../../../../core'\nimport type { InsightsPayload, InstanceSlotRow, LogoRef } from '../../../../core'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\n\nimport { useBeatActions } from '../../../beatActions'\nimport LogoFromGuid from '../../../components/LogoFromGuid'\nimport StatusMessageCard from '../../../components/StatusMessageCard'\nimport TransactionListCard from '../../../components/TransactionListCard'\nimport { logoFromRef } from '../../../components/shared/EntityLogo'\nimport { statusIconName, statusIconPalette } from '../../../components/statusIcon'\nimport { subscriptionFrequency } from '../../../components/SubscriptionStatus/subscriptionFrequency'\nimport { repeatingTransactionOf, USER_RESPONSE } from '../../../ctaActions/subscriptionAnswer'\n\nimport { resolveVariantConfig } from '../../resolveVariantConfig'\nimport { getLayoutConfig, transactionBlockVariant } from './layout'\n\ninterface TransactionBlockProps {\n payload: InsightsPayload\n beatGuid?: string\n}\n\nconst ROW_LOGO_SIZE = 32\n// Same glyph-to-tile ratio mxui's `CategoryIcon` uses, so a status icon sits like the other logos.\nconst ROW_ICON_SIZE = Math.round(ROW_LOGO_SIZE * 0.625)\nconst STATUS_ICON_SIZE = 24\n// Status badge: palette disc, contrastText glyph.\nconst BADGE_SIZE = 32\nconst BADGE_GLYPH_SIZE = 20\n\n/** Status disc from `data.icon` / `data.reviewed_icon`. */\nconst SubscriptionBadge = ({ icon }: { icon?: LogoRef }) => {\n const name = statusIconName(icon?.guid)\n\n if (!name) return null\n\n return (\n <Box\n aria-hidden={true}\n data-icon={name}\n data-testid=\"subscription-badge\"\n sx={{\n alignItems: 'center',\n bgcolor: `${statusIconPalette(icon?.color)}.main`,\n borderRadius: '50%',\n display: 'flex',\n height: BADGE_SIZE,\n justifyContent: 'center',\n width: BADGE_SIZE,\n }}\n >\n <Icon\n fill={true}\n name={name}\n size={BADGE_GLYPH_SIZE}\n sx={{ color: `${statusIconPalette(icon?.color)}.contrastText` }}\n />\n </Box>\n )\n}\n\n/**\n * Renders the row's leading logo from its `LogoRef`: a status icon, or an entity guid whose prefix\n * names the entity. An unrecognized prefix renders no logo rather than guessing.\n *\n * `resolveTopLevelCategory`: mxui's `CategoryIcon` only knows the top-level category guids and\n * silently falls back to the Uncategorized icon for a sub-category. The details drawer avoids\n * this by passing `transaction.top_level_category_guid`; the row only has the raw guid, so it is\n * walked up to its parent here (identity until categories load). That applies both to a `CAT-`\n * row logo and to a merchant's `fallback_guid`, which `MerchantLogo` draws through the same\n * `CategoryIcon` when the merchant image fails to load.\n */\nconst renderRowLogo = (row: InstanceSlotRow, resolveTopLevelCategory: (guid: string) => string) => {\n const logo = logoFromRef(row.logo, row.primary_text)\n\n if (!logo) return undefined\n\n if (logo.logo_name) {\n // A fixed box the size of the other logos keeps the row's text column aligned.\n return (\n <Box\n sx={{\n alignItems: 'center',\n display: 'flex',\n height: ROW_LOGO_SIZE,\n justifyContent: 'center',\n width: ROW_LOGO_SIZE,\n }}\n >\n <Icon name={logo.logo_name} size={ROW_ICON_SIZE} sx={{ color: logo.logo_color }} />\n </Box>\n )\n }\n\n if (logo.merchant_guid) {\n return (\n <MerchantLogo\n alt={logo.merchant_name ?? ''}\n categoryGuid={logo.category_guid ? resolveTopLevelCategory(logo.category_guid) : ''}\n merchantGuid={logo.merchant_guid}\n size={ROW_LOGO_SIZE}\n />\n )\n }\n\n if (logo.institution_guid) {\n return (\n <InstitutionLogo\n alt={logo.institution_name ?? ''}\n institutionGuid={logo.institution_guid}\n size={ROW_LOGO_SIZE}\n />\n )\n }\n\n if (logo.category_guid) {\n const topLevelGuid = resolveTopLevelCategory(logo.category_guid)\n return (\n <Box data-testid={`category-icon-${topLevelGuid}`} sx={{ display: 'flex' }}>\n <CategoryIcon categoryGuid={topLevelGuid} size={ROW_LOGO_SIZE} />\n </Box>\n )\n }\n\n return undefined\n}\n\n/**\n * The `transaction_block`: rows the backend already localized, carried inline on\n * `instance_slot.data.series` (`logo`, `primary_text`, `secondary_text`, `amount`). Only the\n * amount is formatted here, because the contract sends it as a number. `instance_slot.variant`\n * picks the header and slot treatment from `./layout.ts`.\n *\n * This is the full/mini shape. The reduced widgets (micro, embedded) resolve to the row logo\n * alone, carried flat on `data.logo` with no `series`, and are drawn by `CompactInsightCard`.\n *\n * `status_message` draws no rows: `data.message` beside the `data.icon` logo, as a\n * `StatusMessageCard` banner (Uncategorized Transactions V2 `complete`).\n *\n * A header, when the variant shows one, comes from `instance_slot.data.header_text` (the\n * transaction date, or \"{count} transactions\"). It deliberately does *not* come from the first\n * row: on a `with_merchant` card a row's `secondary_text` is the category, so reading it here\n * rendered the category twice and dropped the date entirely.\n *\n * A footer/summary row (Replenish Savings' \"Remaining Balance\") renders under the\n * `with_header_footer` variant, from `data.footer_text` with `data.footer_amount` beside it,\n * formatted like the row amounts (the contract sends it as a number).\n */\nexport const TransactionBlock = observer(({ payload }: TransactionBlockProps) => {\n const theme = useTheme()\n const { getTopLevelCategoryGuid } = useCategoryStore()\n const stores = useGlobalStore()\n const { recurring: recurringCopy } = useGlobalCopyStore()\n const { beat } = useBeatActions()\n const { data, variant } = payload.instance_slot\n // The plain row is the safe default: it adds nothing a wrong variant could misstate.\n const {\n answeredBackground,\n background,\n cardVariant,\n followsSubscription,\n raised,\n showFooter,\n showFrequency,\n showHeader,\n statusMessage,\n sx,\n } = resolveVariantConfig(\n getLayoutConfig(theme),\n variant,\n transactionBlockVariant.NoHeader,\n 'TransactionBlock',\n )\n\n // The live repeating transaction (read-only), for the frequency and the badge / answered wash.\n const repeating =\n (showFrequency || followsSubscription) && beat\n ? repeatingTransactionOf({ beat, stores })\n : undefined\n const subscribed = !!followsSubscription && repeating?.user_response === USER_RESPONSE.CONFIRMED\n\n if (statusMessage) {\n const message = slot<string>(data, 'message')\n if (typeof message !== 'string' || !message.trim()) {\n console.warn('[TransactionBlock] status_message has no message — rendering nothing.')\n return null\n }\n\n // The icon only decorates the message, so it is hidden from the status announcement.\n return (\n <StatusMessageCard\n icon={\n <Box aria-hidden=\"true\" sx={{ display: 'flex' }}>\n <LogoFromGuid logo={slot<LogoRef>(data, 'icon')} size={STATUS_ICON_SIZE} />\n </Box>\n }\n message={message}\n // The 20% wash layers over paper, as Figma's slot does.\n sx={background ? { backgroundImage: background, bgcolor: 'background.paper' } : undefined}\n />\n )\n }\n\n const series = slot<InstanceSlotRow[]>(data, 'series')\n const headerText = slot<string>(data, 'header_text')\n\n if (!Array.isArray(series) || !series.length) return null\n\n const header = showHeader && typeof headerText === 'string' ? headerText : undefined\n\n const footerText = slot<string>(data, 'footer_text')\n const footerAmount = slot<number>(data, 'footer_amount')\n const footer = showFooter\n ? {\n label: footerText,\n amount: formatCurrency(footerAmount, '0,0.00'),\n }\n : undefined\n\n // Live, as pulse: the repeating transaction the CTA's `prepare` loads.\n const frequency = showFrequency ? subscriptionFrequency(recurringCopy, repeating) : undefined\n const badge = followsSubscription ? (\n <SubscriptionBadge icon={slot<LogoRef>(data, subscribed ? 'reviewed_icon' : 'icon')} />\n ) : undefined\n\n return (\n <TransactionListCard\n background={subscribed && answeredBackground ? answeredBackground : background}\n badge={badge}\n footer={footer}\n header={header}\n raised={raised}\n sx={sx}\n variant={cardVariant}\n rows={series.map((row) => ({\n amount: typeof row.amount === 'number' ? formatCurrency(row.amount, '0,0.00') : '',\n amountCaption: frequency,\n leading: renderRowLogo(row, getTopLevelCategoryGuid),\n subtitle: row.secondary_text ?? '',\n title: row.primary_text ?? '',\n }))}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,IAAM,IAAgB,IAEhB,KAAgB,KAAK,MAAM,IAAgB,KAAK,GAChD,KAAmB,IAEnB,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|
|
1
|
+
{"version":3,"file":"TransactionBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport { useTheme } from '@mui/material/styles'\n\nimport { CategoryIcon, InstitutionLogo, MerchantLogo } from '@mxenabled/mxui'\nimport { Icon } from '@mxenabled/mx-icons'\n\nimport { useCategoryStore, useGlobalCopyStore, useGlobalStore } from '../../../../common'\nimport { slot } from '../../../../core'\nimport type { InsightsPayload, InstanceSlotRow, LogoRef } from '../../../../core'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\n\nimport { useBeatActions } from '../../../beatActions'\nimport LogoFromGuid from '../../../components/LogoFromGuid'\nimport StatusMessageCard from '../../../components/StatusMessageCard'\nimport TransactionListCard from '../../../components/TransactionListCard'\nimport { logoFromRef } from '../../../components/shared/EntityLogo'\nimport { statusIconName, statusIconPalette } from '../../../components/statusIcon'\nimport { subscriptionFrequency } from '../../../components/SubscriptionStatus/subscriptionFrequency'\nimport { repeatingTransactionOf, USER_RESPONSE } from '../../../ctaActions/subscriptionAnswer'\n\nimport { resolveVariantConfig } from '../../resolveVariantConfig'\nimport { getLayoutConfig, transactionBlockVariant } from './layout'\n\ninterface TransactionBlockProps {\n payload: InsightsPayload\n beatGuid?: string\n}\n\nconst ROW_LOGO_SIZE = 32\n// Same glyph-to-tile ratio mxui's `CategoryIcon` uses, so a status icon sits like the other logos.\nconst ROW_ICON_SIZE = Math.round(ROW_LOGO_SIZE * 0.625)\nconst STATUS_ICON_SIZE = 24\n// Status badge: palette disc, contrastText glyph.\nconst BADGE_SIZE = 32\nconst BADGE_GLYPH_SIZE = 20\n\n/** Status disc from `data.icon` / `data.reviewed_icon`. */\nconst SubscriptionBadge = ({ icon }: { icon?: LogoRef }) => {\n const name = statusIconName(icon?.guid)\n\n if (!name) return null\n\n return (\n <Box\n aria-hidden={true}\n data-icon={name}\n data-testid=\"subscription-badge\"\n sx={{\n alignItems: 'center',\n bgcolor: `${statusIconPalette(icon?.color)}.main`,\n borderRadius: '50%',\n display: 'flex',\n height: BADGE_SIZE,\n justifyContent: 'center',\n width: BADGE_SIZE,\n }}\n >\n <Icon\n fill={true}\n name={name}\n size={BADGE_GLYPH_SIZE}\n sx={{ color: `${statusIconPalette(icon?.color)}.contrastText` }}\n />\n </Box>\n )\n}\n\n/**\n * Renders the row's leading logo from its `LogoRef`: a status icon, or an entity guid whose prefix\n * names the entity. An unrecognized prefix renders no logo rather than guessing.\n *\n * `resolveTopLevelCategory`: mxui's `CategoryIcon` only knows the top-level category guids and\n * silently falls back to the Uncategorized icon for a sub-category. The details drawer avoids\n * this by passing `transaction.top_level_category_guid`; the row only has the raw guid, so it is\n * walked up to its parent here (identity until categories load). That applies both to a `CAT-`\n * row logo and to a merchant's `fallback_guid`, which `MerchantLogo` draws through the same\n * `CategoryIcon` when the merchant image fails to load.\n */\nconst renderRowLogo = (row: InstanceSlotRow, resolveTopLevelCategory: (guid: string) => string) => {\n const logo = logoFromRef(row.logo, row.primary_text)\n\n if (!logo) return undefined\n\n if (logo.logo_name) {\n // A fixed box the size of the other logos keeps the row's text column aligned.\n return (\n <Box\n sx={{\n alignItems: 'center',\n display: 'flex',\n height: ROW_LOGO_SIZE,\n justifyContent: 'center',\n width: ROW_LOGO_SIZE,\n }}\n >\n <Icon name={logo.logo_name} size={ROW_ICON_SIZE} sx={{ color: logo.logo_color }} />\n </Box>\n )\n }\n\n if (logo.merchant_guid) {\n return (\n <MerchantLogo\n alt={logo.merchant_name ?? ''}\n categoryGuid={logo.category_guid ? resolveTopLevelCategory(logo.category_guid) : ''}\n merchantGuid={logo.merchant_guid}\n size={ROW_LOGO_SIZE}\n />\n )\n }\n\n if (logo.institution_guid) {\n return (\n <InstitutionLogo\n alt={logo.institution_name ?? ''}\n institutionGuid={logo.institution_guid}\n size={ROW_LOGO_SIZE}\n />\n )\n }\n\n if (logo.category_guid) {\n const topLevelGuid = resolveTopLevelCategory(logo.category_guid)\n return (\n <Box data-testid={`category-icon-${topLevelGuid}`} sx={{ display: 'flex' }}>\n <CategoryIcon categoryGuid={topLevelGuid} size={ROW_LOGO_SIZE} />\n </Box>\n )\n }\n\n return undefined\n}\n\n/**\n * The `transaction_block`: rows the backend already localized, carried inline on\n * `instance_slot.data.series` (`logo`, `primary_text`, `secondary_text`, `amount`). Only the\n * amount is formatted here, because the contract sends it as a number. `instance_slot.variant`\n * picks the header and slot treatment from `./layout.ts`.\n *\n * This is the full/mini shape. The reduced widgets (micro, embedded) resolve to the row logo\n * alone, carried flat on `data.logo` with no `series`, and are drawn by `CompactInsightCard`.\n *\n * `status_message` draws no rows: `data.message` beside the `data.icon` logo, as a\n * `StatusMessageCard` banner (Uncategorized Transactions V2 `complete`).\n *\n * A header, when the variant shows one, comes from `instance_slot.data.header_text` (the\n * transaction date, or \"{count} transactions\"). It deliberately does *not* come from the first\n * row: on a `with_merchant` card a row's `secondary_text` is the category, so reading it here\n * rendered the category twice and dropped the date entirely.\n *\n * A footer/summary row (Replenish Savings' \"Remaining Balance\") renders under the\n * `with_header_footer` variant, from `data.footer_text` with `data.footer_amount` beside it,\n * formatted like the row amounts (the contract sends it as a number).\n */\nexport const TransactionBlock = observer(({ payload }: TransactionBlockProps) => {\n const theme = useTheme()\n const { getTopLevelCategoryGuid } = useCategoryStore()\n const stores = useGlobalStore()\n const { recurring: recurringCopy } = useGlobalCopyStore()\n const { beat } = useBeatActions()\n const { data, variant } = payload.instance_slot\n // The plain row is the safe default: it adds nothing a wrong variant could misstate.\n const {\n answeredBackground,\n background,\n cardVariant,\n elevated,\n followsSubscription,\n raised,\n showFooter,\n showFrequency,\n showHeader,\n statusMessage,\n sx,\n } = resolveVariantConfig(\n getLayoutConfig(theme),\n variant,\n transactionBlockVariant.NoHeader,\n 'TransactionBlock',\n )\n\n // The live repeating transaction (read-only), for the frequency and the badge / answered wash.\n const repeating =\n (showFrequency || followsSubscription) && beat\n ? repeatingTransactionOf({ beat, stores })\n : undefined\n const subscribed = !!followsSubscription && repeating?.user_response === USER_RESPONSE.CONFIRMED\n\n if (statusMessage) {\n const message = slot<string>(data, 'message')\n if (typeof message !== 'string' || !message.trim()) {\n console.warn('[TransactionBlock] status_message has no message — rendering nothing.')\n return null\n }\n\n // The icon only decorates the message, so it is hidden from the status announcement.\n return (\n <StatusMessageCard\n icon={\n <Box aria-hidden=\"true\" sx={{ display: 'flex' }}>\n <LogoFromGuid logo={slot<LogoRef>(data, 'icon')} size={STATUS_ICON_SIZE} />\n </Box>\n }\n message={message}\n // The 20% wash layers over paper, as Figma's slot does.\n sx={background ? { backgroundImage: background, bgcolor: 'background.paper' } : undefined}\n />\n )\n }\n\n const series = slot<InstanceSlotRow[]>(data, 'series')\n const headerText = slot<string>(data, 'header_text')\n\n if (!Array.isArray(series) || !series.length) return null\n\n const header = showHeader && typeof headerText === 'string' ? headerText : undefined\n\n const footerText = slot<string>(data, 'footer_text')\n const footerAmount = slot<number>(data, 'footer_amount')\n const footer = showFooter\n ? {\n label: footerText,\n amount: formatCurrency(footerAmount, '0,0.00'),\n }\n : undefined\n\n // Live, as pulse: the repeating transaction the CTA's `prepare` loads.\n const frequency = showFrequency ? subscriptionFrequency(recurringCopy, repeating) : undefined\n const badge = followsSubscription ? (\n <SubscriptionBadge icon={slot<LogoRef>(data, subscribed ? 'reviewed_icon' : 'icon')} />\n ) : undefined\n\n return (\n <TransactionListCard\n background={subscribed && answeredBackground ? answeredBackground : background}\n badge={badge}\n elevated={elevated}\n footer={footer}\n header={header}\n raised={raised}\n sx={sx}\n variant={cardVariant}\n rows={series.map((row) => ({\n amount: typeof row.amount === 'number' ? formatCurrency(row.amount, '0,0.00') : '',\n amountCaption: frequency,\n leading: renderRowLogo(row, getTopLevelCategoryGuid),\n subtitle: row.secondary_text ?? '',\n title: row.primary_text ?? '',\n }))}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,IAAM,IAAgB,I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kB;AAAA,MAChC,OAAO,EAAI,gBAAgB;AAAA,IAC7B,EAAE;AAAA,EACH,CAAA;AAEL,CAAC"}
|
|
@@ -42,6 +42,8 @@ export interface TransactionLayoutConfig {
|
|
|
42
42
|
followsSubscription?: boolean;
|
|
43
43
|
/** Wash once subscribed. */
|
|
44
44
|
answeredBackground?: string;
|
|
45
|
+
/** The rows' card on the wash gets `elevation/1` (needs `background`). */
|
|
46
|
+
elevated?: boolean;
|
|
45
47
|
/** Slot padding override (CSS shorthand). */
|
|
46
48
|
sx?: SxProps;
|
|
47
49
|
/** Border and shadow on the row card. */
|