@mx-cartographer/experiences 9.7.78 → 9.7.80
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 +14 -0
- package/dist/core/stores/GlobalCopyStore.d.ts +6 -0
- package/dist/core/stores/GlobalCopyStore.es.js +14 -8
- package/dist/core/stores/GlobalCopyStore.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +24 -0
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.d.ts +6 -0
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js +161 -0
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js.map +1 -0
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +86 -61
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.d.ts +7 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js +9 -5
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js +5 -5
- package/dist/insights-v2/components/BaseLayout.es.js +106 -105
- package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
- package/dist/insights-v2/components/CtaStatus.d.ts +5 -1
- package/dist/insights-v2/components/CtaStatus.es.js +25 -22
- package/dist/insights-v2/components/CtaStatus.es.js.map +1 -1
- package/dist/insights-v2/components/TransactionListCard.d.ts +5 -1
- package/dist/insights-v2/components/TransactionListCard.es.js +61 -45
- package/dist/insights-v2/components/TransactionListCard.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/ctaConfig.es.js +35 -14
- package/dist/insights-v2/ctaActions/ctaConfig.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/subscriptionAnswer.d.ts +9 -1
- package/dist/insights-v2/ctaActions/subscriptionAnswer.es.js +62 -57
- package/dist/insights-v2/ctaActions/subscriptionAnswer.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/types.d.ts +10 -2
- package/dist/insights-v2/ctaActions/useCtaAction.d.ts +5 -2
- package/dist/insights-v2/ctaActions/useCtaAction.es.js +45 -37
- package/dist/insights-v2/ctaActions/useCtaAction.es.js.map +1 -1
- package/dist/insights-v2/mappings/actionBlocksKey.d.ts +1 -0
- package/dist/insights-v2/mappings/actionBlocksKey.es.js +1 -0
- package/dist/insights-v2/mappings/actionBlocksKey.es.js.map +1 -1
- package/dist/insights-v2/mappings/blocks.es.js +82 -76
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/dist/microinsights/cards/InsightCard.es.js +92 -83
- package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
- package/dist/microinsights/cards/MicroCtaStatus.d.ts +18 -0
- package/dist/microinsights/cards/MicroCtaStatus.es.js +50 -0
- package/dist/microinsights/cards/MicroCtaStatus.es.js.map +1 -0
- package/dist/microinsights/stores/CopyStore.d.ts +10 -1
- package/dist/microinsights/stores/CopyStore.es.js +20 -11
- package/dist/microinsights/stores/CopyStore.es.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [9.7.80] - 11-03-2026
|
|
2
|
+
|
|
3
|
+
- **ADDED** - Storybook QA page showing every size and state of Large Transaction V2 and Large Transaction Pending V2, with new mock data in `mock/BlockBeatsData/LargeTransactionV2WidgetBeats.ts` (MEW2-3424)
|
|
4
|
+
|
|
5
|
+
## [9.7.79] - 11-03-2026
|
|
6
|
+
|
|
7
|
+
- **ADDED** - Unexpected Subscription Payment on the shared subscription status CTA (WEC-2126): `confirm_subscription_status` registers `subscriptionEntryStep({ statusLabels: { positive: 'subscribed', negative: 'not_subscribed' } })`, so the card follows the live repeating transaction as pulse did (none / `USER_RESPONSE_UNKNOWN` → Confirm Status, `CONFIRMED` → "Subscribed | Undo", any other answer → "Not subscribed | Undo"). New `subscription_status_modal_block`, a centred modal every widget's "Confirm Status" opens: the row from the opening CTA's `drilldown_data` with the live frequency, "I'm Subscribed" / "I'm Not Subscribed", then the three reasons; it saves through `answerSubscription`, reports the "No" press, and shows a success snackbar or an error one with Try Again. Words from the new optional `insights_feed.subscription_status_modal` copy (`SubscriptionStatusModalCopy`); a missing word renders nothing
|
|
8
|
+
- **ADDED** - `transaction_block` / `warning_wash` follows the beat's live repeating transaction: the frequency word under the amount (`showFrequency`, shared with `info_wash`) and, with `followsSubscription`, a status badge over the row (`TransactionListCard` `badge`: `data.icon` flag, `data.reviewed_icon` tick once subscribed) and the answered wash. It only reads the store
|
|
9
|
+
- **ADDED** - `CtaStep.compactStatus`: mini and micro mirror the step's status when their `in_description_cta` names it (USP opts in; Subscription Detected keeps its link). Micro resolves it through `MicroCtaStatusGate`: answered, it shows the opening block's `answeredTitle` (USP: "Unexpected Charge Reviewed"), `data.reviewed_icon` and the presenter's "Undo", and a tap goes to the host instead of re-opening the block; with missing data it shows no action
|
|
10
|
+
- **CHANGED** - Subscription Status dialogs: fixed `xs` width, white paper, 4px radius, full-bleed wash; reasons as 44px rows with inset dividers. `CtaStatus` gains `sx` and `CTA_STATUS_CONTENT_CLASS`; USP's white "Not subscribed" bar (paper fill, 50% black border, 70% icon) is its own step config (`subscriptionEntryStep` `negativeSx`), so the shared neutral tone is unchanged. The `warning_wash` badge is a 32px palette disc with a `contrastText` glyph; `TransactionListCard` gains `elevated`
|
|
11
|
+
- **CHANGED** - `useBeatCtaActions` returns `linkPresentation`, the state of the `linkCta`
|
|
12
|
+
(`in_description_cta`) step when it sets `compactStatus`; mini reads its label and answered title from it
|
|
13
|
+
- **FIXED** - The Subscription Status modal saves once per tap (in-flight guard) and clears the old notice on Try Again; an answered USP micro card's tap to the host keeps its `clicked_insight` analytics
|
|
14
|
+
|
|
1
15
|
## [9.7.78] - 11-02-2026
|
|
2
16
|
|
|
3
17
|
- **FIXED** - Save an Extra $100 amount spacing and the Uncategorized Transactions V2 "All Categorized!" banner now match Figma (WEC-2153, WEC-2155)
|
|
@@ -10,5 +10,11 @@ export declare class GlobalCopyStore {
|
|
|
10
10
|
constructor(globalStore: GlobalStore);
|
|
11
11
|
loadCopy: () => Promise<void>;
|
|
12
12
|
getCopy: (namespace: string, translationKey?: string) => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Merges an already-loaded section into `copy` (no request), for a host that did not load the
|
|
15
|
+
* copy, e.g. the micro widget handing over the insights_feed it loaded with its own copy. A
|
|
16
|
+
* section the store already has is kept.
|
|
17
|
+
*/
|
|
18
|
+
setSection: <K extends keyof GlobalCopy>(key: K, section: GlobalCopy[K] | undefined) => void;
|
|
13
19
|
private captureError;
|
|
14
20
|
}
|
|
@@ -1,36 +1,42 @@
|
|
|
1
|
-
import { GlobalCopyApi as
|
|
2
|
-
import { makeAutoObservable as a, runInAction as
|
|
3
|
-
var
|
|
1
|
+
import { GlobalCopyApi as i } from "../api/GlobalCopyApi.es.js";
|
|
2
|
+
import { makeAutoObservable as a, runInAction as r } from "mobx";
|
|
3
|
+
var c = class {
|
|
4
4
|
globalStore;
|
|
5
|
-
api = new
|
|
5
|
+
api = new i("/", "");
|
|
6
6
|
copy = {};
|
|
7
7
|
featureNamespace = "experiences";
|
|
8
8
|
isInitialized = !1;
|
|
9
9
|
constructor(t) {
|
|
10
|
-
this.globalStore = t, this.api = new
|
|
10
|
+
this.globalStore = t, this.api = new i(t.endpoint, t.sessionToken, t.onError), a(this);
|
|
11
11
|
}
|
|
12
12
|
loadCopy = async () => {
|
|
13
|
-
await this.getCopy(this.featureNamespace),
|
|
13
|
+
await this.getCopy(this.featureNamespace), r(() => {
|
|
14
14
|
this.isInitialized = !0;
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
getCopy = async (t, o = "") => {
|
|
18
18
|
try {
|
|
19
19
|
const e = await this.api.getGlobalCopy(t, o);
|
|
20
|
-
|
|
20
|
+
r(() => {
|
|
21
21
|
this.copy = e[t];
|
|
22
22
|
});
|
|
23
23
|
} catch (e) {
|
|
24
24
|
this.captureError("getCopy", e);
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
+
setSection = (t, o) => {
|
|
28
|
+
!o || this.copy?.[t] || (this.copy = {
|
|
29
|
+
...this.copy,
|
|
30
|
+
[t]: o
|
|
31
|
+
});
|
|
32
|
+
};
|
|
27
33
|
captureError = (t, o) => this.globalStore.captureException(o, {
|
|
28
34
|
store: "GlobalCopyStore",
|
|
29
35
|
action: t
|
|
30
36
|
});
|
|
31
37
|
};
|
|
32
38
|
export {
|
|
33
|
-
|
|
39
|
+
c as GlobalCopyStore
|
|
34
40
|
};
|
|
35
41
|
|
|
36
42
|
//# sourceMappingURL=GlobalCopyStore.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalCopyStore.es.js","names":[],"sources":["../../../src/core/stores/GlobalCopyStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { GlobalCopyApi } from '../api'\nimport { GlobalCopy } from '../types'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class GlobalCopyStore {\n globalStore: GlobalStore\n api: GlobalCopyApi = new GlobalCopyApi('/', '')\n\n copy: GlobalCopy = {} as GlobalCopy\n featureNamespace = 'experiences'\n\n isInitialized = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new GlobalCopyApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n\n makeAutoObservable(this)\n }\n\n loadCopy = async () => {\n await this.getCopy(this.featureNamespace)\n\n runInAction(() => {\n this.isInitialized = true\n })\n }\n\n getCopy = async (namespace: string, translationKey: string = '') => {\n try {\n const newCopy = await this.api.getGlobalCopy(namespace, translationKey)\n\n runInAction(() => {\n this.copy = newCopy[namespace]\n })\n } catch (error) {\n this.captureError('getCopy', error)\n }\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'GlobalCopyStore', action })\n}\n"],"mappings":";;AAOA,IAAa,IAAb,MAA6B;AAAA,EAC3B;AAAA,EACA,MAAqB,IAAI,EAAc,KAAK,EAAE;AAAA,EAE9C,OAAmB,CAAC;AAAA,EACpB,mBAAmB;AAAA,EAEnB,gBAAgB;AAAA,EAEhB,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EACb,EAAY,UACZ,EAAY,cACZ,EAAY,OACd,GAEA,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,WAAW,YAAY;AACrB,UAAM,KAAK,QAAQ,KAAK,gBAAgB,GAExC,EAAA,MAAkB;AAChB,WAAK,gBAAgB;AAAA,IACvB,CAAC;AAAA,EACH;AAAA,EAEA,UAAU,OAAO,GAAmB,IAAyB,OAAO;AAClE,QAAI;AACF,YAAM,IAAU,MAAM,KAAK,IAAI,cAAc,GAAW,CAAc;AAEtE,MAAA,EAAA,MAAkB;AAChB,aAAK,OAAO,EAAQ,CAAA;AAAA,MACtB,CAAC;AAAA,IACH,SAAS,GAAO;AACd,WAAK,aAAa,WAAW,CAAK;AAAA,IACpC;AAAA,EACF;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAmB,QAAA;AAAA,EAAO,CAAC;AACjF"}
|
|
1
|
+
{"version":3,"file":"GlobalCopyStore.es.js","names":[],"sources":["../../../src/core/stores/GlobalCopyStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { GlobalCopyApi } from '../api'\nimport { GlobalCopy } from '../types'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class GlobalCopyStore {\n globalStore: GlobalStore\n api: GlobalCopyApi = new GlobalCopyApi('/', '')\n\n copy: GlobalCopy = {} as GlobalCopy\n featureNamespace = 'experiences'\n\n isInitialized = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new GlobalCopyApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n\n makeAutoObservable(this)\n }\n\n loadCopy = async () => {\n await this.getCopy(this.featureNamespace)\n\n runInAction(() => {\n this.isInitialized = true\n })\n }\n\n getCopy = async (namespace: string, translationKey: string = '') => {\n try {\n const newCopy = await this.api.getGlobalCopy(namespace, translationKey)\n\n runInAction(() => {\n this.copy = newCopy[namespace]\n })\n } catch (error) {\n this.captureError('getCopy', error)\n }\n }\n\n /**\n * Merges an already-loaded section into `copy` (no request), for a host that did not load the\n * copy, e.g. the micro widget handing over the insights_feed it loaded with its own copy. A\n * section the store already has is kept.\n */\n setSection = <K extends keyof GlobalCopy>(key: K, section: GlobalCopy[K] | undefined) => {\n if (!section || this.copy?.[key]) return\n\n this.copy = { ...this.copy, [key]: section }\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'GlobalCopyStore', action })\n}\n"],"mappings":";;AAOA,IAAa,IAAb,MAA6B;AAAA,EAC3B;AAAA,EACA,MAAqB,IAAI,EAAc,KAAK,EAAE;AAAA,EAE9C,OAAmB,CAAC;AAAA,EACpB,mBAAmB;AAAA,EAEnB,gBAAgB;AAAA,EAEhB,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EACb,EAAY,UACZ,EAAY,cACZ,EAAY,OACd,GAEA,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,WAAW,YAAY;AACrB,UAAM,KAAK,QAAQ,KAAK,gBAAgB,GAExC,EAAA,MAAkB;AAChB,WAAK,gBAAgB;AAAA,IACvB,CAAC;AAAA,EACH;AAAA,EAEA,UAAU,OAAO,GAAmB,IAAyB,OAAO;AAClE,QAAI;AACF,YAAM,IAAU,MAAM,KAAK,IAAI,cAAc,GAAW,CAAc;AAEtE,MAAA,EAAA,MAAkB;AAChB,aAAK,OAAO,EAAQ,CAAA;AAAA,MACtB,CAAC;AAAA,IACH,SAAS,GAAO;AACd,WAAK,aAAa,WAAW,CAAK;AAAA,IACpC;AAAA,EACF;AAAA,EAOA,aAAA,CAA0C,GAAQ,MAAuC;AACvF,IAAI,CAAC,KAAW,KAAK,OAAO,CAAA,MAE5B,KAAK,OAAO;AAAA,MAAE,GAAG,KAAK;AAAA,MAAO,CAAA,CAAA,GAAM;AAAA,IAAQ;AAAA,EAC7C;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAmB,QAAA;AAAA,EAAO,CAAC;AACjF"}
|
|
@@ -194,6 +194,28 @@ export interface SurveyModalCopy {
|
|
|
194
194
|
/** ARIA label for the snackbar close button. */
|
|
195
195
|
toast_close_aria: string;
|
|
196
196
|
}
|
|
197
|
+
/** Subscription Status modal words. */
|
|
198
|
+
export interface SubscriptionStatusModalCopy {
|
|
199
|
+
/** Dialog title. */
|
|
200
|
+
title: string;
|
|
201
|
+
/** Positive answer. */
|
|
202
|
+
subscribed_answer: string;
|
|
203
|
+
/** Negative answer; opens the reasons. */
|
|
204
|
+
not_subscribed_answer: string;
|
|
205
|
+
/** Reasons. */
|
|
206
|
+
never_subscribed: string;
|
|
207
|
+
cancelled: string;
|
|
208
|
+
one_time_purchase: string;
|
|
209
|
+
/** Micro title once answered. */
|
|
210
|
+
reviewed_title: string;
|
|
211
|
+
/** Snackbar words. */
|
|
212
|
+
success_message: string;
|
|
213
|
+
error_message: string;
|
|
214
|
+
try_again: string;
|
|
215
|
+
/** Close labels. */
|
|
216
|
+
close_aria: string;
|
|
217
|
+
toast_close_aria: string;
|
|
218
|
+
}
|
|
197
219
|
/** Connection-details education drilldown (`connection_detail_block`). */
|
|
198
220
|
export interface ConnectionDetailsCopy {
|
|
199
221
|
aria_label_thumbs_down: string;
|
|
@@ -423,6 +445,8 @@ export interface InsightsFeedCopy {
|
|
|
423
445
|
connection_details?: ConnectionDetailsCopy;
|
|
424
446
|
/** Optional: every caller already null-guards (`copyStore.insights_feed?.survey_modal`). */
|
|
425
447
|
survey_modal?: SurveyModalCopy;
|
|
448
|
+
/** Subscription Status modal words. */
|
|
449
|
+
subscription_status_modal?: SubscriptionStatusModalCopy;
|
|
426
450
|
feedback_bar: FeedbackBarCopy;
|
|
427
451
|
dismiss: DismissInsightCopy;
|
|
428
452
|
/** Optional until the localized-content service ships the namespace. */
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionBlockProps } from '../mappings/blocks';
|
|
2
|
+
/** Unexpected Subscription Payment's Subscription Status modal. */
|
|
3
|
+
export declare const SubscriptionStatusModalBlock: (({ beat, }: ActionBlockProps) => import("react/jsx-runtime").JSX.Element | null) & {
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
export default SubscriptionStatusModalBlock;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { useGlobalCopyStore as V, useGlobalStore as X, useInsightsV2Store as $ } from "../../common/context/hooks.es.js";
|
|
2
|
+
import { slot as d } from "../../core/types/Insights.es.js";
|
|
3
|
+
import { formatCurrency as q } from "../../core/utils/NumberFormatting.es.js";
|
|
4
|
+
import R from "../../common/components/dialog/Dialog.es.js";
|
|
5
|
+
import { useBeatActions as Z } from "../beatActions.es.js";
|
|
6
|
+
import { USER_RESPONSE as f, answerSubscription as J, repeatingTransactionOf as K, reportSubscriptionMarkedIncorrect as Q } from "../ctaActions/subscriptionAnswer.es.js";
|
|
7
|
+
import Y from "../components/LogoFromGuid.es.js";
|
|
8
|
+
import "../components/celebrationGradients.es.js";
|
|
9
|
+
import rr from "../components/TransactionListCard.es.js";
|
|
10
|
+
import { subscriptionFrequency as tr } from "../components/SubscriptionStatus/subscriptionFrequency.es.js";
|
|
11
|
+
import er from "../components/shared/StatusSnackbar.es.js";
|
|
12
|
+
import { getDynamicCtaBasedOnTriggers as or } from "./util.es.js";
|
|
13
|
+
import { useEffect as sr, useRef as M, useState as T } from "react";
|
|
14
|
+
import { observer as nr } from "mobx-react-lite";
|
|
15
|
+
import B from "@mui/material/Stack";
|
|
16
|
+
import { Text as ir } from "@mxenabled/mxui";
|
|
17
|
+
import { Icon as ar } from "@mxenabled/mx-icons";
|
|
18
|
+
import { Fragment as cr, jsx as e, jsxs as C } from "react/jsx-runtime";
|
|
19
|
+
import lr from "@mui/material/Divider";
|
|
20
|
+
import ur from "@mui/material/ButtonBase";
|
|
21
|
+
var mr = 32, G = {
|
|
22
|
+
backgroundColor: "background.paper",
|
|
23
|
+
borderRadius: 1
|
|
24
|
+
}, L = {
|
|
25
|
+
"& .MuiDialog-paper": G,
|
|
26
|
+
"& .MuiDialogContent-root": { p: 0 }
|
|
27
|
+
}, pr = [
|
|
28
|
+
["never_subscribed", f.NEVER_SUBSCRIBED],
|
|
29
|
+
["cancelled", f.CANCELLED],
|
|
30
|
+
["one_time_purchase", f.ONE_TIME_PURCHASE]
|
|
31
|
+
], t = (i) => typeof i == "string" && i.trim() ? i : void 0, Tr = nr(function({ beat: x }) {
|
|
32
|
+
const P = X(), { insights_feed: _, recurring: F } = V(), { actionDrawer: W, closeActionDrawer: g } = $(), U = Z(), [E, b] = T("answers"), [o, a] = T(null), c = M(!1), y = M(!1), r = _?.subscription_status_modal, l = x.insights_payload, S = pr.flatMap(([s, m]) => {
|
|
33
|
+
const p = t(r?.[s]);
|
|
34
|
+
return p ? [{
|
|
35
|
+
label: p,
|
|
36
|
+
userResponse: m
|
|
37
|
+
}] : [];
|
|
38
|
+
}), D = !!t(r?.title) && !!t(r?.subscribed_answer) && !!t(r?.not_subscribed_answer) && S.length > 0, I = !!_ && !D;
|
|
39
|
+
if (sr(() => {
|
|
40
|
+
I && (console.warn("[SubscriptionStatusModalBlock] subscription_status_modal is missing its title, answers or reasons; closing."), g());
|
|
41
|
+
}, [I, g]), !l || !r || !D) return null;
|
|
42
|
+
const h = t(r.close_aria) ?? t(r.toast_close_aria) ?? t(_?.settings_menu?.close) ?? "", O = o && t(o.severity === "success" ? r.success_message : r.error_message), v = {
|
|
43
|
+
beat: x,
|
|
44
|
+
stores: P,
|
|
45
|
+
hostActions: U
|
|
46
|
+
}, u = or(W, l.primary_cta, l.secondary_cta, l.in_description_cta)?.drilldown_data ?? {}, k = d(u, "logo"), w = d(u, "primary_text"), N = d(u, "amount"), A = async (s) => {
|
|
47
|
+
if (!y.current) {
|
|
48
|
+
y.current = !0, a(null), b("saving");
|
|
49
|
+
try {
|
|
50
|
+
await J(v, s), t(r.success_message) ? a({ severity: "success" }) : n();
|
|
51
|
+
} catch {
|
|
52
|
+
t(r.error_message) ? a({
|
|
53
|
+
severity: "error",
|
|
54
|
+
retry: s
|
|
55
|
+
}) : n();
|
|
56
|
+
} finally {
|
|
57
|
+
y.current = !1;
|
|
58
|
+
}
|
|
59
|
+
b("done");
|
|
60
|
+
}
|
|
61
|
+
}, n = () => {
|
|
62
|
+
a(null), g();
|
|
63
|
+
}, j = () => {
|
|
64
|
+
c.current = !0, Q(v), b("reasons");
|
|
65
|
+
}, H = () => {
|
|
66
|
+
c.current = !0, A(f.CONFIRMED);
|
|
67
|
+
}, z = () => {
|
|
68
|
+
if (c.current) {
|
|
69
|
+
c.current = !1;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
n();
|
|
73
|
+
};
|
|
74
|
+
return /* @__PURE__ */ C(cr, { children: [
|
|
75
|
+
/* @__PURE__ */ e(R, {
|
|
76
|
+
copy: {
|
|
77
|
+
title: r.title,
|
|
78
|
+
close_aria: h
|
|
79
|
+
},
|
|
80
|
+
fullWidth: !0,
|
|
81
|
+
isOpen: E === "answers",
|
|
82
|
+
onClose: z,
|
|
83
|
+
onPrimaryAction: H,
|
|
84
|
+
onSecondaryAction: j,
|
|
85
|
+
primaryText: r.subscribed_answer,
|
|
86
|
+
secondaryText: r.not_subscribed_answer,
|
|
87
|
+
sx: L,
|
|
88
|
+
children: typeof w == "string" && w && /* @__PURE__ */ e(rr, {
|
|
89
|
+
background: "linear-gradient(201deg, rgba(255, 170, 0, 0.25) 1.86%, rgba(255, 68, 0, 0.25) 101.54%)",
|
|
90
|
+
elevated: !0,
|
|
91
|
+
rows: [{
|
|
92
|
+
amount: typeof N == "number" ? q(N, "0,0.00") : "",
|
|
93
|
+
amountCaption: tr(F, K(v)),
|
|
94
|
+
leading: k ? /* @__PURE__ */ e(Y, {
|
|
95
|
+
logo: k,
|
|
96
|
+
size: mr
|
|
97
|
+
}) : void 0,
|
|
98
|
+
subtitle: d(u, "secondary_text") ?? "",
|
|
99
|
+
title: w
|
|
100
|
+
}]
|
|
101
|
+
})
|
|
102
|
+
}),
|
|
103
|
+
/* @__PURE__ */ e(R, {
|
|
104
|
+
copy: {
|
|
105
|
+
title: r.title,
|
|
106
|
+
close_aria: h
|
|
107
|
+
},
|
|
108
|
+
fullWidth: !0,
|
|
109
|
+
isOpen: E === "reasons",
|
|
110
|
+
onClose: n,
|
|
111
|
+
showActions: !1,
|
|
112
|
+
sx: {
|
|
113
|
+
...L,
|
|
114
|
+
"& .MuiDialog-paper": {
|
|
115
|
+
...G,
|
|
116
|
+
pb: 16
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
children: /* @__PURE__ */ e(B, { children: S.map(({ label: s, userResponse: m }, p) => /* @__PURE__ */ C(B, { children: [/* @__PURE__ */ C(ur, {
|
|
120
|
+
onClick: () => {
|
|
121
|
+
A(m);
|
|
122
|
+
},
|
|
123
|
+
sx: {
|
|
124
|
+
gap: 12,
|
|
125
|
+
justifyContent: "space-between",
|
|
126
|
+
minHeight: 44,
|
|
127
|
+
px: 24,
|
|
128
|
+
py: 8,
|
|
129
|
+
textAlign: "left",
|
|
130
|
+
width: "100%"
|
|
131
|
+
},
|
|
132
|
+
children: [/* @__PURE__ */ e(ir, {
|
|
133
|
+
variant: "body1",
|
|
134
|
+
children: s
|
|
135
|
+
}), /* @__PURE__ */ e(ar, {
|
|
136
|
+
"aria-hidden": !0,
|
|
137
|
+
name: "chevron_right",
|
|
138
|
+
size: 24,
|
|
139
|
+
sx: { color: "action.active" }
|
|
140
|
+
})]
|
|
141
|
+
}), p < S.length - 1 && /* @__PURE__ */ e(lr, { sx: { ml: 24 } })] }, m)) })
|
|
142
|
+
}),
|
|
143
|
+
o && O && /* @__PURE__ */ e(er, {
|
|
144
|
+
actionText: o.retry ? t(r.try_again) : void 0,
|
|
145
|
+
closeAriaLabel: t(r.toast_close_aria) ?? h,
|
|
146
|
+
message: O,
|
|
147
|
+
onActionClick: o.retry ? () => {
|
|
148
|
+
A(o.retry);
|
|
149
|
+
} : void 0,
|
|
150
|
+
onClose: n,
|
|
151
|
+
open: !0,
|
|
152
|
+
severity: o.severity
|
|
153
|
+
})
|
|
154
|
+
] });
|
|
155
|
+
});
|
|
156
|
+
export {
|
|
157
|
+
Tr as SubscriptionStatusModalBlock,
|
|
158
|
+
Tr as default
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
//# sourceMappingURL=SubscriptionStatusModalBlock.es.js.map
|
|
@@ -0,0 +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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
import { repeatingTransactionOf as
|
|
6
|
-
import { logoFromRef as
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
1
|
+
import { useCategoryStore as F, useGlobalCopyStore as N, useGlobalStore as M } from "../../../../common/context/hooks.es.js";
|
|
2
|
+
import { slot as a } from "../../../../core/types/Insights.es.js";
|
|
3
|
+
import { formatCurrency as x } from "../../../../core/utils/NumberFormatting.es.js";
|
|
4
|
+
import { useBeatActions as Z } from "../../../beatActions.es.js";
|
|
5
|
+
import { USER_RESPONSE as $, repeatingTransactionOf as j } from "../../../ctaActions/subscriptionAnswer.es.js";
|
|
6
|
+
import { logoFromRef as q } from "../../../components/shared/EntityLogo.es.js";
|
|
7
|
+
import D from "../../../components/LogoFromGuid.es.js";
|
|
8
|
+
import { statusIconName as H, statusIconPalette as b } from "../../../components/statusIcon.es.js";
|
|
9
|
+
import { resolveVariantConfig as P } from "../../resolveVariantConfig.es.js";
|
|
10
|
+
import V from "../../../components/TransactionListCard.es.js";
|
|
11
|
+
import U from "../../../components/StatusMessageCard.es.js";
|
|
12
|
+
import { subscriptionFrequency as W } from "../../../components/SubscriptionStatus/subscriptionFrequency.es.js";
|
|
13
|
+
import { getLayoutConfig as Y, transactionBlockVariant as J } from "./layout.es.js";
|
|
14
|
+
import { observer as K } from "mobx-react-lite";
|
|
15
|
+
import { CategoryIcon as Q, InstitutionLogo as X, MerchantLogo as oo } from "@mxenabled/mxui";
|
|
16
|
+
import { Icon as I } from "@mxenabled/mx-icons";
|
|
16
17
|
import { jsx as t } from "react/jsx-runtime";
|
|
17
|
-
import { useTheme as
|
|
18
|
-
import
|
|
19
|
-
var
|
|
20
|
-
const
|
|
18
|
+
import { useTheme as to } from "@mui/material/styles";
|
|
19
|
+
import u from "@mui/material/Box";
|
|
20
|
+
var s = 32, ro = Math.round(s * 0.625), eo = 24, v = 32, no = 20, io = ({ icon: e }) => {
|
|
21
|
+
const n = H(e?.guid);
|
|
22
|
+
return n ? /* @__PURE__ */ t(u, {
|
|
23
|
+
"aria-hidden": !0,
|
|
24
|
+
"data-icon": n,
|
|
25
|
+
"data-testid": "subscription-badge",
|
|
26
|
+
sx: {
|
|
27
|
+
alignItems: "center",
|
|
28
|
+
bgcolor: `${b(e?.color)}.main`,
|
|
29
|
+
borderRadius: "50%",
|
|
30
|
+
display: "flex",
|
|
31
|
+
height: v,
|
|
32
|
+
justifyContent: "center",
|
|
33
|
+
width: v
|
|
34
|
+
},
|
|
35
|
+
children: /* @__PURE__ */ t(I, {
|
|
36
|
+
fill: !0,
|
|
37
|
+
name: n,
|
|
38
|
+
size: no,
|
|
39
|
+
sx: { color: `${b(e?.color)}.contrastText` }
|
|
40
|
+
})
|
|
41
|
+
}) : null;
|
|
42
|
+
}, ao = (e, n) => {
|
|
43
|
+
const o = q(e.logo, e.primary_text);
|
|
21
44
|
if (o) {
|
|
22
|
-
if (o.logo_name) return /* @__PURE__ */ t(
|
|
45
|
+
if (o.logo_name) return /* @__PURE__ */ t(u, {
|
|
23
46
|
sx: {
|
|
24
47
|
alignItems: "center",
|
|
25
48
|
display: "flex",
|
|
26
|
-
height:
|
|
49
|
+
height: s,
|
|
27
50
|
justifyContent: "center",
|
|
28
|
-
width:
|
|
51
|
+
width: s
|
|
29
52
|
},
|
|
30
|
-
children: /* @__PURE__ */ t(
|
|
53
|
+
children: /* @__PURE__ */ t(I, {
|
|
31
54
|
name: o.logo_name,
|
|
32
|
-
size:
|
|
55
|
+
size: ro,
|
|
33
56
|
sx: { color: o.logo_color }
|
|
34
57
|
})
|
|
35
58
|
});
|
|
36
|
-
if (o.merchant_guid) return /* @__PURE__ */ t(
|
|
59
|
+
if (o.merchant_guid) return /* @__PURE__ */ t(oo, {
|
|
37
60
|
alt: o.merchant_name ?? "",
|
|
38
|
-
categoryGuid: o.category_guid ?
|
|
61
|
+
categoryGuid: o.category_guid ? n(o.category_guid) : "",
|
|
39
62
|
merchantGuid: o.merchant_guid,
|
|
40
|
-
size:
|
|
63
|
+
size: s
|
|
41
64
|
});
|
|
42
|
-
if (o.institution_guid) return /* @__PURE__ */ t(
|
|
65
|
+
if (o.institution_guid) return /* @__PURE__ */ t(X, {
|
|
43
66
|
alt: o.institution_name ?? "",
|
|
44
67
|
institutionGuid: o.institution_guid,
|
|
45
|
-
size:
|
|
68
|
+
size: s
|
|
46
69
|
});
|
|
47
70
|
if (o.category_guid) {
|
|
48
|
-
const c =
|
|
49
|
-
return /* @__PURE__ */ t(
|
|
71
|
+
const c = n(o.category_guid);
|
|
72
|
+
return /* @__PURE__ */ t(u, {
|
|
50
73
|
"data-testid": `category-icon-${c}`,
|
|
51
74
|
sx: { display: "flex" },
|
|
52
|
-
children: /* @__PURE__ */ t(
|
|
75
|
+
children: /* @__PURE__ */ t(Q, {
|
|
53
76
|
categoryGuid: c,
|
|
54
|
-
size:
|
|
77
|
+
size: s
|
|
55
78
|
})
|
|
56
79
|
});
|
|
57
80
|
}
|
|
58
81
|
}
|
|
59
|
-
},
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
82
|
+
}, To = K(({ payload: e }) => {
|
|
83
|
+
const n = to(), { getTopLevelCategoryGuid: o } = F(), c = M(), { recurring: S } = N(), { beat: l } = Z(), { data: i, variant: C } = e.instance_slot, { answeredBackground: f, background: m, cardVariant: G, followsSubscription: d, showFooter: E, showFrequency: p, showHeader: T, statusMessage: B, sx: k } = P(Y(n), C, J.NoHeader, "TransactionBlock"), _ = (p || d) && l ? j({
|
|
84
|
+
beat: l,
|
|
85
|
+
stores: c
|
|
86
|
+
}) : void 0, y = !!d && _?.user_response === $.CONFIRMED;
|
|
87
|
+
if (B) {
|
|
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(U, {
|
|
90
|
+
icon: /* @__PURE__ */ t(u, {
|
|
65
91
|
"aria-hidden": "true",
|
|
66
92
|
sx: { display: "flex" },
|
|
67
|
-
children: /* @__PURE__ */ t(
|
|
68
|
-
logo:
|
|
69
|
-
size:
|
|
93
|
+
children: /* @__PURE__ */ t(D, {
|
|
94
|
+
logo: a(i, "icon"),
|
|
95
|
+
size: eo
|
|
70
96
|
})
|
|
71
97
|
}),
|
|
72
98
|
message: r,
|
|
@@ -76,31 +102,30 @@ var i = 32, U = Math.round(i * 0.625), D = 24, J = (a, s) => {
|
|
|
76
102
|
} : void 0
|
|
77
103
|
});
|
|
78
104
|
}
|
|
79
|
-
const
|
|
80
|
-
if (!Array.isArray(
|
|
81
|
-
const
|
|
82
|
-
label:
|
|
83
|
-
amount:
|
|
84
|
-
} : void 0,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
leading: J(r, o),
|
|
105
|
+
const g = a(i, "series"), h = a(i, "header_text");
|
|
106
|
+
if (!Array.isArray(g) || !g.length) return null;
|
|
107
|
+
const L = T && typeof h == "string" ? h : void 0, O = a(i, "footer_text"), R = a(i, "footer_amount"), A = E ? {
|
|
108
|
+
label: O,
|
|
109
|
+
amount: x(R, "0,0.00")
|
|
110
|
+
} : void 0, w = p ? W(S, _) : void 0, z = d ? /* @__PURE__ */ t(io, { icon: a(i, y ? "reviewed_icon" : "icon") }) : void 0;
|
|
111
|
+
return /* @__PURE__ */ t(V, {
|
|
112
|
+
background: y && f ? f : m,
|
|
113
|
+
badge: z,
|
|
114
|
+
footer: A,
|
|
115
|
+
header: L,
|
|
116
|
+
sx: k,
|
|
117
|
+
variant: G,
|
|
118
|
+
rows: g.map((r) => ({
|
|
119
|
+
amount: typeof r.amount == "number" ? x(r.amount, "0,0.00") : "",
|
|
120
|
+
amountCaption: w,
|
|
121
|
+
leading: ao(r, o),
|
|
97
122
|
subtitle: r.secondary_text ?? "",
|
|
98
123
|
title: r.primary_text ?? ""
|
|
99
124
|
}))
|
|
100
125
|
});
|
|
101
126
|
});
|
|
102
127
|
export {
|
|
103
|
-
|
|
128
|
+
To as TransactionBlock
|
|
104
129
|
};
|
|
105
130
|
|
|
106
131
|
//# 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 { subscriptionFrequency } from '../../../components/SubscriptionStatus/subscriptionFrequency'\nimport { repeatingTransactionOf } 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)\n// Figma's status banner draws a 24px check_circle, so its row is 64px tall.\nconst STATUS_ICON_SIZE = 24\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 { background, cardVariant, showFooter, showFrequency, showHeader, statusMessage } =\n resolveVariantConfig(\n getLayoutConfig(theme),\n variant,\n transactionBlockVariant.NoHeader,\n 'TransactionBlock',\n )\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 =\n showFrequency && beat\n ? subscriptionFrequency(recurringCopy, repeatingTransactionOf({ beat, stores }))\n : undefined\n\n return (\n <TransactionListCard\n background={background}\n footer={footer}\n header={header}\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":";;;;;;;;;;;;;;;;;;AA6BA,IAAM,IAAgB,IAEhB,IAAgB,KAAK,MAAM,IAAgB,KAAK,GAEhD,IAAmB,IAanB,IAAA,CAAiB,GAAsB,MAAsD;AACjG,QAAM,IAAO,EAAY,EAAI,MAAM,EAAI,YAAY;AAEnD,MAAK,GAEL;AAAA,QAAI,EAAK,UAEP,QACE,gBAAA,EAAC,GAAD;AAAA,MACE,IAAI;AAAA,QACF,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,gBAAgB;AAAA,QAChB,OAAO;AAAA,MACT;AAAA,MAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,QAAM,MAAM,EAAK;AAAA,QAAW,MAAM;AAAA,QAAe,IAAI,EAAE,OAAO,EAAK,WAAW;AAAA,MAAI,CAAA;AAAA,IAC/E,CAAA;AAIT,QAAI,EAAK,cACP,QACE,gBAAA,EAAC,GAAD;AAAA,MACE,KAAK,EAAK,iBAAiB;AAAA,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A,EAAC,GAAD;AAAA,UAAc,MAAM,EAAc,GAAM,MAAM;AAAA,UAAG,MAAM;AAAA,QAAmB,CAAA;AAAA,MACvE,CAAA;AAAA,MAEE,SAAA;AAAA,MAET,IAAI,IAAa;AAAA,QAAE,iBAAiB;AAAA,QAAY,SAAS;AAAA,MAAmB,IAAI;AAAA,IACjF,CAAA;AAAA,EAEL;AAEA,QAAM,IAAS,EAAwB,GAAM,QAAQ,GAC/C,IAAa,EAAa,GAAM,aAAa;AAEnD,MAAI,CAAC,MAAM,QAAQ,CAAM,KAAK,CAAC,EAAO,OAAQ,QAAO;AAErD,QAAM,IAAS,KAAc,OAAO,KAAe,WAAW,IAAa,QAErE,IAAa,EAAa,GAAM,aAAa,GAC7C,IAAe,EAAa,GAAM,eAAe,GACjD,IAAS,IACX;AAAA,IACE,OAAO;AAAA,IACP,QAAQ,EAAe,GAAc,QAAQ;AAAA,EAC/C,IACA,QAGE,IACJ,KAAiB,IACb,EAAsB,GAAe,EAAuB;AAAA,IAAE,MAAA;AAAA,IAAM,QAAA;AAAA,EAAO,CAAC,CAAC,IAC7E;AAEN,SACE,gBAAA,EAAC,GAAD;AAAA,IACc,YAAA;AAAA,IACJ,QAAA;AAAA,IACA,QAAA;AAAA,IACR,SAAS;AAAA,IACT,MAAM,EAAO,IAAA,CAAK,OAAS;AAAA,MACzB,QAAQ,OAAO,EAAI,UAAW,WAAW,EAAe,EAAI,QAAQ,QAAQ,IAAI;AAAA,MAChF,eAAe;AAAA,MACf,SAAS,EAAc,GAAK,CAAuB;AAAA,MACnD,UAAU,EAAI,kBAAkB;AAAA,MAChC,OAAO,EAAI,gBAAgB;AAAA,IAC7B,EAAE;AAAA,EACH,CAAA;AAEL,CAAC"}
|
|
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 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 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,IAAa,IACb,KAAmB,IAGnB,KAAA,CAAqB,EAAE,MAAA,EAAA,MAA+B;AAC1D,QAAM,IAAO,EAAe,GAAM,IAAI;AAEtC,SAAK,IAGH,gBAAA,EAAC,GAAD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,CAAA;AAAA,MAEE,SAAA;AAAA,MAET,IAAI,IAAa;AAAA,QAAE,iBAAiB;AAAA,QAAY,SAAS;AAAA,MAAmB,IAAI;AAAA,IACjF,CAAA;AAAA,EAEL;AAEA,QAAM,IAAS,EAAwB,GAAM,QAAQ,GAC/C,IAAa,EAAa,GAAM,aAAa;AAEnD,MAAI,CAAC,MAAM,QAAQ,CAAM,KAAK,CAAC,EAAO,OAAQ,QAAO;AAErD,QAAM,IAAS,KAAc,OAAO,KAAe,WAAW,IAAa,QAErE,IAAa,EAAa,GAAM,aAAa,GAC7C,IAAe,EAAa,GAAM,eAAe,GACjD,IAAS,IACX;AAAA,IACE,OAAO;AAAA,IACP,QAAQ,EAAe,GAAc,QAAQ;AAAA,EAC/C,IACA,QAGE,IAAY,IAAgB,EAAsB,GAAe,CAAS,IAAI,QAC9E,IAAQ,IACZ,gBAAA,EAAC,IAAD,EAAmB,MAAM,EAAc,GAAM,IAAa,kBAAkB,MAAM,EAAI,CAAA,IACpF;AAEJ,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,YAAY,KAAc,IAAqB,IAAqB;AAAA,IAC7D,OAAA;AAAA,IACC,QAAA;AAAA,IACA,QAAA;AAAA,IACJ,IAAA;AAAA,IACJ,SAAS;AAAA,IACT,MAAM,EAAO,IAAA,CAAK,OAAS;AAAA,MACzB,QAAQ,OAAO,EAAI,UAAW,WAAW,EAAe,EAAI,QAAQ,QAAQ,IAAI;AAAA,MAChF,eAAe;AAAA,MACf,SAAS,GAAc,GAAK,CAAuB;AAAA,MACnD,UAAU,EAAI,kBAAkB;AAAA,MAChC,OAAO,EAAI,gBAAgB;AAAA,IAC7B,EAAE;AAAA,EACH,CAAA;AAEL,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Theme } from '@mui/material/styles';
|
|
1
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
2
2
|
/**
|
|
3
3
|
* Transaction block variants, keyed by the backend `instance_slot.variant`. All render the same
|
|
4
4
|
* pre-localized rows through `TransactionListCard`; only the header and the slot differ.
|
|
@@ -38,6 +38,12 @@ export interface TransactionLayoutConfig {
|
|
|
38
38
|
statusMessage?: boolean;
|
|
39
39
|
/** Caption each amount with the beat's live repeating transaction frequency. */
|
|
40
40
|
showFrequency?: boolean;
|
|
41
|
+
/** Status badge and answered wash from the live repeating transaction. */
|
|
42
|
+
followsSubscription?: boolean;
|
|
43
|
+
/** Wash once subscribed. */
|
|
44
|
+
answeredBackground?: string;
|
|
45
|
+
/** Slot padding override (CSS shorthand). */
|
|
46
|
+
sx?: SxProps;
|
|
41
47
|
}
|
|
42
48
|
/** Per-variant `TransactionListCard` props (mirrors DetailedAccountBlock's `getLayoutConfig`). */
|
|
43
49
|
export declare const getLayoutConfig: (theme: Theme) => Record<TransactionBlockVariant, TransactionLayoutConfig>;
|