@mx-cartographer/experiences 9.7.65 → 9.7.66
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 +5 -0
- package/README.md +1 -1
- package/dist/core/stores/RecurringTransactionsStore.es.js +27 -22
- package/dist/core/stores/RecurringTransactionsStore.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +6 -0
- package/dist/insights-v2/analytics/analyticsEventsConfig.d.ts +29 -0
- package/dist/insights-v2/analytics/analyticsEventsConfig.es.js +28 -0
- package/dist/insights-v2/analytics/analyticsEventsConfig.es.js.map +1 -1
- package/dist/insights-v2/components/BaseLayout.es.js +113 -106
- package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/index.d.ts +1 -1
- package/dist/insights-v2/ctaActions/runCtaAction.d.ts +1 -1
- package/dist/insights-v2/ctaActions/runCtaAction.es.js +9 -6
- package/dist/insights-v2/ctaActions/runCtaAction.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/subscriptionAnswer.d.ts +46 -0
- package/dist/insights-v2/ctaActions/types.d.ts +16 -2
- package/dist/insights-v2/ctaActions/useCtaAction.es.js +42 -30
- package/dist/insights-v2/ctaActions/useCtaAction.es.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
## [9.7.66] - 10-29-2026
|
|
2
|
+
|
|
3
|
+
- **ADDED** - Shared subscription status CTA for Insights 2.0 (WEC-2158), for Subscription Detected and Unexpected Subscription Payment. The answer lives on the repeating transaction (`user_response`), so a CTA step can now draw a `CtaStatus` or nothing instead of the button (`presenter`, full card; `hideAll` also hides the secondary CTA) and load what it reads once per beat (`prepare`). `subscriptionEntryStep({ statusLabels, answerCounts? })` (`ctaActions/subscriptionAnswer.ts`) builds a beat's entry: unanswered draws the button; answered draws the status with Undo (writes `USER_RESPONSE_UNKNOWN`); a missing repeating transaction hides both CTAs, as pulse did. The repeating transactions load once per page on every card (mini too), retried by the next card after a failure; a second Undo while one is saving is ignored. The words are general copy, as pulse's were: `insights_feed.general` `confirmed` / `incorrect` / `subscribed` / `not_subscribed` / `undo` (new optional keys); the beat sends none. A beat's own survey saves the answer through `answerSubscription` and reports the "No" press through `reportSubscriptionMarkedIncorrect` (pulse's Subscription Confirmation events, Undo included). No beat registers an entry yet
|
|
4
|
+
- **FIXED** - `RecurringTransactionsStore.updateRepeatingTransaction` no longer drops the record when no transactions are loaded (the insights feed), keeping the server's record instead (WEC-2158)
|
|
5
|
+
|
|
1
6
|
## [9.7.65] - 10-28-2026
|
|
2
7
|
|
|
3
8
|
- **FIXED** - Fee Detected design QA (WEC-2139): quieter full-card Contact Support CTA, tighter Transaction Details header spacing with 32px action-row tiles, and Fee Detected fixtures that follow the V2 contract (no date header, orange `ICO-error` icon, `contact_support_block`).
|
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ The library is built using a modern React stack, leveraging industry-standard to
|
|
|
43
43
|
|
|
44
44
|
You need these tools to work in this repo:
|
|
45
45
|
|
|
46
|
-
- Node.js:
|
|
46
|
+
- Node.js: 22 (>=22.12). CI uses `node:22-alpine` (pinned, not the moving `lts` tag).
|
|
47
47
|
- Yarn: the version in the `packageManager` field of [package.json](package.json). Enable Corepack to get it.
|
|
48
48
|
|
|
49
49
|
### Installation
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { RecurrenceStatus as n, RecurrenceType as c } from "../types/RepeatingTransaction.es.js";
|
|
2
|
-
import { augmentRepeatingTransactions as o, buildAllRecurrences as
|
|
3
|
-
import { RepeatingTransactionsApi as
|
|
4
|
-
import { endOfMonth as
|
|
5
|
-
import { isBefore as
|
|
6
|
-
import { startOfMonth as
|
|
2
|
+
import { augmentRepeatingTransactions as o, buildAllRecurrences as R } from "../utils/RecurringTransactionsUtil.es.js";
|
|
3
|
+
import { RepeatingTransactionsApi as g } from "../api/RepeatingTransactionsApi.es.js";
|
|
4
|
+
import { endOfMonth as T } from "date-fns/endOfMonth";
|
|
5
|
+
import { isBefore as f } from "date-fns/isBefore";
|
|
6
|
+
import { startOfMonth as y } from "date-fns/startOfMonth";
|
|
7
7
|
import { startOfToday as s } from "date-fns/startOfToday";
|
|
8
|
-
import { isSameDay as
|
|
8
|
+
import { isSameDay as l } from "date-fns/isSameDay";
|
|
9
9
|
import { isWithinInterval as h } from "date-fns/isWithinInterval";
|
|
10
|
-
import { subDays as
|
|
10
|
+
import { subDays as S } from "date-fns/subDays";
|
|
11
11
|
import { isAfter as u } from "date-fns/isAfter";
|
|
12
|
-
import { makeAutoObservable as
|
|
13
|
-
var d = (e, t) => h(t.expectedDate, e), a = (e, t) => e + t.amount,
|
|
12
|
+
import { makeAutoObservable as _, runInAction as p } from "mobx";
|
|
13
|
+
var d = (e, t) => h(t.expectedDate, e), a = (e, t) => e + t.amount, G = class {
|
|
14
14
|
globalStore;
|
|
15
|
-
api = new
|
|
15
|
+
api = new g("/", "");
|
|
16
16
|
repeatingTransactions = [];
|
|
17
17
|
isDataLoaded = !1;
|
|
18
18
|
selectedDay;
|
|
19
19
|
dateRange = {
|
|
20
|
-
start:
|
|
21
|
-
end:
|
|
20
|
+
start: y(s()),
|
|
21
|
+
end: T(s())
|
|
22
22
|
};
|
|
23
23
|
selectedRepeatingTransactionGuid = null;
|
|
24
24
|
selectedRecurrence = null;
|
|
@@ -27,7 +27,7 @@ var d = (e, t) => h(t.expectedDate, e), a = (e, t) => e + t.amount, U = class {
|
|
|
27
27
|
severity: void 0
|
|
28
28
|
};
|
|
29
29
|
constructor(e) {
|
|
30
|
-
this.globalStore = e, this.api = new
|
|
30
|
+
this.globalStore = e, this.api = new g(e.endpoint, e.sessionToken, e.onError), _(this, {
|
|
31
31
|
recurrencesForRange: !1,
|
|
32
32
|
upcomingExpensesForRange: !1,
|
|
33
33
|
upcomingIncomeForRange: !1,
|
|
@@ -43,7 +43,7 @@ var d = (e, t) => h(t.expectedDate, e), a = (e, t) => e + t.amount, U = class {
|
|
|
43
43
|
}
|
|
44
44
|
recurrencesForRange = (e) => {
|
|
45
45
|
const t = this.globalStore.accountStore.visibleAccounts;
|
|
46
|
-
return
|
|
46
|
+
return R(this.detailedRepeatingTransactions, e).filter((r) => t.some((i) => i.guid === r.accountGuid && !i.is_excluded_from_accounts)).filter((r) => h(r.expectedDate, e));
|
|
47
47
|
};
|
|
48
48
|
upcomingExpensesForRange = (e) => this.recurrencesForRange(e).filter((t) => t.type === c.Expense && t.status === n.Upcoming);
|
|
49
49
|
incomeForRange = (e) => this.recurrencesForRange(e).filter((t) => t.type === c.Income);
|
|
@@ -56,7 +56,7 @@ var d = (e, t) => h(t.expectedDate, e), a = (e, t) => e + t.amount, U = class {
|
|
|
56
56
|
return this.recurrences.filter((e) => e.status === n.Paid || e.status === n.Missed);
|
|
57
57
|
}
|
|
58
58
|
get upcomingRecurrences() {
|
|
59
|
-
return this.recurrences.filter((e) => u(e.expectedDate,
|
|
59
|
+
return this.recurrences.filter((e) => u(e.expectedDate, S(s(), 3)) && f(e.expectedDate, this.dateRange.end) && e.status === n.Upcoming);
|
|
60
60
|
}
|
|
61
61
|
get expenses() {
|
|
62
62
|
return this.recurrences.filter((e) => e.type === c.Expense);
|
|
@@ -101,7 +101,7 @@ var d = (e, t) => h(t.expectedDate, e), a = (e, t) => e + t.amount, U = class {
|
|
|
101
101
|
return this.currentMonthIncome.filter((e) => e.status === n.Upcoming).reduce(a, 0);
|
|
102
102
|
}
|
|
103
103
|
get selectedDayRecurrences() {
|
|
104
|
-
return this.selectedDay && this.recurrences.filter((e) => this.selectedDay &&
|
|
104
|
+
return this.selectedDay && this.recurrences.filter((e) => this.selectedDay && l(e.occurredOnDate || e.expectedDate, this.selectedDay));
|
|
105
105
|
}
|
|
106
106
|
get selectedRepeatingTransaction() {
|
|
107
107
|
return this.selectedRepeatingTransactionGuid ? this.detailedRepeatingTransactions.find((e) => e.guid === this.selectedRepeatingTransactionGuid) : void 0;
|
|
@@ -113,7 +113,7 @@ var d = (e, t) => h(t.expectedDate, e), a = (e, t) => e + t.amount, U = class {
|
|
|
113
113
|
};
|
|
114
114
|
setDateRange = (e) => this.dateRange = e;
|
|
115
115
|
setSelectedDay = (e) => {
|
|
116
|
-
this.selectedDay = this.selectedDay &&
|
|
116
|
+
this.selectedDay = this.selectedDay && l(e, this.selectedDay) ? void 0 : e;
|
|
117
117
|
};
|
|
118
118
|
loadRepeatingTransactionData = async () => {
|
|
119
119
|
await Promise.all([
|
|
@@ -154,14 +154,19 @@ var d = (e, t) => h(t.expectedDate, e), a = (e, t) => e + t.amount, U = class {
|
|
|
154
154
|
};
|
|
155
155
|
updateRepeatingTransaction = async (e) => {
|
|
156
156
|
try {
|
|
157
|
-
const t = await this.api.updateRepeatingTransaction(e), r = this.repeatingTransactions.findIndex((
|
|
158
|
-
|
|
157
|
+
const t = await this.api.updateRepeatingTransaction(e), r = this.repeatingTransactions.findIndex((m) => m.guid === t.guid);
|
|
158
|
+
if (r < 0) return !1;
|
|
159
|
+
const [i] = o(this.globalStore.accountStore.visibleAccounts, [t], this.globalStore.transactionStore.transactions);
|
|
160
|
+
return p(() => {
|
|
159
161
|
this.repeatingTransactions = [
|
|
160
162
|
...this.repeatingTransactions.slice(0, r),
|
|
161
|
-
|
|
163
|
+
i ?? {
|
|
164
|
+
...this.repeatingTransactions[r],
|
|
165
|
+
...t
|
|
166
|
+
},
|
|
162
167
|
...this.repeatingTransactions.slice(r + 1)
|
|
163
168
|
];
|
|
164
|
-
}), this.setAlert(this.copy.update_repeating_transaction_success, "success"), !0
|
|
169
|
+
}), this.setAlert(this.copy.update_repeating_transaction_success, "success"), !0;
|
|
165
170
|
} catch (t) {
|
|
166
171
|
return this.captureError("updateRepeatingTransaction", t), this.setAlert(this.copy.update_repeating_transaction_error, "error"), !1;
|
|
167
172
|
}
|
|
@@ -196,7 +201,7 @@ var d = (e, t) => h(t.expectedDate, e), a = (e, t) => e + t.amount, U = class {
|
|
|
196
201
|
};
|
|
197
202
|
};
|
|
198
203
|
export {
|
|
199
|
-
|
|
204
|
+
G as RecurringTransactionsStore
|
|
200
205
|
};
|
|
201
206
|
|
|
202
207
|
//# sourceMappingURL=RecurringTransactionsStore.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecurringTransactionsStore.es.js","names":[],"sources":["../../../src/core/stores/RecurringTransactionsStore.ts"],"sourcesContent":["import { type AlertProps } from '@mui/material'\nimport { makeAutoObservable, runInAction } from 'mobx'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { isAfter } from 'date-fns/isAfter'\nimport { isBefore } from 'date-fns/isBefore'\nimport { isSameDay } from 'date-fns/isSameDay'\nimport { isWithinInterval } from 'date-fns/isWithinInterval'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\nimport { subDays } from 'date-fns/subDays'\n\nimport { RepeatingTransactionsApi } from '../api'\nimport {\n type Recurrence,\n type RecurringCopy,\n type RepeatingTransaction,\n type Transaction,\n RecurrenceStatus,\n RecurrenceType,\n type DateRange,\n} from '../types'\nimport {\n augmentRepeatingTransactions,\n buildAllRecurrences,\n} from '../utils/RecurringTransactionsUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nconst currentMonthFilter = (date: DateRange, recurrence: Recurrence) =>\n isWithinInterval(recurrence.expectedDate, date)\n\nconst recurrenceTotalReducer = (total: number, recurrence: Recurrence) => total + recurrence.amount\n\ninterface RecurringAlertProps {\n message: string\n severity: AlertProps['severity']\n}\n\nexport class RecurringTransactionsStore {\n globalStore: GlobalStore\n api = new RepeatingTransactionsApi('/', '')\n\n repeatingTransactions: RepeatingTransaction[] = []\n isDataLoaded: boolean = false\n\n selectedDay: Date | undefined\n dateRange: DateRange = { start: startOfMonth(startOfToday()), end: endOfMonth(startOfToday()) }\n selectedRepeatingTransactionGuid: string | null = null\n selectedRecurrence: Recurrence | null = null\n\n alert: RecurringAlertProps = { message: '', severity: undefined }\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new RepeatingTransactionsApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n\n // The *ForRange helpers are parameterized computeds: they must stay plain\n // methods (not actions) so observable reads inside them remain tracked when\n // invoked from an observer/derivation. makeAutoObservable would otherwise\n // annotate them as actions, which do not track reads.\n makeAutoObservable(this, {\n recurrencesForRange: false,\n upcomingExpensesForRange: false,\n upcomingIncomeForRange: false,\n incomeForRange: false,\n nextIncomeForRange: false,\n })\n }\n\n get copy(): RecurringCopy {\n return this.globalStore.copyStore.copy.recurring\n }\n\n get detailedRepeatingTransactions(): RepeatingTransaction[] {\n return augmentRepeatingTransactions(\n this.globalStore.accountStore.visibleAccounts,\n this.repeatingTransactions,\n this.globalStore.transactionStore.transactions,\n )\n }\n\n /**\n * Returns all recurrences built from repeating transactions and filtered by\n * accounts, scoped to the supplied date range. This is the range-parameterized\n * core used by both the shared getters (which pass this.dateRange) and by\n * consumers such as Cash Flow that need their own independent window without\n * mutating the shared dateRange.\n */\n recurrencesForRange = (dateRange: DateRange): Recurrence[] => {\n const accounts = this.globalStore.accountStore.visibleAccounts\n\n return buildAllRecurrences(this.detailedRepeatingTransactions, dateRange)\n .filter((r) => accounts.some((a) => a.guid === r.accountGuid && !a.is_excluded_from_accounts))\n .filter((r) => isWithinInterval(r.expectedDate, dateRange))\n }\n\n /**\n * Returns the upcoming expense recurrences scoped to the supplied date range.\n */\n upcomingExpensesForRange = (dateRange: DateRange): Recurrence[] => {\n return this.recurrencesForRange(dateRange).filter(\n (recurrence: Recurrence) =>\n recurrence.type === RecurrenceType.Expense &&\n recurrence.status === RecurrenceStatus.Upcoming,\n )\n }\n\n /**\n * Returns the income recurrences scoped to the supplied date range.\n */\n incomeForRange = (dateRange: DateRange): Recurrence[] => {\n return this.recurrencesForRange(dateRange).filter(\n (recurrence: Recurrence) => recurrence.type === RecurrenceType.Income,\n )\n }\n\n /**\n * Returns the upcoming income recurrences scoped to the supplied date range.\n */\n upcomingIncomeForRange = (dateRange: DateRange): Recurrence[] => {\n return this.incomeForRange(dateRange).filter(\n (recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Upcoming,\n )\n }\n\n /**\n * Returns the next upcoming income recurrence scoped to the supplied range.\n */\n nextIncomeForRange = (dateRange: DateRange): Recurrence | undefined => {\n return this.upcomingIncomeForRange(dateRange).find((r) =>\n isAfter(r.expectedDate, startOfToday()),\n )\n }\n\n /**\n * Returns all recurrences built from repeating transactions and filtered by accounts.\n */\n get recurrences(): Recurrence[] {\n return this.recurrencesForRange(this.dateRange)\n }\n\n /**\n * Returns all recurrences that have occurred in the past, including those that are paid or missed\n */\n get pastRecurrences(): Recurrence[] {\n return this.recurrences.filter(\n (recurrence: Recurrence) =>\n recurrence.status === RecurrenceStatus.Paid ||\n recurrence.status === RecurrenceStatus.Missed,\n )\n }\n\n /**\n * Returns all recurrences that are expected to occur through the end of the month\n * or should have occurred in the last 3 days.\n */\n get upcomingRecurrences(): Recurrence[] {\n return this.recurrences.filter(\n (r) =>\n isAfter(r.expectedDate, subDays(startOfToday(), 3)) &&\n isBefore(r.expectedDate, this.dateRange.end) &&\n r.status === RecurrenceStatus.Upcoming,\n )\n }\n\n /**\n * Returns all expense recurrences.\n */\n get expenses(): Recurrence[] {\n return this.recurrences.filter(\n (recurrence: Recurrence) => recurrence.type === RecurrenceType.Expense,\n )\n }\n\n /**\n * Returns the upcoming expense recurrences.\n */\n get upcomingExpenses(): Recurrence[] {\n return this.expenses.filter(\n (recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Upcoming,\n )\n }\n\n /**\n * Returns all income recurrences.\n */\n get income(): Recurrence[] {\n return this.recurrences.filter(\n (recurrence: Recurrence) => recurrence.type === RecurrenceType.Income,\n )\n }\n\n /**\n * Returns the upcoming income recurrences.\n */\n get upcomingIncome(): Recurrence[] {\n return this.income.filter(\n (recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Upcoming,\n )\n }\n\n get nextIncomeRecurrence() {\n return this.upcomingIncome.find((r) => isAfter(r.expectedDate, startOfToday()))\n }\n\n /**\n * Returns the expense recurrences for the current month.\n */\n get currentMonthExpenses(): Recurrence[] {\n return this.expenses.filter((recurrence: Recurrence) =>\n currentMonthFilter(this.dateRange, recurrence),\n )\n }\n\n /**\n * Returns the income recurrences for the current month.\n */\n get currentMonthIncome(): Recurrence[] {\n return this.income.filter((recurrence: Recurrence) =>\n currentMonthFilter(this.dateRange, recurrence),\n )\n }\n\n /**\n * Calculates the total amount of all expenses for the current month.\n */\n get expenseTotal(): number {\n return this.currentMonthExpenses.reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all paid expenses for the current month.\n */\n get paidExpenseTotal(): number {\n return this.currentMonthExpenses\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Paid)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all missed expenses for the current month.\n */\n get missedExpenseTotal(): number {\n return this.currentMonthExpenses\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Missed)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all upcoming expenses for the current month.\n */\n get upcomingExpenseTotal(): number {\n return this.currentMonthExpenses\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Upcoming)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all income for the current month.\n */\n get incomeTotal(): number {\n return this.currentMonthIncome.reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all paid income for the current month.\n */\n get paidIncomeTotal(): number {\n return this.currentMonthIncome\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Paid)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all upcoming income for the current month.\n */\n get upcomingIncomeTotal(): number {\n return this.currentMonthIncome\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Upcoming)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Get the recurrences for the currently selected day.\n */\n get selectedDayRecurrences(): Recurrence[] | undefined {\n return (\n this.selectedDay &&\n this.recurrences.filter(\n (recurrence: Recurrence) =>\n this.selectedDay &&\n isSameDay(recurrence.occurredOnDate || recurrence.expectedDate, this.selectedDay),\n )\n )\n }\n\n get selectedRepeatingTransaction(): RepeatingTransaction | undefined {\n return this.selectedRepeatingTransactionGuid\n ? this.detailedRepeatingTransactions.find(\n (rt) => rt.guid === this.selectedRepeatingTransactionGuid,\n )\n : undefined\n }\n\n setSelectedRepeatingTransactionGuid = (guid: string | null) =>\n (this.selectedRepeatingTransactionGuid = guid)\n\n setSelectedRecurrence = (recurrence: Recurrence | null) => (this.selectedRecurrence = recurrence)\n\n setRepeatingTransactions = (repeating: RepeatingTransaction[]) => {\n this.repeatingTransactions = repeating\n this.isDataLoaded = true\n }\n\n /**\n * Set the date range for filtering recurrences.\n * @param dateRange - The date range to set.\n */\n setDateRange = (dateRange: DateRange) => (this.dateRange = dateRange)\n\n /**\n * Set the currently selected day.\n * @param day - The day to select.\n */\n setSelectedDay = (day: Date) => {\n this.selectedDay = this.selectedDay && isSameDay(day, this.selectedDay) ? undefined : day\n }\n\n loadRepeatingTransactionData = async () => {\n await Promise.all([\n this.globalStore.accountStore.loadAccountData(),\n this.globalStore.categoryStore.loadCategories(),\n this.globalStore.transactionStore.loadTransactionData(),\n ])\n await this.loadRepeatingTransactions()\n }\n\n /**\n * Load repeating transactions and augment them with additional data.\n */\n loadRepeatingTransactions = async () => {\n try {\n const repeatingTransactions = await this.api.getRepeatingTransactions()\n this.setRepeatingTransactions(repeatingTransactions)\n } catch (error) {\n this.captureError('getRepeatingTransactions', error)\n }\n }\n\n /**\n * Add a new repeating transaction and link it to the associated transaction.\n * @param repeatingTransaction - The repeating transaction to add.\n * @param transaction - The transaction associated with the repeating transaction.\n */\n addRepeatingTransaction = async (\n repeatingTransaction: RepeatingTransaction,\n transaction: Transaction,\n ): Promise<boolean> => {\n try {\n const newRepeating = await this.api.addRepeatingTransaction(repeatingTransaction)\n\n await this.globalStore.transactionStore.updateTransaction({\n ...transaction,\n repeating_transaction_guid: newRepeating.guid,\n })\n\n runInAction(() => {\n this.repeatingTransactions = [\n ...this.repeatingTransactions,\n ...augmentRepeatingTransactions(\n this.globalStore.accountStore.visibleAccounts,\n [newRepeating],\n this.globalStore.transactionStore.transactions,\n ),\n ]\n })\n\n this.setAlert(this.copy.add_repeating_transaction_success, 'success')\n\n return true\n } catch (error) {\n this.captureError('addRepeatingTransaction', error)\n this.setAlert(this.copy.add_repeating_transaction_error, 'error')\n\n return false\n }\n }\n\n /**\n * Delete a repeating transaction by its GUID.\n * @param guid - The GUID of the repeating transaction to delete.\n */\n deleteRepeatingTransaction = async (guid: string): Promise<boolean> => {\n try {\n await this.api.deleteRepeatingTransaction(guid)\n\n runInAction(() => {\n this.repeatingTransactions = this.repeatingTransactions.filter((rt) => rt.guid !== guid)\n })\n\n this.setAlert(this.copy.remove_repeating_transaction_success, 'success')\n\n return true\n } catch (error) {\n this.captureError('deleteRepeatingTransaction', error)\n this.setAlert(this.copy.remove_repeating_transaction_error, 'error')\n\n return false\n }\n }\n\n /**\n * Update an existing repeating transaction.\n * @param transaction - The repeating transaction to update.\n */\n updateRepeatingTransaction = async (transaction: RepeatingTransaction): Promise<boolean> => {\n try {\n const updatedTransaction = await this.api.updateRepeatingTransaction(transaction)\n\n const index = this.repeatingTransactions.findIndex(\n (rt) => rt.guid === updatedTransaction.guid,\n )\n if (index < 0) return false\n\n runInAction(() => {\n this.repeatingTransactions = [\n ...this.repeatingTransactions.slice(0, index),\n ...augmentRepeatingTransactions(\n this.globalStore.accountStore.visibleAccounts,\n [updatedTransaction],\n this.globalStore.transactionStore.transactions,\n ),\n ...this.repeatingTransactions.slice(index + 1),\n ]\n })\n\n this.setAlert(this.copy.update_repeating_transaction_success, 'success')\n\n return true\n } catch (error) {\n this.captureError('updateRepeatingTransaction', error)\n this.setAlert(this.copy.update_repeating_transaction_error, 'error')\n\n return false\n }\n }\n\n /**\n * Mark a recurrence as paid by linking a transaction to the repeating transaction.\n * @param repeatingTransactionGuid - The GUID of the repeating transaction.\n * @param transaction - The transaction to link.\n */\n markRecurrenceAsPaid = async (repeatingTransactionGuid: string, transaction: Transaction) => {\n try {\n await this.globalStore.transactionStore.updateTransaction({\n ...transaction,\n repeating_transaction_guid: repeatingTransactionGuid,\n })\n\n await this.loadRepeatingTransactions()\n this.setSelectedRecurrence(null)\n this.setAlert(this.copy.link_transaction_success, 'success')\n } catch (error) {\n this.captureError('markRecurrenceAsPaid', error)\n this.setAlert(this.copy.link_transaction_error, 'error')\n }\n }\n\n /**\n * Mark a recurrence as unpaid by unlinking the associated transaction from the repeating transaction.\n * @param transaction - The transaction to unlink.\n */\n markRecurrenceAsUnpaid = async (transaction: Transaction) => {\n try {\n await this.globalStore.transactionStore.updateTransaction({\n ...transaction,\n repeating_transaction_guid: null,\n })\n\n await this.loadRepeatingTransactions()\n this.setSelectedRecurrence(null)\n this.setAlert(this.copy.unlink_transaction_success, 'success')\n } catch (error) {\n this.captureError('markRecurrenceAsUnpaid', error)\n this.setAlert(this.copy.unlink_transaction_error, 'error')\n }\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'RecurringTransactionsStore', action })\n\n setAlert = (message: string, severity: RecurringAlertProps['severity'] = undefined) =>\n (this.alert = { message, severity })\n}\n"],"mappings":";;;;;;;;;;;;AA4BA,IAAM,IAAA,CAAsB,GAAiB,MAC3C,EAAiB,EAAW,cAAc,CAAI,GAE1C,IAAA,CAA0B,GAAe,MAA2B,IAAQ,EAAW,QAOhF,IAAb,MAAwC;AAAA,EACtC;AAAA,EACA,MAAM,IAAI,EAAyB,KAAK,EAAE;AAAA,EAE1C,wBAAgD,CAAC;AAAA,EACjD,eAAwB;AAAA,EAExB;AAAA,EACA,YAAuB;AAAA,IAAE,OAAO,EAAa,EAAa,CAAC;AAAA,IAAG,KA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K,KAAK,0BAA0B,SAAS;AAAA,IAC7D,SAAS,GAAO;AACd,WAAK,aAAa,wBAAwB,CAAK,GAC/C,KAAK,SAAS,KAAK,KAAK,wBAAwB,OAAO;AAAA,IACzD;AAAA,EACF;AAAA,EAMA,yBAAyB,OAAO,MAA6B;AAC3D,QAAI;AACF,YAAM,KAAK,YAAY,iBAAiB,kBAAkB;AAAA,QACxD,GAAG;AAAA,QACH,4BAA4B;AAAA,MAC9B,CAAC,GAED,MAAM,KAAK,0BAA0B,GACrC,KAAK,sBAAsB,IAAI,GAC/B,KAAK,SAAS,KAAK,KAAK,4BAA4B,SAAS;AAAA,IAC/D,SAAS,GAAO;AACd,WAAK,aAAa,0BAA0B,CAAK,GACjD,KAAK,SAAS,KAAK,KAAK,0BAA0B,OAAO;AAAA,IAC3D;AAAA,EACF;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAA8B,QAAA;AAAA,EAAO,CAAC;AAAA,EAE1F,WAAA,CAAY,GAAiB,IAA4C,WACtE,KAAK,QAAQ;AAAA,IAAE,SAAA;AAAA,IAAS,UAAA;AAAA,EAAS;AACtC"}
|
|
1
|
+
{"version":3,"file":"RecurringTransactionsStore.es.js","names":[],"sources":["../../../src/core/stores/RecurringTransactionsStore.ts"],"sourcesContent":["import { type AlertProps } from '@mui/material'\nimport { makeAutoObservable, runInAction } from 'mobx'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { isAfter } from 'date-fns/isAfter'\nimport { isBefore } from 'date-fns/isBefore'\nimport { isSameDay } from 'date-fns/isSameDay'\nimport { isWithinInterval } from 'date-fns/isWithinInterval'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\nimport { subDays } from 'date-fns/subDays'\n\nimport { RepeatingTransactionsApi } from '../api'\nimport {\n type Recurrence,\n type RecurringCopy,\n type RepeatingTransaction,\n type Transaction,\n RecurrenceStatus,\n RecurrenceType,\n type DateRange,\n} from '../types'\nimport {\n augmentRepeatingTransactions,\n buildAllRecurrences,\n} from '../utils/RecurringTransactionsUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nconst currentMonthFilter = (date: DateRange, recurrence: Recurrence) =>\n isWithinInterval(recurrence.expectedDate, date)\n\nconst recurrenceTotalReducer = (total: number, recurrence: Recurrence) => total + recurrence.amount\n\ninterface RecurringAlertProps {\n message: string\n severity: AlertProps['severity']\n}\n\nexport class RecurringTransactionsStore {\n globalStore: GlobalStore\n api = new RepeatingTransactionsApi('/', '')\n\n repeatingTransactions: RepeatingTransaction[] = []\n isDataLoaded: boolean = false\n\n selectedDay: Date | undefined\n dateRange: DateRange = { start: startOfMonth(startOfToday()), end: endOfMonth(startOfToday()) }\n selectedRepeatingTransactionGuid: string | null = null\n selectedRecurrence: Recurrence | null = null\n\n alert: RecurringAlertProps = { message: '', severity: undefined }\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new RepeatingTransactionsApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n\n // The *ForRange helpers are parameterized computeds: they must stay plain\n // methods (not actions) so observable reads inside them remain tracked when\n // invoked from an observer/derivation. makeAutoObservable would otherwise\n // annotate them as actions, which do not track reads.\n makeAutoObservable(this, {\n recurrencesForRange: false,\n upcomingExpensesForRange: false,\n upcomingIncomeForRange: false,\n incomeForRange: false,\n nextIncomeForRange: false,\n })\n }\n\n get copy(): RecurringCopy {\n return this.globalStore.copyStore.copy.recurring\n }\n\n get detailedRepeatingTransactions(): RepeatingTransaction[] {\n return augmentRepeatingTransactions(\n this.globalStore.accountStore.visibleAccounts,\n this.repeatingTransactions,\n this.globalStore.transactionStore.transactions,\n )\n }\n\n /**\n * Returns all recurrences built from repeating transactions and filtered by\n * accounts, scoped to the supplied date range. This is the range-parameterized\n * core used by both the shared getters (which pass this.dateRange) and by\n * consumers such as Cash Flow that need their own independent window without\n * mutating the shared dateRange.\n */\n recurrencesForRange = (dateRange: DateRange): Recurrence[] => {\n const accounts = this.globalStore.accountStore.visibleAccounts\n\n return buildAllRecurrences(this.detailedRepeatingTransactions, dateRange)\n .filter((r) => accounts.some((a) => a.guid === r.accountGuid && !a.is_excluded_from_accounts))\n .filter((r) => isWithinInterval(r.expectedDate, dateRange))\n }\n\n /**\n * Returns the upcoming expense recurrences scoped to the supplied date range.\n */\n upcomingExpensesForRange = (dateRange: DateRange): Recurrence[] => {\n return this.recurrencesForRange(dateRange).filter(\n (recurrence: Recurrence) =>\n recurrence.type === RecurrenceType.Expense &&\n recurrence.status === RecurrenceStatus.Upcoming,\n )\n }\n\n /**\n * Returns the income recurrences scoped to the supplied date range.\n */\n incomeForRange = (dateRange: DateRange): Recurrence[] => {\n return this.recurrencesForRange(dateRange).filter(\n (recurrence: Recurrence) => recurrence.type === RecurrenceType.Income,\n )\n }\n\n /**\n * Returns the upcoming income recurrences scoped to the supplied date range.\n */\n upcomingIncomeForRange = (dateRange: DateRange): Recurrence[] => {\n return this.incomeForRange(dateRange).filter(\n (recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Upcoming,\n )\n }\n\n /**\n * Returns the next upcoming income recurrence scoped to the supplied range.\n */\n nextIncomeForRange = (dateRange: DateRange): Recurrence | undefined => {\n return this.upcomingIncomeForRange(dateRange).find((r) =>\n isAfter(r.expectedDate, startOfToday()),\n )\n }\n\n /**\n * Returns all recurrences built from repeating transactions and filtered by accounts.\n */\n get recurrences(): Recurrence[] {\n return this.recurrencesForRange(this.dateRange)\n }\n\n /**\n * Returns all recurrences that have occurred in the past, including those that are paid or missed\n */\n get pastRecurrences(): Recurrence[] {\n return this.recurrences.filter(\n (recurrence: Recurrence) =>\n recurrence.status === RecurrenceStatus.Paid ||\n recurrence.status === RecurrenceStatus.Missed,\n )\n }\n\n /**\n * Returns all recurrences that are expected to occur through the end of the month\n * or should have occurred in the last 3 days.\n */\n get upcomingRecurrences(): Recurrence[] {\n return this.recurrences.filter(\n (r) =>\n isAfter(r.expectedDate, subDays(startOfToday(), 3)) &&\n isBefore(r.expectedDate, this.dateRange.end) &&\n r.status === RecurrenceStatus.Upcoming,\n )\n }\n\n /**\n * Returns all expense recurrences.\n */\n get expenses(): Recurrence[] {\n return this.recurrences.filter(\n (recurrence: Recurrence) => recurrence.type === RecurrenceType.Expense,\n )\n }\n\n /**\n * Returns the upcoming expense recurrences.\n */\n get upcomingExpenses(): Recurrence[] {\n return this.expenses.filter(\n (recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Upcoming,\n )\n }\n\n /**\n * Returns all income recurrences.\n */\n get income(): Recurrence[] {\n return this.recurrences.filter(\n (recurrence: Recurrence) => recurrence.type === RecurrenceType.Income,\n )\n }\n\n /**\n * Returns the upcoming income recurrences.\n */\n get upcomingIncome(): Recurrence[] {\n return this.income.filter(\n (recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Upcoming,\n )\n }\n\n get nextIncomeRecurrence() {\n return this.upcomingIncome.find((r) => isAfter(r.expectedDate, startOfToday()))\n }\n\n /**\n * Returns the expense recurrences for the current month.\n */\n get currentMonthExpenses(): Recurrence[] {\n return this.expenses.filter((recurrence: Recurrence) =>\n currentMonthFilter(this.dateRange, recurrence),\n )\n }\n\n /**\n * Returns the income recurrences for the current month.\n */\n get currentMonthIncome(): Recurrence[] {\n return this.income.filter((recurrence: Recurrence) =>\n currentMonthFilter(this.dateRange, recurrence),\n )\n }\n\n /**\n * Calculates the total amount of all expenses for the current month.\n */\n get expenseTotal(): number {\n return this.currentMonthExpenses.reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all paid expenses for the current month.\n */\n get paidExpenseTotal(): number {\n return this.currentMonthExpenses\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Paid)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all missed expenses for the current month.\n */\n get missedExpenseTotal(): number {\n return this.currentMonthExpenses\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Missed)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all upcoming expenses for the current month.\n */\n get upcomingExpenseTotal(): number {\n return this.currentMonthExpenses\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Upcoming)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all income for the current month.\n */\n get incomeTotal(): number {\n return this.currentMonthIncome.reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all paid income for the current month.\n */\n get paidIncomeTotal(): number {\n return this.currentMonthIncome\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Paid)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all upcoming income for the current month.\n */\n get upcomingIncomeTotal(): number {\n return this.currentMonthIncome\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Upcoming)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Get the recurrences for the currently selected day.\n */\n get selectedDayRecurrences(): Recurrence[] | undefined {\n return (\n this.selectedDay &&\n this.recurrences.filter(\n (recurrence: Recurrence) =>\n this.selectedDay &&\n isSameDay(recurrence.occurredOnDate || recurrence.expectedDate, this.selectedDay),\n )\n )\n }\n\n get selectedRepeatingTransaction(): RepeatingTransaction | undefined {\n return this.selectedRepeatingTransactionGuid\n ? this.detailedRepeatingTransactions.find(\n (rt) => rt.guid === this.selectedRepeatingTransactionGuid,\n )\n : undefined\n }\n\n setSelectedRepeatingTransactionGuid = (guid: string | null) =>\n (this.selectedRepeatingTransactionGuid = guid)\n\n setSelectedRecurrence = (recurrence: Recurrence | null) => (this.selectedRecurrence = recurrence)\n\n setRepeatingTransactions = (repeating: RepeatingTransaction[]) => {\n this.repeatingTransactions = repeating\n this.isDataLoaded = true\n }\n\n /**\n * Set the date range for filtering recurrences.\n * @param dateRange - The date range to set.\n */\n setDateRange = (dateRange: DateRange) => (this.dateRange = dateRange)\n\n /**\n * Set the currently selected day.\n * @param day - The day to select.\n */\n setSelectedDay = (day: Date) => {\n this.selectedDay = this.selectedDay && isSameDay(day, this.selectedDay) ? undefined : day\n }\n\n loadRepeatingTransactionData = async () => {\n await Promise.all([\n this.globalStore.accountStore.loadAccountData(),\n this.globalStore.categoryStore.loadCategories(),\n this.globalStore.transactionStore.loadTransactionData(),\n ])\n await this.loadRepeatingTransactions()\n }\n\n /**\n * Load repeating transactions and augment them with additional data.\n */\n loadRepeatingTransactions = async () => {\n try {\n const repeatingTransactions = await this.api.getRepeatingTransactions()\n this.setRepeatingTransactions(repeatingTransactions)\n } catch (error) {\n this.captureError('getRepeatingTransactions', error)\n }\n }\n\n /**\n * Add a new repeating transaction and link it to the associated transaction.\n * @param repeatingTransaction - The repeating transaction to add.\n * @param transaction - The transaction associated with the repeating transaction.\n */\n addRepeatingTransaction = async (\n repeatingTransaction: RepeatingTransaction,\n transaction: Transaction,\n ): Promise<boolean> => {\n try {\n const newRepeating = await this.api.addRepeatingTransaction(repeatingTransaction)\n\n await this.globalStore.transactionStore.updateTransaction({\n ...transaction,\n repeating_transaction_guid: newRepeating.guid,\n })\n\n runInAction(() => {\n this.repeatingTransactions = [\n ...this.repeatingTransactions,\n ...augmentRepeatingTransactions(\n this.globalStore.accountStore.visibleAccounts,\n [newRepeating],\n this.globalStore.transactionStore.transactions,\n ),\n ]\n })\n\n this.setAlert(this.copy.add_repeating_transaction_success, 'success')\n\n return true\n } catch (error) {\n this.captureError('addRepeatingTransaction', error)\n this.setAlert(this.copy.add_repeating_transaction_error, 'error')\n\n return false\n }\n }\n\n /**\n * Delete a repeating transaction by its GUID.\n * @param guid - The GUID of the repeating transaction to delete.\n */\n deleteRepeatingTransaction = async (guid: string): Promise<boolean> => {\n try {\n await this.api.deleteRepeatingTransaction(guid)\n\n runInAction(() => {\n this.repeatingTransactions = this.repeatingTransactions.filter((rt) => rt.guid !== guid)\n })\n\n this.setAlert(this.copy.remove_repeating_transaction_success, 'success')\n\n return true\n } catch (error) {\n this.captureError('deleteRepeatingTransaction', error)\n this.setAlert(this.copy.remove_repeating_transaction_error, 'error')\n\n return false\n }\n }\n\n /**\n * Update an existing repeating transaction.\n * @param transaction - The repeating transaction to update.\n */\n updateRepeatingTransaction = async (transaction: RepeatingTransaction): Promise<boolean> => {\n try {\n const updatedTransaction = await this.api.updateRepeatingTransaction(transaction)\n\n const index = this.repeatingTransactions.findIndex(\n (rt) => rt.guid === updatedTransaction.guid,\n )\n if (index < 0) return false\n\n // augmentRepeatingTransactions returns nothing while no transactions are loaded (the insights\n // feed); keep the server's record then rather than drop it.\n const [augmented] = augmentRepeatingTransactions(\n this.globalStore.accountStore.visibleAccounts,\n [updatedTransaction],\n this.globalStore.transactionStore.transactions,\n )\n\n runInAction(() => {\n this.repeatingTransactions = [\n ...this.repeatingTransactions.slice(0, index),\n augmented ?? { ...this.repeatingTransactions[index], ...updatedTransaction },\n ...this.repeatingTransactions.slice(index + 1),\n ]\n })\n\n this.setAlert(this.copy.update_repeating_transaction_success, 'success')\n\n return true\n } catch (error) {\n this.captureError('updateRepeatingTransaction', error)\n this.setAlert(this.copy.update_repeating_transaction_error, 'error')\n\n return false\n }\n }\n\n /**\n * Mark a recurrence as paid by linking a transaction to the repeating transaction.\n * @param repeatingTransactionGuid - The GUID of the repeating transaction.\n * @param transaction - The transaction to link.\n */\n markRecurrenceAsPaid = async (repeatingTransactionGuid: string, transaction: Transaction) => {\n try {\n await this.globalStore.transactionStore.updateTransaction({\n ...transaction,\n repeating_transaction_guid: repeatingTransactionGuid,\n })\n\n await this.loadRepeatingTransactions()\n this.setSelectedRecurrence(null)\n this.setAlert(this.copy.link_transaction_success, 'success')\n } catch (error) {\n this.captureError('markRecurrenceAsPaid', error)\n this.setAlert(this.copy.link_transaction_error, 'error')\n }\n }\n\n /**\n * Mark a recurrence as unpaid by unlinking the associated transaction from the repeating transaction.\n * @param transaction - The transaction to unlink.\n */\n markRecurrenceAsUnpaid = async (transaction: Transaction) => {\n try {\n await this.globalStore.transactionStore.updateTransaction({\n ...transaction,\n repeating_transaction_guid: null,\n })\n\n await this.loadRepeatingTransactions()\n this.setSelectedRecurrence(null)\n this.setAlert(this.copy.unlink_transaction_success, 'success')\n } catch (error) {\n this.captureError('markRecurrenceAsUnpaid', error)\n this.setAlert(this.copy.unlink_transaction_error, 'error')\n }\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'RecurringTransactionsStore', action })\n\n setAlert = (message: string, severity: RecurringAlertProps['severity'] = undefined) =>\n (this.alert = { message, severity })\n}\n"],"mappings":";;;;;;;;;;;;AA4BA,IAAM,IAAA,CAAsB,GAAiB,MAC3C,EAAiB,EAAW,cAAc,CAAI,GAE1C,IAAA,CAA0B,GAAe,MAA2B,IAAQ,EAAW,QAOhF,IAAb,MAAwC;AAAA,EACtC;AAAA,EACA,MAAM,IAAI,EAAyB,KAAK,EAAE;AAAA,EAE1C,wBAAgD,CAAC;AAAA,EACjD,eAAwB;AAAA,EAExB;AAAA,EACA,YAAuB;AAAA,IAAE,OAAO,EAAa,EAAa,CAAC;AAAA,IAAG,KAAK,EAAW,EAAa,CAAC;AAAA,EAAE;AAAA,EAC9F,mCAAkD;AAAA,EAClD,qBAAwC;AAAA,EAExC,QAA6B;AAAA,IAAE,SAAS;AAAA,IAAI,UAAU;AAAA,EAAU;AAAA,EAEhE,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EACb,EAAY,UACZ,EAAY,cACZ,EAAY,OACd,GAMA,EAAmB,MAAM;AAAA,MACvB,qBAAqB;AAAA,MACrB,0BAA0B;AAAA,MAC1B,wBAAwB;AAAA,MACxB,gBAAgB;AAAA,MAChB,oBAAoB;AAAA,IACtB,CAAC;AAAA,EACH;AAAA,EAEA,IAAI,OAAsB;AACxB,WAAO,KAAK,YAAY,UAAU,KAAK;AAAA,EACzC;AAAA,EAEA,IAAI,gCAAwD;AAC1D,WAAO,EACL,KAAK,YAAY,aA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AAK,aAAa,0BAA0B,CAAK,GACjD,KAAK,SAAS,KAAK,KAAK,0BAA0B,OAAO;AAAA,IAC3D;AAAA,EACF;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAA8B,QAAA;AAAA,EAAO,CAAC;AAAA,EAE1F,WAAA,CAAY,GAAiB,IAA4C,WACtE,KAAK,QAAQ;AAAA,IAAE,SAAA;AAAA,IAAS,UAAA;AAAA,EAAS;AACtC"}
|
|
@@ -38,6 +38,12 @@ interface GeneralInsightsFeedCopy {
|
|
|
38
38
|
in_month_you_had_a_category_of_amount?: string;
|
|
39
39
|
income_transactions?: string;
|
|
40
40
|
spend_transactions?: string;
|
|
41
|
+
/** Subscription status CTA words: the ✓ / ✗ status and Undo. */
|
|
42
|
+
confirmed?: string;
|
|
43
|
+
incorrect?: string;
|
|
44
|
+
subscribed?: string;
|
|
45
|
+
not_subscribed?: string;
|
|
46
|
+
undo?: string;
|
|
41
47
|
}
|
|
42
48
|
interface SettingsMenuCopy {
|
|
43
49
|
close: string;
|
|
@@ -76,6 +76,35 @@ export declare const ANALYTICS_EVENTS_CONFIG: {
|
|
|
76
76
|
readonly category: "Emergency Savings";
|
|
77
77
|
readonly action: "Designate Emergency Savings Account - Savings Account Created";
|
|
78
78
|
};
|
|
79
|
+
readonly SUBSCRIPTION_CONFIRMED: {
|
|
80
|
+
readonly category: "Subscription Confirmation";
|
|
81
|
+
readonly action: "User Marked as Correct";
|
|
82
|
+
};
|
|
83
|
+
readonly SUBSCRIPTION_NOT_SUBSCRIBED: {
|
|
84
|
+
readonly category: "Subscription Confirmation";
|
|
85
|
+
readonly action: "User Marked as Incorrect";
|
|
86
|
+
};
|
|
87
|
+
readonly SUBSCRIPTION_NEVER_SUBSCRIBED: {
|
|
88
|
+
readonly category: "Subscription Confirmation";
|
|
89
|
+
readonly action: "Have Never Subscribed";
|
|
90
|
+
};
|
|
91
|
+
readonly SUBSCRIPTION_CANCELLED: {
|
|
92
|
+
readonly category: "Subscription Confirmation";
|
|
93
|
+
readonly action: "Subscription Has Been Canceled";
|
|
94
|
+
};
|
|
95
|
+
readonly SUBSCRIPTION_ONE_TIME_PURCHASE: {
|
|
96
|
+
readonly category: "Subscription Confirmation";
|
|
97
|
+
readonly action: "One Time Purchase";
|
|
98
|
+
};
|
|
99
|
+
readonly SUBSCRIPTION_WRONG_FREQUENCY: {
|
|
100
|
+
readonly category: "Subscription Confirmation";
|
|
101
|
+
readonly action: "Frequency Is Incorrect";
|
|
102
|
+
};
|
|
103
|
+
/** Fired with " - Previous action: <answer>" appended, as pulse did. */
|
|
104
|
+
readonly SUBSCRIPTION_UNDO: {
|
|
105
|
+
readonly category: "Subscription Confirmation";
|
|
106
|
+
readonly action: "User Clicked Undo Button";
|
|
107
|
+
};
|
|
79
108
|
readonly OPENED_CONNECT_DRAWER: {
|
|
80
109
|
readonly postHog: {
|
|
81
110
|
readonly eventName: "opened_connect_drawer";
|
|
@@ -63,6 +63,34 @@ var t = (e) => e?.replace(/([A-Z]+)/g, " $1")?.replace(/^ /, "") ?? "", a = {
|
|
|
63
63
|
category: "Emergency Savings",
|
|
64
64
|
action: "Designate Emergency Savings Account - Savings Account Created"
|
|
65
65
|
},
|
|
66
|
+
SUBSCRIPTION_CONFIRMED: {
|
|
67
|
+
category: "Subscription Confirmation",
|
|
68
|
+
action: "User Marked as Correct"
|
|
69
|
+
},
|
|
70
|
+
SUBSCRIPTION_NOT_SUBSCRIBED: {
|
|
71
|
+
category: "Subscription Confirmation",
|
|
72
|
+
action: "User Marked as Incorrect"
|
|
73
|
+
},
|
|
74
|
+
SUBSCRIPTION_NEVER_SUBSCRIBED: {
|
|
75
|
+
category: "Subscription Confirmation",
|
|
76
|
+
action: "Have Never Subscribed"
|
|
77
|
+
},
|
|
78
|
+
SUBSCRIPTION_CANCELLED: {
|
|
79
|
+
category: "Subscription Confirmation",
|
|
80
|
+
action: "Subscription Has Been Canceled"
|
|
81
|
+
},
|
|
82
|
+
SUBSCRIPTION_ONE_TIME_PURCHASE: {
|
|
83
|
+
category: "Subscription Confirmation",
|
|
84
|
+
action: "One Time Purchase"
|
|
85
|
+
},
|
|
86
|
+
SUBSCRIPTION_WRONG_FREQUENCY: {
|
|
87
|
+
category: "Subscription Confirmation",
|
|
88
|
+
action: "Frequency Is Incorrect"
|
|
89
|
+
},
|
|
90
|
+
SUBSCRIPTION_UNDO: {
|
|
91
|
+
category: "Subscription Confirmation",
|
|
92
|
+
action: "User Clicked Undo Button"
|
|
93
|
+
},
|
|
66
94
|
OPENED_CONNECT_DRAWER: { postHog: {
|
|
67
95
|
eventName: "opened_connect_drawer",
|
|
68
96
|
properties: (e) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyticsEventsConfig.es.js","names":[],"sources":["../../../src/insights-v2/analytics/analyticsEventsConfig.ts"],"sourcesContent":["import type { Beat } from '../../core'\n\n// PascalCase template to label, ported from Pulse.\nexport const sentenceCaseTemplate = (template?: string | null): string =>\n template?.replace(/([A-Z]+)/g, ' $1')?.replace(/^ /, '') ?? ''\n\n// Fixed or beat-computed value.\ntype Resolvable = string | ((beat: Beat) => string)\n\n// Source of truth for insights-v2 analytics events. Mirrors Pulse's strings.\n// Entry has a Firefly half (action/category) and/or a postHog half.\nexport interface AnalyticsEventConfigEntry {\n category?: Resolvable\n action?: Resolvable\n /** Detail stored with the Firefly event, e.g. a survey reason. */\n value?: Resolvable\n postHog?: {\n eventName: string\n properties?: (beat: Beat) => Record<string, unknown>\n }\n}\n\nexport const ANALYTICS_EVENTS_CONFIG = {\n // Primary/secondary CTA click, fired via sendCtaAnalytics.\n PRIMARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'Primary Action Selected',\n },\n SECONDARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'Secondary Action Selected',\n },\n // Fires once, gated on !beat.cta_clicked_at.\n FIRST_TIME_PRIMARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'First Time Primary Action Selected',\n },\n\n // \"Not Interested\" survey submitted; the call site sets the picked reason as `value`.\n BEAT_DISMISSED: {\n category: 'Beat Interaction',\n action: 'Beat Dismissed',\n },\n\n // Bar click on the card's inline chart.\n CHART_BAR_CLICKED: {\n category: 'Beat Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Bar Clicked`,\n },\n // Bar click inside the drill-down drawer.\n DRAWER_CHART_BAR_CLICKED: {\n category: 'Drawer Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Bar Clicked`,\n },\n // Month/tab change inside the drill-down drawer.\n TAB_SELECTED: {\n category: 'Drawer Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Month Tab Selected`,\n },\n // Series (e.g. Spend / Income) tab change inside the double-bar drawer.\n TYPE_FILTER_SELECTED: {\n category: 'Transactions Filter',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Transactions Filtered By Type`,\n },\n\n // LowAccountBalance threshold dialog.\n EDIT_INSIGHT_THRESHOLD_SAVE: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Save',\n },\n EDIT_INSIGHT_THRESHOLD_CANCELED: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Canceled',\n },\n EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Input Selected',\n },\n\n // SavingsOpportunityV2 safety-net dialog.\n EDIT_SAFETY_NET_SAVE: {\n category: 'Safety Net',\n action: 'Edit Safety Net',\n },\n // Ported verbatim from Pulse (uses '=' not '-').\n EDIT_SAFETY_NET_CANCEL: {\n category: 'Safety Net',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} = Edit Safety Net - Cancel`,\n },\n\n // Designate Emergency Savings Account (picker pick, Save, Open a Savings Account). Pulse's strings.\n EMERGENCY_SAVINGS_ACCT_SELECTED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account Selected',\n },\n EMERGENCY_SAVINGS_ACCT_SAVED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account Saved',\n },\n EMERGENCY_SAVINGS_ACCT_CREATED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account - Savings Account Created',\n },\n\n // Connect drawer opened. PostHog-only.\n OPENED_CONNECT_DRAWER: {\n postHog: {\n eventName: 'opened_connect_drawer',\n properties: (beat) => ({ beat_guid: beat.guid, template: beat.template }),\n },\n },\n} as const satisfies Record<string, AnalyticsEventConfigEntry>\n"],"mappings":"AAGA,IAAa,IAAA,CAAwB,MACnC,GAAU,QAAQ,aAAa,KAAK,GAAG,QAAQ,MAAM,EAAE,KAAK,IAkBjD,IAA0B;AAAA,EAErC,yBAAyB;AAAA,IACvB,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,2BAA2B;AAAA,IACzB,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAEA,oCAAoC;AAAA,IAClC,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAGA,gBAAgB;AAAA,IACd,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAGA,mBAAmB;AAAA,IACjB,UAAU;AAAA,IACV,QAAA,CAAS,MAAS,GAAG,EAAqB,EAAK,QAAQ,CAAA;AAAA,EACzD;AAAA,EAEA,0BAA0B;AAAA,IACxB,UAAU;AAAA,IACV,QAAA,CAAS,MAAS,GAAG,EAAqB,EAAK,QAAQ,CAAA;AAAA,EACzD;AAAA,EAEA,cAAc;AAAA,IACZ,UAAU;AAAA,IACV,QAAA,CAAS,MAAS,GAAG,EAAqB,EAAK,QAAQ,CAAA;AAAA,EACzD;AAAA,EAEA,sBAAsB;AAAA,IACpB,UAAU;AAAA,IACV,QAAA,CAAS,MAAS,GAAG,EAAqB,EAAK,QAAQ,CAAA;AAAA,EACzD;AAAA,EAGA,6BAA6B;AAAA,IAC3B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,iCAAiC;AAAA,IAC/B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,uCAAuC;AAAA,IACrC,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAGA,sBAAsB;AAAA,IACpB,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAEA,wBAAwB;AAAA,IACtB,UAAU;AAAA,IACV,QAAA,CAAS,MAAS,GAAG,EAAqB,EAAK,QAAQ,CAAA;AAAA,EACzD;AAAA,EAGA,iCAAiC;AAAA,IAC/B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,8BAA8B;AAAA,IAC5B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,gCAAgC;AAAA,IAC9B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAGA,uBAAuB,EACrB,SAAS;AAAA,IACP,WAAW;AAAA,IACX,YAAA,CAAa,OAAU;AAAA,MAAE,WAAW,EAAK;AAAA,MAAM,UAAU,EAAK;AAAA,IAAS;AAAA,EACzE,EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"analyticsEventsConfig.es.js","names":[],"sources":["../../../src/insights-v2/analytics/analyticsEventsConfig.ts"],"sourcesContent":["import type { Beat } from '../../core'\n\n// PascalCase template to label, ported from Pulse.\nexport const sentenceCaseTemplate = (template?: string | null): string =>\n template?.replace(/([A-Z]+)/g, ' $1')?.replace(/^ /, '') ?? ''\n\n// Fixed or beat-computed value.\ntype Resolvable = string | ((beat: Beat) => string)\n\n// Source of truth for insights-v2 analytics events. Mirrors Pulse's strings.\n// Entry has a Firefly half (action/category) and/or a postHog half.\nexport interface AnalyticsEventConfigEntry {\n category?: Resolvable\n action?: Resolvable\n /** Detail stored with the Firefly event, e.g. a survey reason. */\n value?: Resolvable\n postHog?: {\n eventName: string\n properties?: (beat: Beat) => Record<string, unknown>\n }\n}\n\nexport const ANALYTICS_EVENTS_CONFIG = {\n // Primary/secondary CTA click, fired via sendCtaAnalytics.\n PRIMARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'Primary Action Selected',\n },\n SECONDARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'Secondary Action Selected',\n },\n // Fires once, gated on !beat.cta_clicked_at.\n FIRST_TIME_PRIMARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'First Time Primary Action Selected',\n },\n\n // \"Not Interested\" survey submitted; the call site sets the picked reason as `value`.\n BEAT_DISMISSED: {\n category: 'Beat Interaction',\n action: 'Beat Dismissed',\n },\n\n // Bar click on the card's inline chart.\n CHART_BAR_CLICKED: {\n category: 'Beat Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Bar Clicked`,\n },\n // Bar click inside the drill-down drawer.\n DRAWER_CHART_BAR_CLICKED: {\n category: 'Drawer Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Bar Clicked`,\n },\n // Month/tab change inside the drill-down drawer.\n TAB_SELECTED: {\n category: 'Drawer Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Month Tab Selected`,\n },\n // Series (e.g. Spend / Income) tab change inside the double-bar drawer.\n TYPE_FILTER_SELECTED: {\n category: 'Transactions Filter',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Transactions Filtered By Type`,\n },\n\n // LowAccountBalance threshold dialog.\n EDIT_INSIGHT_THRESHOLD_SAVE: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Save',\n },\n EDIT_INSIGHT_THRESHOLD_CANCELED: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Canceled',\n },\n EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Input Selected',\n },\n\n // SavingsOpportunityV2 safety-net dialog.\n EDIT_SAFETY_NET_SAVE: {\n category: 'Safety Net',\n action: 'Edit Safety Net',\n },\n // Ported verbatim from Pulse (uses '=' not '-').\n EDIT_SAFETY_NET_CANCEL: {\n category: 'Safety Net',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} = Edit Safety Net - Cancel`,\n },\n\n // Designate Emergency Savings Account (picker pick, Save, Open a Savings Account). Pulse's strings.\n EMERGENCY_SAVINGS_ACCT_SELECTED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account Selected',\n },\n EMERGENCY_SAVINGS_ACCT_SAVED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account Saved',\n },\n EMERGENCY_SAVINGS_ACCT_CREATED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account - Savings Account Created',\n },\n\n // Subscription status CTA answers and Undo (pulse's Subscription Confirmation).\n SUBSCRIPTION_CONFIRMED: {\n category: 'Subscription Confirmation',\n action: 'User Marked as Correct',\n },\n SUBSCRIPTION_NOT_SUBSCRIBED: {\n category: 'Subscription Confirmation',\n action: 'User Marked as Incorrect',\n },\n SUBSCRIPTION_NEVER_SUBSCRIBED: {\n category: 'Subscription Confirmation',\n action: 'Have Never Subscribed',\n },\n SUBSCRIPTION_CANCELLED: {\n category: 'Subscription Confirmation',\n action: 'Subscription Has Been Canceled',\n },\n SUBSCRIPTION_ONE_TIME_PURCHASE: {\n category: 'Subscription Confirmation',\n action: 'One Time Purchase',\n },\n SUBSCRIPTION_WRONG_FREQUENCY: {\n category: 'Subscription Confirmation',\n action: 'Frequency Is Incorrect',\n },\n /** Fired with \" - Previous action: <answer>\" appended, as pulse did. */\n SUBSCRIPTION_UNDO: { category: 'Subscription Confirmation', action: 'User Clicked Undo Button' },\n\n // Connect drawer opened. PostHog-only.\n OPENED_CONNECT_DRAWER: {\n postHog: {\n eventName: 'opened_connect_drawer',\n properties: (beat) => ({ beat_guid: beat.guid, template: beat.template }),\n },\n },\n} as const satisfies Record<string, AnalyticsEventConfigEntry>\n"],"mappings":"AAGA,IAAa,IAAA,CAAwB,MACnC,GAAU,QAAQ,aAAa,KAAK,GAAG,QAAQ,MAAM,EAAE,KAAK,IAkBjD,IAA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;AAAA,EACA,gCAAgC;AAAA,IAC9B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAGA,wBAAwB;AAAA,IACtB,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,6BAA6B;AAAA,IAC3B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,+BAA+B;AAAA,IAC7B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,wBAAwB;AAAA,IACtB,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,gCAAgC;AAAA,IAC9B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,8BAA8B;AAAA,IAC5B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAEA,mBAAmB;AAAA,IAAE,UAAU;AAAA,IAA6B,QAAQ;AAAA,EAA2B;AAAA,EAG/F,uBAAuB,EACrB,SAAS;AAAA,IACP,WAAW;AAAA,IACX,YAAA,CAAa,OAAU;AAAA,MAAE,WAAW,EAAK;AAAA,MAAM,UAAU,EAAK;AAAA,IAAS;AAAA,EACzE,EACF;AACF"}
|
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import { useAppConfig as
|
|
2
|
-
import { sendClientConfiguredCta as
|
|
3
|
-
import { BeatActionsProvider as
|
|
4
|
-
import { isContactSupportCtaDisabled as
|
|
5
|
-
import { reportCtaClick as
|
|
6
|
-
import { useBeatCtaActions as
|
|
7
|
-
import { actionBlocksKey as
|
|
8
|
-
import { logoFromRef as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import {
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
|
|
1
|
+
import { useAppConfig as K, useGlobalCopyStore as Y, useGlobalStore as $, useInsightsV2Store as q } from "../../common/context/hooks.es.js";
|
|
2
|
+
import { sendClientConfiguredCta as J } from "../../common/utils/PostMessage.es.js";
|
|
3
|
+
import { BeatActionsProvider as Q } from "../beatActions.es.js";
|
|
4
|
+
import { isContactSupportCtaDisabled as Z } from "../actionBlocks/ContactSupportActionBlock.es.js";
|
|
5
|
+
import { reportCtaClick as oo } from "../ctaActions/runCtaAction.es.js";
|
|
6
|
+
import { useBeatCtaActions as io } from "../ctaActions/useCtaAction.es.js";
|
|
7
|
+
import { actionBlocksKey as eo } from "../mappings/actionBlocksKey.es.js";
|
|
8
|
+
import { logoFromRef as to } from "./shared/EntityLogo.es.js";
|
|
9
|
+
import { CtaStatus as ro } from "./CtaStatus.es.js";
|
|
10
|
+
import no from "./FeedbackDialog.es.js";
|
|
11
|
+
import { ErrorCard as so } from "./ErrorCard.es.js";
|
|
12
|
+
import { blocks as ao } from "../mappings/blocks.es.js";
|
|
13
|
+
import { ActionBlockLayer as lo } from "../actionBlocks/ActionBlockLayer.es.js";
|
|
14
|
+
import co from "./Footer.es.js";
|
|
15
|
+
import mo from "./Header.es.js";
|
|
16
|
+
import { FeedbackBar as po } from "./FeedbackBar.es.js";
|
|
17
|
+
import { DismissInsightDialog as uo } from "./DismissInsightDialog.es.js";
|
|
18
|
+
import { HiddenConfirmationCard as fo } from "./HiddenConfirmationCard.es.js";
|
|
19
|
+
import { LoadingCard as bo } from "./LoadingCard.es.js";
|
|
20
|
+
import { ObsolesceBanner as Co } from "./ObsolesceBanner.es.js";
|
|
21
|
+
import { useBeatFeedbackFlow as ho } from "../hooks/useBeatFeedbackFlow.es.js";
|
|
22
|
+
import { useMemo as go } from "react";
|
|
23
|
+
import { observer as yo } from "mobx-react-lite";
|
|
24
|
+
import x from "@mui/material/Stack";
|
|
25
|
+
import { P as _o } from "@mxenabled/mxui";
|
|
26
|
+
import p from "@mui/material/Button";
|
|
27
|
+
import { ChevronRight as A } from "@mxenabled/mx-icons";
|
|
28
|
+
import { Fragment as ko, jsx as i, jsxs as u } from "react/jsx-runtime";
|
|
29
|
+
import xo from "@mui/material/Box";
|
|
30
|
+
import vo from "@mui/material/Card";
|
|
31
|
+
var So = {}, wo = {
|
|
31
32
|
position: "absolute",
|
|
32
33
|
top: 0,
|
|
33
34
|
left: 0,
|
|
@@ -36,7 +37,7 @@ var yo = {}, ko = {
|
|
|
36
37
|
backgroundColor: "background.default",
|
|
37
38
|
opacity: 0.7,
|
|
38
39
|
zIndex: 3
|
|
39
|
-
},
|
|
40
|
+
}, Do = {
|
|
40
41
|
alignItems: "center",
|
|
41
42
|
alignSelf: "flex-start",
|
|
42
43
|
display: "flex",
|
|
@@ -44,75 +45,75 @@ var yo = {}, ko = {
|
|
|
44
45
|
height: 44,
|
|
45
46
|
px: 2,
|
|
46
47
|
textTransform: "none"
|
|
47
|
-
},
|
|
48
|
+
}, Bo = {
|
|
48
49
|
color: "text.secondary",
|
|
49
50
|
fontSize: 13,
|
|
50
51
|
fontWeight: 600,
|
|
51
52
|
lineHeight: "16px",
|
|
52
53
|
"&.Mui-disabled": { color: "text.disabled" }
|
|
53
|
-
},
|
|
54
|
-
const
|
|
54
|
+
}, ri = yo(({ beat: e, beatActions: l = So, obsolete: C, isLoading: O = !1, isError: I = !1 }) => {
|
|
55
|
+
const F = Y(), E = q(), { config: M } = K(), o = ho(e, l), v = $(), { runCta: R, primary: h, secondary: S } = io(e, l, e.insights_payload?.primary_cta, e.insights_payload?.secondary_cta), f = e.insights_payload?.widget_type === "mini", N = go(() => ({
|
|
55
56
|
...o.wrappedActions,
|
|
56
|
-
beat:
|
|
57
|
-
}), [o.wrappedActions,
|
|
58
|
-
if (
|
|
59
|
-
const t =
|
|
57
|
+
beat: e
|
|
58
|
+
}), [o.wrappedActions, e]);
|
|
59
|
+
if (I) return /* @__PURE__ */ i(so, {});
|
|
60
|
+
const t = e.insights_payload;
|
|
60
61
|
if (!t || o.cardState === "dismissed") return null;
|
|
61
|
-
const { instance_slot:
|
|
62
|
-
logo:
|
|
62
|
+
const { instance_slot: H, primary_cta: n, secondary_cta: s, sub_title: P, title: G, guid: w, dismissed_at: V } = t, { block: z } = H, U = P ?? (t.subtitle ? {
|
|
63
|
+
logo: to(t.logo),
|
|
63
64
|
text: t.subtitle
|
|
64
|
-
} : void 0),
|
|
65
|
-
if (!
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
beat:
|
|
69
|
-
stores:
|
|
70
|
-
hostActions:
|
|
71
|
-
slot:
|
|
72
|
-
}),
|
|
65
|
+
} : void 0), c = (a) => Z(a, M, l.onContactSupport), D = async (a, m) => {
|
|
66
|
+
if (!c(m.block)) {
|
|
67
|
+
if (m.block === eo.CONTACT_SUPPORT_ACTION_BLOCK) {
|
|
68
|
+
oo({
|
|
69
|
+
beat: e,
|
|
70
|
+
stores: v,
|
|
71
|
+
hostActions: l,
|
|
72
|
+
slot: a
|
|
73
|
+
}), l.onContactSupport?.();
|
|
73
74
|
return;
|
|
74
75
|
}
|
|
75
|
-
await
|
|
76
|
+
await R(a, m);
|
|
76
77
|
}
|
|
77
|
-
},
|
|
78
|
-
const { is_mobile_webview:
|
|
79
|
-
|
|
80
|
-
isMobileWebview:
|
|
81
|
-
webviewScheme:
|
|
82
|
-
userGuid: t.user_guid ??
|
|
78
|
+
}, B = ao[z], d = t.in_description_cta, g = !f && d?.label && d.block ? d : void 0, y = n?.label || (g ? void 0 : d?.label) || void 0, b = !f && !!n?.label, L = e.in_description_cta || e.html_in_description_cta, W = () => {
|
|
79
|
+
const { is_mobile_webview: a, clientConfig: m } = v.appDataStore.appConfig;
|
|
80
|
+
J(e.template, {
|
|
81
|
+
isMobileWebview: a,
|
|
82
|
+
webviewScheme: m?.master?.ui_message_webview_url_scheme,
|
|
83
|
+
userGuid: t.user_guid ?? e.user_guid
|
|
83
84
|
});
|
|
84
|
-
},
|
|
85
|
-
return /* @__PURE__ */
|
|
85
|
+
}, r = b ? h.presentation : void 0, X = r?.kind === "hidden" && !!r.hideAll, T = !f && !!s?.label && !X, j = !!y && r?.kind !== "hidden" || T, _ = F.insights_feed?.general, k = C?.state === "not_refreshable" && !V && !!_;
|
|
86
|
+
return /* @__PURE__ */ i(Q, {
|
|
86
87
|
value: N,
|
|
87
|
-
children: /* @__PURE__ */
|
|
88
|
+
children: /* @__PURE__ */ u(x, {
|
|
88
89
|
sx: { mb: 16 },
|
|
89
90
|
children: [
|
|
90
|
-
o.cardState === "confirming" ? /* @__PURE__ */
|
|
91
|
+
o.cardState === "confirming" ? /* @__PURE__ */ i(fo, {
|
|
91
92
|
onClose: o.collapseConfirmation,
|
|
92
93
|
onLeaveFeedback: o.openHideSurvey,
|
|
93
94
|
onUndo: o.undoDismiss
|
|
94
|
-
}) : /* @__PURE__ */
|
|
95
|
-
...
|
|
96
|
-
copy:
|
|
97
|
-
}), /* @__PURE__ */
|
|
98
|
-
inert:
|
|
99
|
-
sx: { ...
|
|
95
|
+
}) : /* @__PURE__ */ u(ko, { children: [C && _ && /* @__PURE__ */ i(Co, {
|
|
96
|
+
...C,
|
|
97
|
+
copy: _
|
|
98
|
+
}), /* @__PURE__ */ u(vo, {
|
|
99
|
+
inert: k,
|
|
100
|
+
sx: { ...k && {
|
|
100
101
|
position: "relative",
|
|
101
102
|
zIndex: 2,
|
|
102
103
|
pointerEvents: "none"
|
|
103
104
|
} },
|
|
104
105
|
children: [
|
|
105
|
-
|
|
106
|
-
/* @__PURE__ */
|
|
107
|
-
isMini:
|
|
108
|
-
subtitle:
|
|
106
|
+
k && /* @__PURE__ */ i(xo, { sx: wo }),
|
|
107
|
+
/* @__PURE__ */ i(mo, {
|
|
108
|
+
isMini: f,
|
|
109
|
+
subtitle: U,
|
|
109
110
|
title: G ?? ""
|
|
110
111
|
}),
|
|
111
|
-
O ? /* @__PURE__ */
|
|
112
|
-
beatGuid:
|
|
112
|
+
O ? /* @__PURE__ */ i(bo, {}) : B && /* @__PURE__ */ i(B, {
|
|
113
|
+
beatGuid: w,
|
|
113
114
|
payload: t
|
|
114
115
|
}),
|
|
115
|
-
/* @__PURE__ */
|
|
116
|
+
/* @__PURE__ */ u(x, {
|
|
116
117
|
sx: {
|
|
117
118
|
gap: 6,
|
|
118
119
|
pb: 16,
|
|
@@ -120,14 +121,14 @@ var yo = {}, ko = {
|
|
|
120
121
|
px: 16
|
|
121
122
|
},
|
|
122
123
|
children: [
|
|
123
|
-
/* @__PURE__ */
|
|
124
|
+
/* @__PURE__ */ i(_o, {
|
|
124
125
|
dangerouslySetInnerHTML: { __html: t.description.html_text },
|
|
125
126
|
variant: "subtitle2"
|
|
126
127
|
}),
|
|
127
|
-
|
|
128
|
-
endIcon: /* @__PURE__ */
|
|
129
|
-
onClick: () =>
|
|
130
|
-
guid:
|
|
128
|
+
g && /* @__PURE__ */ i(p, {
|
|
129
|
+
endIcon: /* @__PURE__ */ i(A, {}),
|
|
130
|
+
onClick: () => E.openActionDrawer({
|
|
131
|
+
guid: w,
|
|
131
132
|
trigger: "inDescriptionCta"
|
|
132
133
|
}),
|
|
133
134
|
sx: {
|
|
@@ -135,66 +136,72 @@ var yo = {}, ko = {
|
|
|
135
136
|
p: 4,
|
|
136
137
|
width: "max-content"
|
|
137
138
|
},
|
|
138
|
-
children:
|
|
139
|
+
children: g.label
|
|
139
140
|
}),
|
|
140
|
-
!
|
|
141
|
-
endIcon: /* @__PURE__ */
|
|
142
|
-
onClick:
|
|
141
|
+
!d?.label && L && /* @__PURE__ */ i(p, {
|
|
142
|
+
endIcon: /* @__PURE__ */ i(A, {}),
|
|
143
|
+
onClick: W,
|
|
143
144
|
sx: {
|
|
144
145
|
height: 24,
|
|
145
146
|
p: 4,
|
|
146
147
|
width: "max-content"
|
|
147
148
|
},
|
|
148
|
-
children:
|
|
149
|
+
children: L
|
|
149
150
|
})
|
|
150
151
|
]
|
|
151
152
|
}),
|
|
152
|
-
|
|
153
|
+
j && /* @__PURE__ */ u(x, {
|
|
153
154
|
sx: {
|
|
154
155
|
gap: 8,
|
|
155
156
|
pb: 16,
|
|
156
157
|
px: 16
|
|
157
158
|
},
|
|
158
159
|
children: [
|
|
159
|
-
|
|
160
|
-
sx:
|
|
160
|
+
y && !b && /* @__PURE__ */ i(p, {
|
|
161
|
+
sx: Do,
|
|
161
162
|
variant: "text",
|
|
162
|
-
children:
|
|
163
|
+
children: y
|
|
163
164
|
}),
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
b && n && r?.kind === "status" && /* @__PURE__ */ i(ro, {
|
|
166
|
+
action: r.action,
|
|
167
|
+
icon: r.icon,
|
|
168
|
+
label: r.label,
|
|
169
|
+
tone: r.tone
|
|
170
|
+
}),
|
|
171
|
+
b && n && !r && /* @__PURE__ */ i(p, {
|
|
172
|
+
"aria-disabled": c(n.block) || h.disabled,
|
|
173
|
+
disabled: h.disabled,
|
|
174
|
+
onClick: () => D("primary", n),
|
|
175
|
+
sx: { ...c(n.block) && { color: "text.disabled" } },
|
|
169
176
|
variant: "outlined",
|
|
170
|
-
children:
|
|
177
|
+
children: n.label
|
|
171
178
|
}),
|
|
172
|
-
|
|
173
|
-
"aria-disabled":
|
|
179
|
+
T && s && /* @__PURE__ */ i(p, {
|
|
180
|
+
"aria-disabled": c(s.block) || S.disabled,
|
|
174
181
|
color: "inherit",
|
|
175
|
-
disabled:
|
|
176
|
-
onClick: () =>
|
|
182
|
+
disabled: S.disabled,
|
|
183
|
+
onClick: () => D("secondary", s),
|
|
177
184
|
sx: {
|
|
178
|
-
...
|
|
179
|
-
...
|
|
185
|
+
...Bo,
|
|
186
|
+
...c(s.block) && { color: "text.disabled" }
|
|
180
187
|
},
|
|
181
|
-
children:
|
|
188
|
+
children: s.label
|
|
182
189
|
})
|
|
183
190
|
]
|
|
184
191
|
}),
|
|
185
|
-
/* @__PURE__ */
|
|
192
|
+
/* @__PURE__ */ i(po, {
|
|
186
193
|
onTellUsMore: o.openRatingSurvey,
|
|
187
194
|
show: o.isFeedbackBarShown
|
|
188
195
|
})
|
|
189
196
|
]
|
|
190
197
|
})] }),
|
|
191
|
-
/* @__PURE__ */
|
|
192
|
-
/* @__PURE__ */
|
|
198
|
+
/* @__PURE__ */ i(lo, { beat: e }),
|
|
199
|
+
/* @__PURE__ */ i(uo, {
|
|
193
200
|
isOpen: o.isDismissOpen,
|
|
194
201
|
onClose: o.closeDismissDialog,
|
|
195
202
|
onDismiss: o.confirmDismiss
|
|
196
203
|
}),
|
|
197
|
-
o.isSurveyOpen && /* @__PURE__ */
|
|
204
|
+
o.isSurveyOpen && /* @__PURE__ */ i(no, {
|
|
198
205
|
characterLimitLabel: o.survey.characterLimitLabel,
|
|
199
206
|
closeAriaLabel: o.survey.closeAriaLabel,
|
|
200
207
|
isOpen: !0,
|
|
@@ -207,13 +214,13 @@ var yo = {}, ko = {
|
|
|
207
214
|
secondaryText: o.survey.backText,
|
|
208
215
|
title: o.survey.title
|
|
209
216
|
}),
|
|
210
|
-
o.cardState === "visible" && t.footer && /* @__PURE__ */
|
|
217
|
+
o.cardState === "visible" && t.footer && /* @__PURE__ */ i(co, { footer: t.footer })
|
|
211
218
|
]
|
|
212
219
|
})
|
|
213
220
|
});
|
|
214
221
|
});
|
|
215
222
|
export {
|
|
216
|
-
|
|
223
|
+
ri as default
|
|
217
224
|
};
|
|
218
225
|
|
|
219
226
|
//# sourceMappingURL=BaseLayout.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseLayout.es.js","names":[],"sources":["../../../src/insights-v2/components/BaseLayout.tsx"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport Stack from '@mui/material/Stack'\n\nimport { ChevronRight } from '@mxenabled/mx-icons'\nimport { P } from '@mxenabled/mxui'\n\nimport { blocks } from '../mappings/blocks'\nimport { actionBlocksKey } from '../mappings/actionBlocksKey'\nimport { isContactSupportCtaDisabled } from '../actionBlocks/ContactSupportActionBlock'\nimport { logoFromRef } from './shared/EntityLogo'\n\nimport Footer from './Footer'\nimport Header from './Header'\nimport FeedbackBar from './FeedbackBar'\nimport FeedbackDialog from './FeedbackDialog'\nimport DismissInsightDialog from './DismissInsightDialog'\nimport HiddenConfirmationCard from './HiddenConfirmationCard'\nimport ErrorCard from './ErrorCard'\nimport LoadingCard from './LoadingCard'\nimport { ObsolesceBanner, type ObsolesceBannerState } from './ObsolesceBanner'\nimport { useAppConfig, useGlobalCopyStore, useGlobalStore, useInsightsV2Store } from '../../common'\nimport { sendClientConfiguredCta } from '../../common/utils/PostMessage'\nimport type { Beat, PrimaryCTA, SecondaryCTA } from '../../core'\nimport { BeatActionsProvider, type BeatActions } from '../beatActions'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { reportCtaClick, useBeatCtaActions } from '../ctaActions'\nimport { useBeatFeedbackFlow } from '../hooks/useBeatFeedbackFlow'\n\nexport interface ObsoleteState {\n state: ObsolesceBannerState\n onRefresh: () => void\n onDismiss: () => void\n}\n\ninterface BaseLayoutProps {\n beat: Beat\n beatActions?: BeatActions\n obsolete?: ObsoleteState\n /** Swap only the block slot for a LoadingCard (e.g. while a sampled beat loads). */\n isLoading?: boolean\n /** Replace the entire card with an ErrorCard (e.g. when the sample fails to load). */\n isError?: boolean\n}\n\nconst NO_BEAT_ACTIONS: BeatActions = {}\n\nconst OBSOLETE_OVERLAY_SX = {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n backgroundColor: 'background.default',\n opacity: 0.7,\n // Above every block's own z-index (hero card 1, AccountBlock 2), or that section shows through.\n zIndex: 3,\n} as const\n\n// Mini CTA label styled like a Button.\nconst MINI_CTA_SX = {\n alignItems: 'center',\n alignSelf: 'flex-start',\n display: 'flex',\n fontWeight: 600,\n height: 44,\n px: 2,\n textTransform: 'none',\n} as const\n\n// Full card's secondary CTA (e.g. Fee Detected's Contact Support): a quiet text button, 13/16\n// semibold in text.secondary. `color=\"inherit\"` keeps hover, ripple and focus off the primary palette.\n// An unavailable CTA (contact_support_block with no host handler) is dimmed at the call site, as the\n// primary CTA is, because it is only aria-disabled and so never matches `.Mui-disabled`.\nconst SECONDARY_CTA_SX = {\n color: 'text.secondary',\n fontSize: 13,\n fontWeight: 600,\n lineHeight: '16px',\n '&.Mui-disabled': { color: 'text.disabled' },\n} as const\n\nconst BaseLayout = observer(\n ({\n beat,\n beatActions = NO_BEAT_ACTIONS,\n obsolete,\n isLoading = false,\n isError = false,\n }: BaseLayoutProps) => {\n const copy = useGlobalCopyStore()\n const insightsV2Store = useInsightsV2Store()\n const { config } = useAppConfig()\n const flow = useBeatFeedbackFlow(beat, beatActions)\n\n const stores = useGlobalStore()\n const {\n runCta: handleCtaClick,\n primary: primaryCtaState,\n secondary: secondaryCtaState,\n } = useBeatCtaActions(\n beat,\n beatActions,\n beat.insights_payload?.primary_cta,\n beat.insights_payload?.secondary_cta,\n )\n\n // Guard: payload may not be loaded yet (isLoading/isError states).\n const isMini = beat.insights_payload?.widget_type === 'mini'\n\n // Memoized: an inline object here would change identity every render, making every\n // useAnalyticsEvent() consumer's callback (and its effect deps) unstable too.\n const beatActionsValue = useMemo(\n () => ({ ...flow.wrappedActions, beat }),\n [flow.wrappedActions, beat],\n )\n\n // Error replaces the entire card; loading only swaps the block slot (below).\n if (isError) return <ErrorCard />\n\n const insights_payload = beat.insights_payload\n\n if (!insights_payload) return null\n if (flow.cardState === 'dismissed') return null\n\n const { instance_slot, primary_cta, secondary_cta, sub_title, title, guid, dismissed_at } =\n insights_payload\n const { block } = instance_slot\n\n // Rebuild V1 subtitle shape; sub_title wins if present.\n const subtitle =\n sub_title ??\n (insights_payload.subtitle\n ? {\n logo: logoFromRef(insights_payload.logo),\n text: insights_payload.subtitle,\n }\n : undefined)\n\n // CTAs run via ctaActions; contact_support_block bypasses it.\n const isCtaDisabled = (ctaBlock: string | null | undefined) =>\n isContactSupportCtaDisabled(ctaBlock, config, beatActions.onContactSupport)\n\n const onCtaClick = async (slot: 'primary' | 'secondary', cta: PrimaryCTA | SecondaryCTA) => {\n if (isCtaDisabled(cta.block)) return\n\n if (cta.block === actionBlocksKey.CONTACT_SUPPORT_ACTION_BLOCK) {\n // Bypasses the runner, but still reports the press like any other CTA: the generic\n // press event, and (on a first primary press) FIRST_TIME_PRIMARY_ACTION_SELECTED +\n // cta_clicked_at.\n reportCtaClick({ beat, stores, hostActions: beatActions, slot })\n beatActions.onContactSupport?.()\n return\n }\n\n await handleCtaClick(slot, cta)\n }\n\n const Block = blocks[block as keyof typeof blocks]\n\n const inDescriptionCta = insights_payload.in_description_cta\n // Full card: the envelope's link opens the drawer its block names. A link with no block (mini's\n // \"Make a Transfer\") is the card's action, drawn as the mini label below, never a dead link.\n const envelopeLink =\n !isMini && inDescriptionCta?.label && inDescriptionCta.block ? inDescriptionCta : undefined\n // The card's action label: the primary CTA's, else a block-less envelope link's (ditto ≥ 1.4.3\n // sends mini's action as in_description_cta). `||`, not `??`: the copy may send the primary label\n // as \"\" rather than omit it, and an empty string must fall through. It is a button only on a full\n // card with a primary CTA; otherwise a label, so a tap reaches the host's card handler.\n const ctaLabel =\n primary_cta?.label || (envelopeLink ? undefined : inDescriptionCta?.label) || undefined\n const isCtaButton = !isMini && !!primary_cta?.label\n const clientConfiguredLabel = beat.in_description_cta || beat.html_in_description_cta\n const onClientConfiguredLinkClick = () => {\n const { is_mobile_webview, clientConfig } = stores.appDataStore.appConfig\n\n sendClientConfiguredCta(beat.template, {\n isMobileWebview: is_mobile_webview,\n webviewScheme: clientConfig?.master?.ui_message_webview_url_scheme,\n userGuid: insights_payload.user_guid ?? beat.user_guid,\n })\n }\n const showSecondaryCta = !isMini && !!secondary_cta?.label\n const obsoleteCopy = copy.insights_feed?.general\n const isObsoleteDimmed =\n obsolete?.state === 'not_refreshable' && !dismissed_at && !!obsoleteCopy\n\n return (\n <BeatActionsProvider value={beatActionsValue}>\n <Stack sx={{ mb: 16 }}>\n {flow.cardState === 'confirming' ? (\n <HiddenConfirmationCard\n onClose={flow.collapseConfirmation}\n onLeaveFeedback={flow.openHideSurvey}\n onUndo={flow.undoDismiss}\n />\n ) : (\n <>\n {obsolete && obsoleteCopy && <ObsolesceBanner {...obsolete} copy={obsoleteCopy} />}\n <Card\n inert={isObsoleteDimmed}\n sx={{\n ...(isObsoleteDimmed && {\n position: 'relative',\n zIndex: 2,\n pointerEvents: 'none',\n }),\n }}\n >\n {isObsoleteDimmed && <Box sx={OBSOLETE_OVERLAY_SX} />}\n <Header isMini={isMini} subtitle={subtitle} title={title ?? ''} />\n {isLoading ? (\n <LoadingCard />\n ) : (\n Block && <Block beatGuid={guid} payload={insights_payload} />\n )}\n\n <Stack sx={{ gap: 6, pb: 16, pt: 12, px: 16 }}>\n <P\n dangerouslySetInnerHTML={{\n __html: insights_payload.description.html_text,\n }}\n variant=\"subtitle2\"\n />\n {/* V2: the envelope's link opens the action block it names. */}\n {envelopeLink && (\n <Button\n endIcon={<ChevronRight />}\n onClick={() =>\n insightsV2Store.openActionDrawer({ guid, trigger: 'inDescriptionCta' })\n }\n sx={{ height: 24, p: 4, width: 'max-content' }}\n >\n {envelopeLink.label}\n </Button>\n )}\n {/* Custom-copy link when the envelope sends none; legacy mini shows it too, so no mini guard. */}\n {!inDescriptionCta?.label && clientConfiguredLabel && (\n <Button\n endIcon={<ChevronRight />}\n onClick={onClientConfiguredLinkClick}\n sx={{ height: 24, p: 4, width: 'max-content' }}\n >\n {clientConfiguredLabel}\n </Button>\n )}\n </Stack>\n\n {(ctaLabel || showSecondaryCta) && (\n <Stack sx={{ gap: 8, pb: 16, px: 16 }}>\n {ctaLabel &&\n !isCtaButton && (\n // The card's action when it has no primary CTA button (mini always; a full card whose\n // only link names no block). What the tap does is the host's decision (Pulse posts\n // `carousel/cta`, the same redirect a V1 mini card sends), never the action drawer the\n // full card's CTA opens. It is a real (blue, focusable) button for that tap, but has no\n // handler of its own and does not stop the click, so it reaches the host's card handler\n // exactly as a tap on the card does.\n <Button sx={MINI_CTA_SX} variant=\"text\">\n {ctaLabel}\n </Button>\n )}\n {isCtaButton && primary_cta && (\n <Button\n aria-disabled={isCtaDisabled(primary_cta.block) || primaryCtaState.disabled}\n disabled={primaryCtaState.disabled}\n onClick={() => onCtaClick('primary', primary_cta)}\n sx={{\n ...(isCtaDisabled(primary_cta.block) && { color: 'text.disabled' }),\n }}\n variant=\"outlined\"\n >\n {primary_cta.label}\n </Button>\n )}\n {/* Mini has room for one CTA. */}\n {showSecondaryCta && secondary_cta && (\n <Button\n aria-disabled={\n isCtaDisabled(secondary_cta.block) || secondaryCtaState.disabled\n }\n color=\"inherit\"\n disabled={secondaryCtaState.disabled}\n onClick={() => onCtaClick('secondary', secondary_cta)}\n sx={{\n ...SECONDARY_CTA_SX,\n ...(isCtaDisabled(secondary_cta.block) && { color: 'text.disabled' }),\n }}\n >\n {secondary_cta.label}\n </Button>\n )}\n </Stack>\n )}\n\n <FeedbackBar onTellUsMore={flow.openRatingSurvey} show={flow.isFeedbackBarShown} />\n </Card>\n </>\n )}\n\n <ActionBlockLayer beat={beat} />\n\n <DismissInsightDialog\n isOpen={flow.isDismissOpen}\n onClose={flow.closeDismissDialog}\n onDismiss={flow.confirmDismiss}\n />\n\n {flow.isSurveyOpen && (\n <FeedbackDialog\n characterLimitLabel={flow.survey.characterLimitLabel}\n closeAriaLabel={flow.survey.closeAriaLabel}\n isOpen={true}\n onBackClick={flow.feedbackDialogCallbacks.onBackClick}\n onClose={flow.closeSurvey}\n onSubmit={flow.submitSurvey}\n onTextInputFocus={flow.feedbackDialogCallbacks.onTextInputFocus}\n options={flow.survey.options}\n primaryText={flow.survey.submitText}\n secondaryText={flow.survey.backText}\n title={flow.survey.title}\n />\n )}\n\n {flow.cardState === 'visible' && insights_payload.footer && (\n <Footer footer={insights_payload.footer} />\n )}\n </Stack>\n </Beat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BACpD,IAAI;AAAA,oBACF,GAAG;AAAA,oBACH,GAAI,EAAc,EAAc,KAAK,KAAK,EAAE,OAAO,gBAAgB;AAAA,kBACrE;AAAA,kBAEC,UAAA,EAAc;AAAA,gBACT,CAAA;AAAA,cAEL;AAAA;YAGT,gBAAA,EAAC,IAAD;AAAA,cAAa,cAAc,EAAK;AAAA,cAAkB,MAAM,EAAK;AAAA,YAAqB,CAAA;AAAA,UAC9E;AAAA,QACN,CAAA,CAAA,EAAA,CAAA;AAAA,QAGJ,gBAAA,EAAC,IAAD,EAAwB,MAAA,EAAO,CAAA;AAAA,QAE/B,gBAAA,EAAC,IAAD;AAAA,UACE,QAAQ,EAAK;AAAA,UACb,SAAS,EAAK;AAAA,UACd,WAAW,EAAK;AAAA,QACjB,CAAA;AAAA,QAEA,EAAK,gBACJ,gBAAA,EAAC,IAAD;AAAA,UACE,qBAAqB,EAAK,OAAO;AAAA,UACjC,gBAAgB,EAAK,OAAO;AAAA,UAC5B,QAAQ;AAAA,UACR,aAAa,EAAK,wBAAwB;AAAA,UAC1C,SAAS,EAAK;AAAA,UACd,UAAU,EAAK;AAAA,UACf,kBAAkB,EAAK,wBAAwB;AAAA,UAC/C,SAAS,EAAK,OAAO;AAAA,UACrB,aAAa,EAAK,OAAO;AAAA,UACzB,eAAe,EAAK,OAAO;AAAA,UAC3B,OAAO,EAAK,OAAO;AAAA,QACpB,CAAA;AAAA,QAGF,EAAK,cAAc,aAAa,EAAiB,UAChD,gBAAA,EAAC,IAAD,EAAQ,QAAQ,EAAiB,OAAS,CAAA;AAAA,MAEvC;AAAA;EACY,CAAA;AAEzB,CACF"}
|
|
1
|
+
{"version":3,"file":"BaseLayout.es.js","names":[],"sources":["../../../src/insights-v2/components/BaseLayout.tsx"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport Stack from '@mui/material/Stack'\n\nimport { ChevronRight } from '@mxenabled/mx-icons'\nimport { P } from '@mxenabled/mxui'\n\nimport { blocks } from '../mappings/blocks'\nimport { actionBlocksKey } from '../mappings/actionBlocksKey'\nimport { isContactSupportCtaDisabled } from '../actionBlocks/ContactSupportActionBlock'\nimport { logoFromRef } from './shared/EntityLogo'\n\nimport Footer from './Footer'\nimport Header from './Header'\nimport FeedbackBar from './FeedbackBar'\nimport FeedbackDialog from './FeedbackDialog'\nimport DismissInsightDialog from './DismissInsightDialog'\nimport HiddenConfirmationCard from './HiddenConfirmationCard'\nimport ErrorCard from './ErrorCard'\nimport LoadingCard from './LoadingCard'\nimport { ObsolesceBanner, type ObsolesceBannerState } from './ObsolesceBanner'\nimport { useAppConfig, useGlobalCopyStore, useGlobalStore, useInsightsV2Store } from '../../common'\nimport { sendClientConfiguredCta } from '../../common/utils/PostMessage'\nimport type { Beat, PrimaryCTA, SecondaryCTA } from '../../core'\nimport { BeatActionsProvider, type BeatActions } from '../beatActions'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { reportCtaClick, useBeatCtaActions } from '../ctaActions'\nimport { CtaStatus } from './CtaStatus'\nimport { useBeatFeedbackFlow } from '../hooks/useBeatFeedbackFlow'\n\nexport interface ObsoleteState {\n state: ObsolesceBannerState\n onRefresh: () => void\n onDismiss: () => void\n}\n\ninterface BaseLayoutProps {\n beat: Beat\n beatActions?: BeatActions\n obsolete?: ObsoleteState\n /** Swap only the block slot for a LoadingCard (e.g. while a sampled beat loads). */\n isLoading?: boolean\n /** Replace the entire card with an ErrorCard (e.g. when the sample fails to load). */\n isError?: boolean\n}\n\nconst NO_BEAT_ACTIONS: BeatActions = {}\n\nconst OBSOLETE_OVERLAY_SX = {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n backgroundColor: 'background.default',\n opacity: 0.7,\n // Above every block's own z-index (hero card 1, AccountBlock 2), or that section shows through.\n zIndex: 3,\n} as const\n\n// Mini CTA label styled like a Button.\nconst MINI_CTA_SX = {\n alignItems: 'center',\n alignSelf: 'flex-start',\n display: 'flex',\n fontWeight: 600,\n height: 44,\n px: 2,\n textTransform: 'none',\n} as const\n\n// Full card's secondary CTA (e.g. Fee Detected's Contact Support): a quiet text button, 13/16\n// semibold in text.secondary. `color=\"inherit\"` keeps hover, ripple and focus off the primary palette.\n// An unavailable CTA (contact_support_block with no host handler) is dimmed at the call site, as the\n// primary CTA is, because it is only aria-disabled and so never matches `.Mui-disabled`.\nconst SECONDARY_CTA_SX = {\n color: 'text.secondary',\n fontSize: 13,\n fontWeight: 600,\n lineHeight: '16px',\n '&.Mui-disabled': { color: 'text.disabled' },\n} as const\n\nconst BaseLayout = observer(\n ({\n beat,\n beatActions = NO_BEAT_ACTIONS,\n obsolete,\n isLoading = false,\n isError = false,\n }: BaseLayoutProps) => {\n const copy = useGlobalCopyStore()\n const insightsV2Store = useInsightsV2Store()\n const { config } = useAppConfig()\n const flow = useBeatFeedbackFlow(beat, beatActions)\n\n const stores = useGlobalStore()\n const {\n runCta: handleCtaClick,\n primary: primaryCtaState,\n secondary: secondaryCtaState,\n } = useBeatCtaActions(\n beat,\n beatActions,\n beat.insights_payload?.primary_cta,\n beat.insights_payload?.secondary_cta,\n )\n\n // Guard: payload may not be loaded yet (isLoading/isError states).\n const isMini = beat.insights_payload?.widget_type === 'mini'\n\n // Memoized: an inline object here would change identity every render, making every\n // useAnalyticsEvent() consumer's callback (and its effect deps) unstable too.\n const beatActionsValue = useMemo(\n () => ({ ...flow.wrappedActions, beat }),\n [flow.wrappedActions, beat],\n )\n\n // Error replaces the entire card; loading only swaps the block slot (below).\n if (isError) return <ErrorCard />\n\n const insights_payload = beat.insights_payload\n\n if (!insights_payload) return null\n if (flow.cardState === 'dismissed') return null\n\n const { instance_slot, primary_cta, secondary_cta, sub_title, title, guid, dismissed_at } =\n insights_payload\n const { block } = instance_slot\n\n // Rebuild V1 subtitle shape; sub_title wins if present.\n const subtitle =\n sub_title ??\n (insights_payload.subtitle\n ? {\n logo: logoFromRef(insights_payload.logo),\n text: insights_payload.subtitle,\n }\n : undefined)\n\n // CTAs run via ctaActions; contact_support_block bypasses it.\n const isCtaDisabled = (ctaBlock: string | null | undefined) =>\n isContactSupportCtaDisabled(ctaBlock, config, beatActions.onContactSupport)\n\n const onCtaClick = async (slot: 'primary' | 'secondary', cta: PrimaryCTA | SecondaryCTA) => {\n if (isCtaDisabled(cta.block)) return\n\n if (cta.block === actionBlocksKey.CONTACT_SUPPORT_ACTION_BLOCK) {\n // Bypasses the runner, but still reports the press like any other CTA: the generic\n // press event, and (on a first primary press) FIRST_TIME_PRIMARY_ACTION_SELECTED +\n // cta_clicked_at.\n reportCtaClick({ beat, stores, hostActions: beatActions, slot })\n beatActions.onContactSupport?.()\n return\n }\n\n await handleCtaClick(slot, cta)\n }\n\n const Block = blocks[block as keyof typeof blocks]\n\n const inDescriptionCta = insights_payload.in_description_cta\n // Full card: the envelope's link opens the drawer its block names. A link with no block (mini's\n // \"Make a Transfer\") is the card's action, drawn as the mini label below, never a dead link.\n const envelopeLink =\n !isMini && inDescriptionCta?.label && inDescriptionCta.block ? inDescriptionCta : undefined\n // The card's action label: the primary CTA's, else a block-less envelope link's (ditto ≥ 1.4.3\n // sends mini's action as in_description_cta). `||`, not `??`: the copy may send the primary label\n // as \"\" rather than omit it, and an empty string must fall through. It is a button only on a full\n // card with a primary CTA; otherwise a label, so a tap reaches the host's card handler.\n const ctaLabel =\n primary_cta?.label || (envelopeLink ? undefined : inDescriptionCta?.label) || undefined\n const isCtaButton = !isMini && !!primary_cta?.label\n const clientConfiguredLabel = beat.in_description_cta || beat.html_in_description_cta\n const onClientConfiguredLinkClick = () => {\n const { is_mobile_webview, clientConfig } = stores.appDataStore.appConfig\n\n sendClientConfiguredCta(beat.template, {\n isMobileWebview: is_mobile_webview,\n webviewScheme: clientConfig?.master?.ui_message_webview_url_scheme,\n userGuid: insights_payload.user_guid ?? beat.user_guid,\n })\n }\n // The primary step's presenter may draw a status or nothing instead of the button (full card only).\n const primaryPresentation = isCtaButton ? primaryCtaState.presentation : undefined\n const hidesAllCtas = primaryPresentation?.kind === 'hidden' && !!primaryPresentation.hideAll\n const showSecondaryCta = !isMini && !!secondary_cta?.label && !hidesAllCtas\n const showCtaRow = (!!ctaLabel && primaryPresentation?.kind !== 'hidden') || showSecondaryCta\n const obsoleteCopy = copy.insights_feed?.general\n const isObsoleteDimmed =\n obsolete?.state === 'not_refreshable' && !dismissed_at && !!obsoleteCopy\n\n return (\n <BeatActionsProvider value={beatActionsValue}>\n <Stack sx={{ mb: 16 }}>\n {flow.cardState === 'confirming' ? (\n <HiddenConfirmationCard\n onClose={flow.collapseConfirmation}\n onLeaveFeedback={flow.openHideSurvey}\n onUndo={flow.undoDismiss}\n />\n ) : (\n <>\n {obsolete && obsoleteCopy && <ObsolesceBanner {...obsolete} copy={obsoleteCopy} />}\n <Card\n inert={isObsoleteDimmed}\n sx={{\n ...(isObsoleteDimmed && {\n position: 'relative',\n zIndex: 2,\n pointerEvents: 'none',\n }),\n }}\n >\n {isObsoleteDimmed && <Box sx={OBSOLETE_OVERLAY_SX} />}\n <Header isMini={isMini} subtitle={subtitle} title={title ?? ''} />\n {isLoading ? (\n <LoadingCard />\n ) : (\n Block && <Block beatGuid={guid} payload={insights_payload} />\n )}\n\n <Stack sx={{ gap: 6, pb: 16, pt: 12, px: 16 }}>\n <P\n dangerouslySetInnerHTML={{\n __html: insights_payload.description.html_text,\n }}\n variant=\"subtitle2\"\n />\n {/* V2: the envelope's link opens the action block it names. */}\n {envelopeLink && (\n <Button\n endIcon={<ChevronRight />}\n onClick={() =>\n insightsV2Store.openActionDrawer({ guid, trigger: 'inDescriptionCta' })\n }\n sx={{ height: 24, p: 4, width: 'max-content' }}\n >\n {envelopeLink.label}\n </Button>\n )}\n {/* Custom-copy link when the envelope sends none; legacy mini shows it too, so no mini guard. */}\n {!inDescriptionCta?.label && clientConfiguredLabel && (\n <Button\n endIcon={<ChevronRight />}\n onClick={onClientConfiguredLinkClick}\n sx={{ height: 24, p: 4, width: 'max-content' }}\n >\n {clientConfiguredLabel}\n </Button>\n )}\n </Stack>\n\n {showCtaRow && (\n <Stack sx={{ gap: 8, pb: 16, px: 16 }}>\n {ctaLabel &&\n !isCtaButton && (\n // The card's action when it has no primary CTA button (mini always; a full card whose\n // only link names no block). What the tap does is the host's decision (Pulse posts\n // `carousel/cta`, the same redirect a V1 mini card sends), never the action drawer the\n // full card's CTA opens. It is a real (blue, focusable) button for that tap, but has no\n // handler of its own and does not stop the click, so it reaches the host's card handler\n // exactly as a tap on the card does.\n <Button sx={MINI_CTA_SX} variant=\"text\">\n {ctaLabel}\n </Button>\n )}\n {isCtaButton && primary_cta && primaryPresentation?.kind === 'status' && (\n <CtaStatus\n action={primaryPresentation.action}\n icon={primaryPresentation.icon}\n label={primaryPresentation.label}\n tone={primaryPresentation.tone}\n />\n )}\n {isCtaButton && primary_cta && !primaryPresentation && (\n <Button\n aria-disabled={isCtaDisabled(primary_cta.block) || primaryCtaState.disabled}\n disabled={primaryCtaState.disabled}\n onClick={() => onCtaClick('primary', primary_cta)}\n sx={{\n ...(isCtaDisabled(primary_cta.block) && { color: 'text.disabled' }),\n }}\n variant=\"outlined\"\n >\n {primary_cta.label}\n </Button>\n )}\n {/* Mini has room for one CTA. */}\n {showSecondaryCta && secondary_cta && (\n <Button\n aria-disabled={\n isCtaDisabled(secondary_cta.block) || secondaryCtaState.disabled\n }\n color=\"inherit\"\n disabled={secondaryCtaState.disabled}\n onClick={() => onCtaClick('secondary', secondary_cta)}\n sx={{\n ...SECONDARY_CTA_SX,\n ...(isCtaDisabled(secondary_cta.block) && { color: 'text.disabled' }),\n }}\n >\n {secondary_cta.label}\n </Button>\n )}\n </Stack>\n )}\n\n <FeedbackBar onTellUsMore={flow.openRatingSurvey} show={flow.isFeedbackBarShown} />\n </Card>\n </>\n )}\n\n <ActionBlockLayer beat={beat} />\n\n <DismissInsightDialog\n isOpen={flow.isDismissOpen}\n onClose={flow.closeDismissDialog}\n onDismiss={flow.confirmDismiss}\n />\n\n {flow.isSurveyOpen && (\n <FeedbackDialog\n characterLimitLabel={flow.survey.characterLimitLabel}\n closeAriaLabel={flow.survey.closeAriaLabel}\n isOpen={true}\n onBackClick={flow.feedbackDialogCallbacks.onBackClick}\n onClose={flow.closeSurvey}\n onSubmit={flow.submitSurvey}\n onTextInputFocus={flow.feedbackDialogCallbacks.onTextInputFocus}\n options={flow.survey.options}\n primaryText={flow.survey.submitText}\n secondaryText={flow.survey.backText}\n title={flow.survey.title}\n />\n )}\n\n {flow.cardState === 'visible' && insights_payload.footer && (\n <Footer footer={insights_payload.footer} />\n )}\n </Stack>\n </BeatActionsProvider>\n )\n },\n)\n\nexport default BaseLayout\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAM,KAA+B,CAAC,GAEhC,KAAsB;AAAA,EAC1B,UAAU;AAAA,EACV,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,iBAAiB;AAAA,EACjB,SAAS;AAAA,EAET,QAAQ;AACV,GAGM,KAAc;AAAA,EAClB,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,eAAe;AACjB,GAMM,KAAmB;AAAA,EACvB,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,kBAAkB,EAAE,OAAO,gBAAgB;AAC7C,GAEM,KAAa,GAAA,CAChB,EACC,MAAA,GACA,aAAA,IAAc,IACd,UAAA,GACA,WAAA,IAAY,IACZ,SAAA,IAAU,GAAA,MACW;AACrB,QAAM,IAAO,EAAmB,GAC1B,IAAkB,EAAmB,GACrC,EAAE,QAAA,EAAA,IAAW,EAAa,GAC1B,IAAO,GAAoB,GAAM,CAAW,GAE5C,IAAS,EAAe,GACxB,EACJ,QAAQ,GACR,S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EAAK;AAAA,QACjB,CAAA;AAAA,QAEA,EAAK,gBACJ,gBAAA,EAAC,IAAD;AAAA,UACE,qBAAqB,EAAK,OAAO;AAAA,UACjC,gBAAgB,EAAK,OAAO;AAAA,UAC5B,QAAQ;AAAA,UACR,aAAa,EAAK,wBAAwB;AAAA,UAC1C,SAAS,EAAK;AAAA,UACd,UAAU,EAAK;AAAA,UACf,kBAAkB,EAAK,wBAAwB;AAAA,UAC/C,SAAS,EAAK,OAAO;AAAA,UACrB,aAAa,EAAK,OAAO;AAAA,UACzB,eAAe,EAAK,OAAO;AAAA,UAC3B,OAAO,EAAK,OAAO;AAAA,QACpB,CAAA;AAAA,QAGF,EAAK,cAAc,aAAa,EAAiB,UAChD,gBAAA,EAAC,IAAD,EAAQ,QAAQ,EAAiB,OAAS,CAAA;AAAA,MAEvC;AAAA;EACY,CAAA;AAEzB,CACF"}
|
|
@@ -4,4 +4,4 @@ export { ctaPostMessages, resolveCtaMetadata, type CtaPostMessageResolver } from
|
|
|
4
4
|
export { HOST_ACTIONS, type HostActionName } from './hostActions';
|
|
5
5
|
export { beatContextOf, reportCtaClick, resolveCtaState, resolveStep, runCtaAction, runCtaHandler, sendCtaAnalytics, } from './runCtaAction';
|
|
6
6
|
export { useBeatCtaActions, useCtaHandler, type BeatCtaActions } from './useCtaAction';
|
|
7
|
-
export type { CtaContext, CtaEffect, CtaHandler, CtaHandlerContext, CtaParams, CtaSlot, CtaState, CtaStateContext, CtaStep, RunHandlerOptions, } from './types';
|
|
7
|
+
export type { CtaContext, CtaEffect, CtaHandler, CtaHandlerContext, CtaParams, CtaPresentation, CtaSlot, CtaState, CtaStateContext, CtaStep, RunHandlerOptions, } from './types';
|
|
@@ -5,7 +5,7 @@ import { CtaContext, CtaHandlerContext, CtaState, CtaStateContext, CtaStep, RunH
|
|
|
5
5
|
export declare const beatContextOf: ({ beat, stores }: Pick<CtaStateContext, "beat" | "stores">) => Record<string, unknown>;
|
|
6
6
|
/** The step named by the CTA's `action_key`, or the empty default (no key / unknown key). */
|
|
7
7
|
export declare const resolveStep: ({ cta }: Pick<CtaStateContext, "cta">) => CtaStep;
|
|
8
|
-
/** Pending always disables
|
|
8
|
+
/** Pending always disables, as may the step's `disabledWhen`; its `presenter` may replace the button. */
|
|
9
9
|
export declare const resolveCtaState: (ctx: CtaStateContext) => CtaState;
|
|
10
10
|
type AnalyticsCtx = Pick<CtaContext, 'beat' | 'stores' | 'hostActions'>;
|
|
11
11
|
/**
|
|
@@ -7,11 +7,14 @@ import { ctaHandlers as A } from "./ctaHandlers.es.js";
|
|
|
7
7
|
import { resolveCtaMetadata as E } from "./ctaPostMessages.es.js";
|
|
8
8
|
import { hasDrawerBlock as S } from "../mappings/hasDrawerBlock.es.js";
|
|
9
9
|
var y = {}, c = ({ cta: t }) => t.action_key && _[t.action_key] || y, B = (t) => {
|
|
10
|
-
const a = c(t);
|
|
11
|
-
return {
|
|
10
|
+
const a = c(t), r = t.stores.insightsV2Store.ctaStatus[t.beat.guid] === "pending", e = a.presenter?.(t);
|
|
11
|
+
return {
|
|
12
|
+
disabled: r || (a.disabledWhen?.(t) ?? !1),
|
|
13
|
+
...e && { presentation: e }
|
|
14
|
+
};
|
|
12
15
|
}, l = ({ beat: t, slot: a, stores: r }) => {
|
|
13
16
|
r.insightsV2Store.openCtaDrawer(t.guid, a === "primary" ? "primaryCta" : "secondaryCta");
|
|
14
|
-
},
|
|
17
|
+
}, g = ({ beat: t, stores: a }, r) => {
|
|
15
18
|
const { is_mobile_webview: e, clientConfig: s } = a.appDataStore.appConfig, { event: i, action: u, payload: C } = r;
|
|
16
19
|
m(t, {
|
|
17
20
|
event: i ?? void 0,
|
|
@@ -21,7 +24,7 @@ var y = {}, c = ({ cta: t }) => t.action_key && _[t.action_key] || y, B = (t) =>
|
|
|
21
24
|
webviewScheme: s?.master?.ui_message_webview_url_scheme,
|
|
22
25
|
userGuid: t.insights_payload?.user_guid ?? t.user_guid
|
|
23
26
|
});
|
|
24
|
-
},
|
|
27
|
+
}, h = (t) => {
|
|
25
28
|
S(t.cta.block) && l(t);
|
|
26
29
|
}, w = (t, { beat: a, stores: r }) => {
|
|
27
30
|
t === "refreshBeat" && r.emitUpdate({ staleBeatGuid: a.guid });
|
|
@@ -75,9 +78,9 @@ var y = {}, c = ({ cta: t }) => t.action_key && _[t.action_key] || y, B = (t) =>
|
|
|
75
78
|
T(e, { skipCtaClicked: a.skipCtaClicked }), await d(e, async () => {
|
|
76
79
|
a.run && await p(e, a.run, a.onSuccess ?? []), a.analytics && o(e, a.analytics);
|
|
77
80
|
const s = E(e);
|
|
78
|
-
s &&
|
|
81
|
+
s && g(e, s);
|
|
79
82
|
const i = a.next ?? (a.run ? "none" : "default");
|
|
80
|
-
i === "default" ?
|
|
83
|
+
i === "default" ? h(e) : i === "drawer" && l(e);
|
|
81
84
|
});
|
|
82
85
|
}, b = {
|
|
83
86
|
label: "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runCtaAction.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/runCtaAction.ts"],"sourcesContent":["import { sendBeatCta } from '../../common/utils/PostMessage'\nimport {\n ANALYTICS_EVENTS_CONFIG,\n type AnalyticsEventConfigEntry,\n} from '../analytics/analyticsEventsConfig'\nimport { resolveAnalyticsEvent } from '../analytics/resolveAnalyticsEvent'\nimport { hasDrawerBlock } from '../mappings/hasDrawerBlock'\nimport { ctaActions } from './ctaConfig'\nimport { resolveCtaMetadata } from './ctaPostMessages'\nimport { ctaHandlers, type CtaHandlerName } from './ctaHandlers'\nimport { HOST_ACTIONS } from './hostActions'\nimport type { CtaPostMessageMetadata } from '../../core'\nimport type {\n CtaContext,\n CtaEffect,\n CtaHandler,\n CtaHandlerContext,\n CtaState,\n CtaStateContext,\n CtaStep,\n RunHandlerOptions,\n} from './types'\n\nconst DEFAULT_STEP: CtaStep = {}\n\n// ─── Resolution ─────────────────────────────────────────────────────────────\n\n/** The beat's own context (input a block collected for it), `{}` until something is written. */\nexport const beatContextOf = ({ beat, stores }: Pick<CtaStateContext, 'beat' | 'stores'>) =>\n stores.insightsV2Store.beatContext[beat.guid] ?? {}\n\n/** The step named by the CTA's `action_key`, or the empty default (no key / unknown key). */\nexport const resolveStep = ({ cta }: Pick<CtaStateContext, 'cta'>): CtaStep =>\n (cta.action_key && ctaActions[cta.action_key]) || DEFAULT_STEP\n\n/** Pending always disables; the step's `disabledWhen` may add to that. */\nexport const resolveCtaState = (ctx: CtaStateContext): CtaState => {\n const step = resolveStep(ctx)\n const pending = ctx.stores.insightsV2Store.ctaStatus[ctx.beat.guid] === 'pending'\n\n return { disabled: pending || (step.disabledWhen?.(ctx) ?? false) }\n}\n\n// ─── Targets and effects ────────────────────────────────────────────────────\n\n/** Opens the beat's drawer for whichever slot triggered the current step. */\nconst openDrawerForSlot = ({\n beat,\n slot,\n stores,\n}: Pick<CtaContext, 'beat' | 'slot' | 'stores'>) => {\n stores.insightsV2Store.openCtaDrawer(\n beat.guid,\n slot === 'primary' ? 'primaryCta' : 'secondaryCta',\n )\n}\n\n/**\n * Posts this CTA's resolved message (event, op and beat-specific payload, from the backend's\n * `cta.metadata` or the template's `ctaPostMessages` entry) to the host.\n */\nconst postCtaMessage = ({ beat, stores }: CtaContext, metadata: CtaPostMessageMetadata) => {\n const { is_mobile_webview, clientConfig } = stores.appDataStore.appConfig\n const { event, action, payload } = metadata\n\n sendBeatCta(beat, {\n event: event ?? undefined,\n op: action ?? undefined,\n extras: payload ?? undefined,\n isMobileWebview: is_mobile_webview,\n webviewScheme: clientConfig?.master?.ui_message_webview_url_scheme,\n userGuid: beat.insights_payload?.user_guid ?? beat.user_guid,\n })\n}\n\n/**\n * Default target: open the drawer for a real block, otherwise nothing. A post message is never\n * implied by a missing block; it is sent only when one resolves (see runCtaAction).\n */\nconst runDefaultTarget = (ctx: CtaContext) => {\n if (hasDrawerBlock(ctx.cta.block)) openDrawerForSlot(ctx)\n}\n\nconst runEffect = (effect: CtaEffect, { beat, stores }: CtaContext) => {\n switch (effect) {\n case 'refreshBeat':\n stores.emitUpdate({ staleBeatGuid: beat.guid })\n break\n }\n}\n\ntype AnalyticsCtx = Pick<CtaContext, 'beat' | 'stores' | 'hostActions'>\n\n/**\n * The one way to fire a catalogued analytics event. Takes the catalogue entry itself (e.g.\n * `ANALYTICS_EVENTS_CONFIG.PRIMARY_ACTION_SELECTED`), not a lookup key — the call site already\n * has the entry via property access, so there is no key to look up or mistype. Resolves the\n * payload and hands it to the host directly. Never throws: a failed fire is captured, it\n * cannot fail or disable anything.\n */\nexport const sendCtaAnalytics = (ctx: AnalyticsCtx, event: AnalyticsEventConfigEntry): void => {\n try {\n ctx.hostActions.onAnalyticsEvent?.(resolveAnalyticsEvent(event, ctx.beat))\n } catch (error) {\n ctx.stores.captureException(error, {\n store: 'ctaActions',\n template: ctx.beat.template,\n handler: 'sendCtaAnalytics',\n })\n }\n}\n\n// First primary click: fires FIRST_TIME_PRIMARY_ACTION_SELECTED and records cta_clicked_at.\nconst markCtaClicked = (ctx: AnalyticsCtx & Pick<CtaContext, 'slot'>): void => {\n const { beat, slot, hostActions, stores } = ctx\n\n if (slot !== 'primary' || beat.cta_clicked_at) return\n\n sendCtaAnalytics(ctx, ANALYTICS_EVENTS_CONFIG.FIRST_TIME_PRIMARY_ACTION_SELECTED)\n\n // Fire-and-forget; a failed write must not fail the user's action, but still report it.\n Promise.resolve()\n .then(() =>\n hostActions.onCtaAction?.({ beatGuid: beat.guid, name: HOST_ACTIONS.markCtaClicked }),\n )\n .catch((error) =>\n stores.captureException(error, {\n store: 'ctaActions',\n template: beat.template,\n handler: 'markCtaClicked',\n }),\n )\n}\n\n/**\n * Trigger 1 + the first-click bookkeeping together: every CTA press's generic analytics\n * (`Primary/Secondary Action Selected`), plus `FIRST_TIME_PRIMARY_ACTION_SELECTED` /\n * `cta_clicked_at` on the first primary press. The one call site for \"a CTA got pressed\",\n * used by the runner and by the contact-support bypass in `BaseLayout`.\n */\nexport const reportCtaClick = (\n ctx: AnalyticsCtx & Pick<CtaContext, 'slot'>,\n { skipCtaClicked = false }: { skipCtaClicked?: boolean } = {},\n): void => {\n sendCtaAnalytics(\n ctx,\n ctx.slot === 'primary'\n ? ANALYTICS_EVENTS_CONFIG.PRIMARY_ACTION_SELECTED\n : ANALYTICS_EVENTS_CONFIG.SECONDARY_ACTION_SELECTED,\n )\n\n if (!skipCtaClicked) markCtaClicked(ctx)\n}\n\n// ─── Shared bookkeeping ─────────────────────────────────────────────────────\n\n/** Runs a named handler, then its `onSuccess` effects. Shared by card CTAs and drawer saves. */\nconst runHandlerWithEffects = async (\n ctx: CtaContext,\n handlerName: CtaHandlerName,\n onSuccess: CtaEffect[],\n): Promise<void> => {\n // Names are typed, but the map is still indexed defensively: config can come from anywhere.\n const handler = (ctaHandlers as Record<string, CtaHandler>)[handlerName]\n\n if (!handler) throw new Error(`Unknown CTA handler \"${handlerName}\"`)\n\n await handler(ctx)\n\n for (const effect of onSuccess) runEffect(effect, ctx)\n}\n\n/** Per-beat status around `work`: `pending` -> `done` | `error` (+ captureException). */\nconst withCtaStatus = async (\n { beat, stores }: Pick<CtaContext, 'beat' | 'stores'>,\n work: () => Promise<void>,\n captureContext: Record<string, string> = {},\n): Promise<boolean> => {\n const { insightsV2Store } = stores\n\n insightsV2Store.setCtaStatus(beat.guid, 'pending')\n\n try {\n await work()\n insightsV2Store.setCtaStatus(beat.guid, 'done')\n\n return true\n } catch (error) {\n insightsV2Store.setCtaStatus(beat.guid, 'error')\n stores.captureException(error, {\n store: 'ctaActions',\n template: beat.template,\n ...captureContext,\n })\n\n return false\n }\n}\n\n// ─── Entry points ───────────────────────────────────────────────────────────\n\n// Runs the CTA's step: handler, onSuccess effects, post message, then the next target.\nexport const runCtaAction = async (ctx: CtaContext): Promise<void> => {\n const step = resolveStep(ctx)\n const stepParams = typeof step.params === 'function' ? step.params(ctx) : step.params\n const stepCtx: CtaContext = { ...ctx, params: { ...stepParams, ...ctx.params } }\n\n reportCtaClick(stepCtx, { skipCtaClicked: step.skipCtaClicked })\n\n await withCtaStatus(stepCtx, async () => {\n if (step.run) await runHandlerWithEffects(stepCtx, step.run, step.onSuccess ?? [])\n\n // A step's own event, e.g. select_savings_account (Saved) / open_savings_account (Created).\n if (step.analytics) sendCtaAnalytics(stepCtx, step.analytics)\n\n const metadata = resolveCtaMetadata(stepCtx)\n\n if (metadata) postCtaMessage(stepCtx, metadata)\n\n const target = step.next ?? (step.run ? 'none' : 'default')\n\n if (target === 'default') runDefaultTarget(stepCtx)\n else if (target === 'drawer') openDrawerForSlot(stepCtx)\n })\n}\n\n/** Placeholder CTA for handlers run from inside a drawer, where no card slot is involved. */\nconst DIRECT_CTA = { label: '', block: '' }\n\n/** Runs a handler directly (drawer Save buttons). True on success. */\nexport const runCtaHandler = (\n ctx: CtaHandlerContext,\n handlerName: CtaHandlerName,\n { onSuccess = [], analytics }: RunHandlerOptions = {},\n): Promise<boolean> => {\n const fullCtx: CtaContext = { ...ctx, cta: DIRECT_CTA, slot: 'primary' }\n\n return withCtaStatus(\n fullCtx,\n async () => {\n await runHandlerWithEffects(fullCtx, handlerName, onSuccess)\n\n // Success-time analytics for drawer Saves.\n if (analytics) sendCtaAnalytics(fullCtx, analytics)\n },\n { handler: handlerName },\n )\n}\n"],"mappings":";;;;;;;;AAuBA,IAAM,IAAwB,CAAC,GASlB,IAAA,CAAe,EAAE,KAAA,EAAA,MAC3B,EAAI,cAAc,EAAW,EAAI,UAAA,KAAgB,GAGvC,IAAA,CAAmB,MAAmC;AACjE,QAAM,IAAO,EAAY,CAAG;AAG5B,SAAO,EAAE,UAFO,EAAI,OAAO,gBAAgB,UAAU,EAAI,KAAK,IAAA,MAAU,cAEzC,EAAK,eAAe,CAAG,KAAK,IAAO;AACpE,GAKM,IAAA,CAAqB,EACzB,MAAA,GACA,MAAA,GACA,QAAA,EAAA,MACkD;AAClD,EAAA,EAAO,gBAAgB,cACrB,EAAK,MACL,MAAS,YAAY,eAAe,cACtC;AACF,GAMM,IAAA,CAAkB,EAAE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AS,EAAK,KAAK,EAAK,aAAa,CAAC,CAAC,GAG7E,EAAK,aAAW,EAAiB,GAAS,EAAK,SAAS;AAE5D,UAAM,IAAW,EAAmB,CAAO;AAE3C,IAAI,KAAU,EAAe,GAAS,CAAQ;AAE9C,UAAM,IAAS,EAAK,SAAS,EAAK,MAAM,SAAS;AAEjD,IAAI,MAAW,YAAW,EAAiB,CAAO,IACzC,MAAW,YAAU,EAAkB,CAAO;AAAA,EACzD,CAAC;AACH,GAGM,IAAa;AAAA,EAAE,OAAO;AAAA,EAAI,OAAO;AAAG,GAG7B,IAAA,CACX,GACA,GACA,EAAE,WAAA,IAAY,CAAC,GAAG,WAAA,EAAA,IAAiC,CAAC,MAC/B;AACrB,QAAM,IAAsB;AAAA,IAAE,GAAG;AAAA,IAAK,KAAK;AAAA,IAAY,MAAM;AAAA,EAAU;AAEvE,SAAO,EACL,GACA,YAAY;AACV,UAAM,EAAsB,GAAS,GAAa,CAAS,GAGvD,KAAW,EAAiB,GAAS,CAAS;AAAA,EACpD,GACA,EAAE,SAAS,EAAY,CACzB;AACF"}
|
|
1
|
+
{"version":3,"file":"runCtaAction.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/runCtaAction.ts"],"sourcesContent":["import { sendBeatCta } from '../../common/utils/PostMessage'\nimport {\n ANALYTICS_EVENTS_CONFIG,\n type AnalyticsEventConfigEntry,\n} from '../analytics/analyticsEventsConfig'\nimport { resolveAnalyticsEvent } from '../analytics/resolveAnalyticsEvent'\nimport { hasDrawerBlock } from '../mappings/hasDrawerBlock'\nimport { ctaActions } from './ctaConfig'\nimport { resolveCtaMetadata } from './ctaPostMessages'\nimport { ctaHandlers, type CtaHandlerName } from './ctaHandlers'\nimport { HOST_ACTIONS } from './hostActions'\nimport type { CtaPostMessageMetadata } from '../../core'\nimport type {\n CtaContext,\n CtaEffect,\n CtaHandler,\n CtaHandlerContext,\n CtaState,\n CtaStateContext,\n CtaStep,\n RunHandlerOptions,\n} from './types'\n\nconst DEFAULT_STEP: CtaStep = {}\n\n// ─── Resolution ─────────────────────────────────────────────────────────────\n\n/** The beat's own context (input a block collected for it), `{}` until something is written. */\nexport const beatContextOf = ({ beat, stores }: Pick<CtaStateContext, 'beat' | 'stores'>) =>\n stores.insightsV2Store.beatContext[beat.guid] ?? {}\n\n/** The step named by the CTA's `action_key`, or the empty default (no key / unknown key). */\nexport const resolveStep = ({ cta }: Pick<CtaStateContext, 'cta'>): CtaStep =>\n (cta.action_key && ctaActions[cta.action_key]) || DEFAULT_STEP\n\n/** Pending always disables, as may the step's `disabledWhen`; its `presenter` may replace the button. */\nexport const resolveCtaState = (ctx: CtaStateContext): CtaState => {\n const step = resolveStep(ctx)\n const pending = ctx.stores.insightsV2Store.ctaStatus[ctx.beat.guid] === 'pending'\n const presentation = step.presenter?.(ctx)\n\n return {\n disabled: pending || (step.disabledWhen?.(ctx) ?? false),\n ...(presentation && { presentation }),\n }\n}\n\n// ─── Targets and effects ────────────────────────────────────────────────────\n\n/** Opens the beat's drawer for whichever slot triggered the current step. */\nconst openDrawerForSlot = ({\n beat,\n slot,\n stores,\n}: Pick<CtaContext, 'beat' | 'slot' | 'stores'>) => {\n stores.insightsV2Store.openCtaDrawer(\n beat.guid,\n slot === 'primary' ? 'primaryCta' : 'secondaryCta',\n )\n}\n\n/**\n * Posts this CTA's resolved message (event, op and beat-specific payload, from the backend's\n * `cta.metadata` or the template's `ctaPostMessages` entry) to the host.\n */\nconst postCtaMessage = ({ beat, stores }: CtaContext, metadata: CtaPostMessageMetadata) => {\n const { is_mobile_webview, clientConfig } = stores.appDataStore.appConfig\n const { event, action, payload } = metadata\n\n sendBeatCta(beat, {\n event: event ?? undefined,\n op: action ?? undefined,\n extras: payload ?? undefined,\n isMobileWebview: is_mobile_webview,\n webviewScheme: clientConfig?.master?.ui_message_webview_url_scheme,\n userGuid: beat.insights_payload?.user_guid ?? beat.user_guid,\n })\n}\n\n/**\n * Default target: open the drawer for a real block, otherwise nothing. A post message is never\n * implied by a missing block; it is sent only when one resolves (see runCtaAction).\n */\nconst runDefaultTarget = (ctx: CtaContext) => {\n if (hasDrawerBlock(ctx.cta.block)) openDrawerForSlot(ctx)\n}\n\nconst runEffect = (effect: CtaEffect, { beat, stores }: CtaContext) => {\n switch (effect) {\n case 'refreshBeat':\n stores.emitUpdate({ staleBeatGuid: beat.guid })\n break\n }\n}\n\ntype AnalyticsCtx = Pick<CtaContext, 'beat' | 'stores' | 'hostActions'>\n\n/**\n * The one way to fire a catalogued analytics event. Takes the catalogue entry itself (e.g.\n * `ANALYTICS_EVENTS_CONFIG.PRIMARY_ACTION_SELECTED`), not a lookup key — the call site already\n * has the entry via property access, so there is no key to look up or mistype. Resolves the\n * payload and hands it to the host directly. Never throws: a failed fire is captured, it\n * cannot fail or disable anything.\n */\nexport const sendCtaAnalytics = (ctx: AnalyticsCtx, event: AnalyticsEventConfigEntry): void => {\n try {\n ctx.hostActions.onAnalyticsEvent?.(resolveAnalyticsEvent(event, ctx.beat))\n } catch (error) {\n ctx.stores.captureException(error, {\n store: 'ctaActions',\n template: ctx.beat.template,\n handler: 'sendCtaAnalytics',\n })\n }\n}\n\n// First primary click: fires FIRST_TIME_PRIMARY_ACTION_SELECTED and records cta_clicked_at.\nconst markCtaClicked = (ctx: AnalyticsCtx & Pick<CtaContext, 'slot'>): void => {\n const { beat, slot, hostActions, stores } = ctx\n\n if (slot !== 'primary' || beat.cta_clicked_at) return\n\n sendCtaAnalytics(ctx, ANALYTICS_EVENTS_CONFIG.FIRST_TIME_PRIMARY_ACTION_SELECTED)\n\n // Fire-and-forget; a failed write must not fail the user's action, but still report it.\n Promise.resolve()\n .then(() =>\n hostActions.onCtaAction?.({ beatGuid: beat.guid, name: HOST_ACTIONS.markCtaClicked }),\n )\n .catch((error) =>\n stores.captureException(error, {\n store: 'ctaActions',\n template: beat.template,\n handler: 'markCtaClicked',\n }),\n )\n}\n\n/**\n * Trigger 1 + the first-click bookkeeping together: every CTA press's generic analytics\n * (`Primary/Secondary Action Selected`), plus `FIRST_TIME_PRIMARY_ACTION_SELECTED` /\n * `cta_clicked_at` on the first primary press. The one call site for \"a CTA got pressed\",\n * used by the runner and by the contact-support bypass in `BaseLayout`.\n */\nexport const reportCtaClick = (\n ctx: AnalyticsCtx & Pick<CtaContext, 'slot'>,\n { skipCtaClicked = false }: { skipCtaClicked?: boolean } = {},\n): void => {\n sendCtaAnalytics(\n ctx,\n ctx.slot === 'primary'\n ? ANALYTICS_EVENTS_CONFIG.PRIMARY_ACTION_SELECTED\n : ANALYTICS_EVENTS_CONFIG.SECONDARY_ACTION_SELECTED,\n )\n\n if (!skipCtaClicked) markCtaClicked(ctx)\n}\n\n// ─── Shared bookkeeping ─────────────────────────────────────────────────────\n\n/** Runs a named handler, then its `onSuccess` effects. Shared by card CTAs and drawer saves. */\nconst runHandlerWithEffects = async (\n ctx: CtaContext,\n handlerName: CtaHandlerName,\n onSuccess: CtaEffect[],\n): Promise<void> => {\n // Names are typed, but the map is still indexed defensively: config can come from anywhere.\n const handler = (ctaHandlers as Record<string, CtaHandler>)[handlerName]\n\n if (!handler) throw new Error(`Unknown CTA handler \"${handlerName}\"`)\n\n await handler(ctx)\n\n for (const effect of onSuccess) runEffect(effect, ctx)\n}\n\n/** Per-beat status around `work`: `pending` -> `done` | `error` (+ captureException). */\nconst withCtaStatus = async (\n { beat, stores }: Pick<CtaContext, 'beat' | 'stores'>,\n work: () => Promise<void>,\n captureContext: Record<string, string> = {},\n): Promise<boolean> => {\n const { insightsV2Store } = stores\n\n insightsV2Store.setCtaStatus(beat.guid, 'pending')\n\n try {\n await work()\n insightsV2Store.setCtaStatus(beat.guid, 'done')\n\n return true\n } catch (error) {\n insightsV2Store.setCtaStatus(beat.guid, 'error')\n stores.captureException(error, {\n store: 'ctaActions',\n template: beat.template,\n ...captureContext,\n })\n\n return false\n }\n}\n\n// ─── Entry points ───────────────────────────────────────────────────────────\n\n// Runs the CTA's step: handler, onSuccess effects, post message, then the next target.\nexport const runCtaAction = async (ctx: CtaContext): Promise<void> => {\n const step = resolveStep(ctx)\n const stepParams = typeof step.params === 'function' ? step.params(ctx) : step.params\n const stepCtx: CtaContext = { ...ctx, params: { ...stepParams, ...ctx.params } }\n\n reportCtaClick(stepCtx, { skipCtaClicked: step.skipCtaClicked })\n\n await withCtaStatus(stepCtx, async () => {\n if (step.run) await runHandlerWithEffects(stepCtx, step.run, step.onSuccess ?? [])\n\n // A step's own event, e.g. select_savings_account (Saved) / open_savings_account (Created).\n if (step.analytics) sendCtaAnalytics(stepCtx, step.analytics)\n\n const metadata = resolveCtaMetadata(stepCtx)\n\n if (metadata) postCtaMessage(stepCtx, metadata)\n\n const target = step.next ?? (step.run ? 'none' : 'default')\n\n if (target === 'default') runDefaultTarget(stepCtx)\n else if (target === 'drawer') openDrawerForSlot(stepCtx)\n })\n}\n\n/** Placeholder CTA for handlers run from inside a drawer, where no card slot is involved. */\nconst DIRECT_CTA = { label: '', block: '' }\n\n/** Runs a handler directly (drawer Save buttons). True on success. */\nexport const runCtaHandler = (\n ctx: CtaHandlerContext,\n handlerName: CtaHandlerName,\n { onSuccess = [], analytics }: RunHandlerOptions = {},\n): Promise<boolean> => {\n const fullCtx: CtaContext = { ...ctx, cta: DIRECT_CTA, slot: 'primary' }\n\n return withCtaStatus(\n fullCtx,\n async () => {\n await runHandlerWithEffects(fullCtx, handlerName, onSuccess)\n\n // Success-time analytics for drawer Saves.\n if (analytics) sendCtaAnalytics(fullCtx, analytics)\n },\n { handler: handlerName },\n )\n}\n"],"mappings":";;;;;;;;AAuBA,IAAM,IAAwB,CAAC,GASlB,IAAA,CAAe,EAAE,KAAA,EAAA,MAC3B,EAAI,cAAc,EAAW,EAAI,UAAA,KAAgB,GAGvC,IAAA,CAAmB,MAAmC;AACjE,QAAM,IAAO,EAAY,CAAG,GACtB,IAAU,EAAI,OAAO,gBAAgB,UAAU,EAAI,KAAK,IAAA,MAAU,WAClE,IAAe,EAAK,YAAY,CAAG;AAEzC,SAAO;AAAA,IACL,UAAU,MA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AK,QACzE,IAAsB;AAAA,IAAE,GAAG;AAAA,IAAK,QAAQ;AAAA,MAAE,GAAG;AAAA,MAAY,GAAG,EAAI;AAAA,IAAO;AAAA,EAAE;AAE/E,EAAA,EAAe,GAAS,EAAE,gBAAgB,EAAK,eAAe,CAAC,GAE/D,MAAM,EAAc,GAAS,YAAY;AACvC,IAAI,EAAK,OAAK,MAAM,EAAsB,GAAS,EAAK,KAAK,EAAK,aAAa,CAAC,CAAC,GAG7E,EAAK,aAAW,EAAiB,GAAS,EAAK,SAAS;AAE5D,UAAM,IAAW,EAAmB,CAAO;AAE3C,IAAI,KAAU,EAAe,GAAS,CAAQ;AAE9C,UAAM,IAAS,EAAK,SAAS,EAAK,MAAM,SAAS;AAEjD,IAAI,MAAW,YAAW,EAAiB,CAAO,IACzC,MAAW,YAAU,EAAkB,CAAO;AAAA,EACzD,CAAC;AACH,GAGM,IAAa;AAAA,EAAE,OAAO;AAAA,EAAI,OAAO;AAAG,GAG7B,IAAA,CACX,GACA,GACA,EAAE,WAAA,IAAY,CAAC,GAAG,WAAA,EAAA,IAAiC,CAAC,MAC/B;AACrB,QAAM,IAAsB;AAAA,IAAE,GAAG;AAAA,IAAK,KAAK;AAAA,IAAY,MAAM;AAAA,EAAU;AAEvE,SAAO,EACL,GACA,YAAY;AACV,UAAM,EAAsB,GAAS,GAAa,CAAS,GAGvD,KAAW,EAAiB,GAAS,CAAS;AAAA,EACpD,GACA,EAAE,SAAS,EAAY,CACzB;AACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { InsightsFeedCopy } from '../../core/types/localization/InsightsFeedCopy';
|
|
2
|
+
import { RepeatingTransaction } from '../../core/types/RepeatingTransaction';
|
|
3
|
+
import { BeatActions } from '../beatActions';
|
|
4
|
+
import { CtaStateContext, CtaStep } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* The shared subscription status CTA. The answer lives on the repeating transaction
|
|
7
|
+
* (`user_response`), read at render time; the words are general copy, as pulse's were. Imports
|
|
8
|
+
* nothing from runCtaAction, so ctaConfig can build entries at load time.
|
|
9
|
+
*/
|
|
10
|
+
/** firefly's `user_response` names (Atlas::Sherlock::RepeatingTransaction::UserResponse). */
|
|
11
|
+
export declare const USER_RESPONSE: {
|
|
12
|
+
readonly UNKNOWN: "USER_RESPONSE_UNKNOWN";
|
|
13
|
+
readonly CONFIRMED: "CONFIRMED";
|
|
14
|
+
readonly CANCELLED: "CANCELLED";
|
|
15
|
+
readonly NEVER_SUBSCRIBED: "NEVER_SUBSCRIBED";
|
|
16
|
+
readonly WRONG_FREQUENCY: "WRONG_FREQUENCY";
|
|
17
|
+
readonly ONE_TIME_PURCHASE: "ONE_TIME_PURCHASE";
|
|
18
|
+
readonly OTHER: "OTHER";
|
|
19
|
+
};
|
|
20
|
+
type StateCtx = Pick<CtaStateContext, 'beat' | 'stores'>;
|
|
21
|
+
type WriteCtx = StateCtx & {
|
|
22
|
+
hostActions?: BeatActions;
|
|
23
|
+
};
|
|
24
|
+
/** A key of `insights_feed.general` naming a status word, e.g. `confirmed`. */
|
|
25
|
+
type GeneralCopyKey = keyof InsightsFeedCopy['general'];
|
|
26
|
+
/** The beat's repeating transaction, or undefined until loaded / when absent. */
|
|
27
|
+
export declare const repeatingTransactionOf: ({ beat, stores, }: StateCtx) => RepeatingTransaction | undefined;
|
|
28
|
+
/** Reports the answer (as pulse), then saves it; rejects on failure so a survey can offer Try Again. */
|
|
29
|
+
export declare const answerSubscription: (ctx: WriteCtx, userResponse: string) => Promise<void>;
|
|
30
|
+
/** The "No" press, before a reason is picked (pulse's DATA_IS_INCORRECT). */
|
|
31
|
+
export declare const reportSubscriptionMarkedIncorrect: (ctx: WriteCtx) => void;
|
|
32
|
+
export interface SubscriptionEntryOptions {
|
|
33
|
+
/** The `insights_feed.general` words for a positive (`CONFIRMED`) and any other answer. */
|
|
34
|
+
statusLabels: {
|
|
35
|
+
positive: GeneralCopyKey;
|
|
36
|
+
negative: GeneralCopyKey;
|
|
37
|
+
};
|
|
38
|
+
/** Whether the stored answer applies to this beat (default: every answer counts). */
|
|
39
|
+
answerCounts?: (ctx: CtaStateContext, repeating: RepeatingTransaction) => boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The step a beat's `action_key` names: the button until answered, then the status with Undo. No
|
|
43
|
+
* repeating transaction or transaction: no CTAs, as pulse. A missing word draws nothing.
|
|
44
|
+
*/
|
|
45
|
+
export declare const subscriptionEntryStep: ({ statusLabels, answerCounts, }: SubscriptionEntryOptions) => CtaStep;
|
|
46
|
+
export {};
|
|
@@ -2,14 +2,24 @@ import { Beat, PrimaryCTA, SecondaryCTA } from '../../core';
|
|
|
2
2
|
import { GlobalStore } from '../../core/stores/GlobalStore';
|
|
3
3
|
import { AnalyticsEventConfigEntry } from '../analytics/analyticsEventsConfig';
|
|
4
4
|
import { BeatActions } from '../beatActions';
|
|
5
|
+
import { CtaStatusProps } from '../components/CtaStatus';
|
|
5
6
|
import { CtaHandlerName } from './ctaHandlers';
|
|
6
7
|
export type CtaSlot = 'primary' | 'secondary';
|
|
7
8
|
/** Handler inputs: control values at the top level, the write set under `fields`. */
|
|
8
9
|
export type CtaParams = Record<string, unknown>;
|
|
9
|
-
/** Read-only view for state predicates evaluated during render. */
|
|
10
|
-
export type CtaStateContext = Pick<CtaContext, 'beat' | 'cta' | 'slot' | 'stores'
|
|
10
|
+
/** Read-only view for state predicates evaluated during render (`hostActions` for a status's analytics). */
|
|
11
|
+
export type CtaStateContext = Pick<CtaContext, 'beat' | 'cta' | 'slot' | 'stores'> & Partial<Pick<CtaContext, 'hostActions'>>;
|
|
12
|
+
/** What a presenter draws instead of the button: a status, or nothing (`hideAll` also hides the secondary). */
|
|
13
|
+
export type CtaPresentation = {
|
|
14
|
+
kind: 'hidden';
|
|
15
|
+
hideAll?: boolean;
|
|
16
|
+
} | ({
|
|
17
|
+
kind: 'status';
|
|
18
|
+
} & CtaStatusProps);
|
|
11
19
|
export interface CtaState {
|
|
12
20
|
disabled: boolean;
|
|
21
|
+
/** Set when the step's presenter replaces the button. */
|
|
22
|
+
presentation?: CtaPresentation;
|
|
13
23
|
}
|
|
14
24
|
/** Everything a step guard or handler can read while running. */
|
|
15
25
|
export interface CtaContext {
|
|
@@ -45,6 +55,10 @@ export interface CtaStep {
|
|
|
45
55
|
* data-derived rules belong to the backend, which omits the label instead.
|
|
46
56
|
*/
|
|
47
57
|
disabledWhen?: (ctx: CtaStateContext) => boolean;
|
|
58
|
+
/** Draw a status or nothing instead of the button; undefined = the button. */
|
|
59
|
+
presenter?: (ctx: CtaStateContext) => CtaPresentation | undefined;
|
|
60
|
+
/** Loads what `presenter` reads, once per beat on mount. */
|
|
61
|
+
prepare?: (ctx: Pick<CtaStateContext, 'beat' | 'stores'>) => void;
|
|
48
62
|
}
|
|
49
63
|
/** Context for a handler run directly from a drawer (no card CTA / slot involved). */
|
|
50
64
|
export type CtaHandlerContext = Omit<CtaContext, 'cta' | 'slot'>;
|
|
@@ -1,44 +1,56 @@
|
|
|
1
|
-
import { useGlobalStore as
|
|
2
|
-
import { resolveCtaState as
|
|
3
|
-
|
|
1
|
+
import { useGlobalStore as p } from "../../common/context/hooks.es.js";
|
|
2
|
+
import { resolveCtaState as c, resolveStep as C, runCtaAction as d, runCtaHandler as f } from "./runCtaAction.es.js";
|
|
3
|
+
import { useEffect as v } from "react";
|
|
4
|
+
var l = {
|
|
4
5
|
label: "",
|
|
5
6
|
block: ""
|
|
6
|
-
},
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
}, S = (t, o = {}, s = l, a = l) => {
|
|
8
|
+
const r = p(), e = C({ cta: s }).prepare, n = {
|
|
9
|
+
beat: t,
|
|
10
|
+
stores: r,
|
|
11
|
+
hostActions: o
|
|
12
|
+
};
|
|
13
|
+
return v(() => {
|
|
14
|
+
e?.({
|
|
15
|
+
beat: t,
|
|
16
|
+
stores: r
|
|
17
|
+
});
|
|
18
|
+
}, [
|
|
19
|
+
t.guid,
|
|
20
|
+
e,
|
|
21
|
+
r
|
|
22
|
+
]), {
|
|
23
|
+
runCta: (u, i, m = {}) => d({
|
|
24
|
+
beat: t,
|
|
11
25
|
cta: i,
|
|
12
|
-
slot:
|
|
13
|
-
stores:
|
|
26
|
+
slot: u,
|
|
27
|
+
stores: r,
|
|
14
28
|
hostActions: o,
|
|
15
|
-
params:
|
|
16
|
-
}),
|
|
17
|
-
primary: n({
|
|
18
|
-
beat: r,
|
|
19
|
-
cta: a,
|
|
20
|
-
slot: "primary",
|
|
21
|
-
stores: t
|
|
29
|
+
params: m
|
|
22
30
|
}),
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
primary: c({
|
|
32
|
+
...n,
|
|
25
33
|
cta: s,
|
|
26
|
-
slot: "
|
|
27
|
-
|
|
34
|
+
slot: "primary"
|
|
35
|
+
}),
|
|
36
|
+
secondary: c({
|
|
37
|
+
...n,
|
|
38
|
+
cta: a,
|
|
39
|
+
slot: "secondary"
|
|
28
40
|
})
|
|
29
41
|
};
|
|
30
|
-
},
|
|
31
|
-
const
|
|
32
|
-
return (
|
|
33
|
-
beat:
|
|
34
|
-
stores:
|
|
42
|
+
}, x = (t, o = {}) => {
|
|
43
|
+
const s = p();
|
|
44
|
+
return (a, r = {}, e) => f({
|
|
45
|
+
beat: t,
|
|
46
|
+
stores: s,
|
|
35
47
|
hostActions: o,
|
|
36
|
-
params:
|
|
37
|
-
},
|
|
48
|
+
params: r
|
|
49
|
+
}, a, e);
|
|
38
50
|
};
|
|
39
51
|
export {
|
|
40
|
-
|
|
41
|
-
|
|
52
|
+
S as useBeatCtaActions,
|
|
53
|
+
x as useCtaHandler
|
|
42
54
|
};
|
|
43
55
|
|
|
44
56
|
//# sourceMappingURL=useCtaAction.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCtaAction.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/useCtaAction.ts"],"sourcesContent":["import type { Beat, PrimaryCTA, SecondaryCTA } from '../../core'\nimport { useGlobalStore } from '../../common'\nimport type { BeatActions } from '../beatActions'\nimport type { CtaHandlerName } from './ctaHandlers'\nimport { resolveCtaState, runCtaAction, runCtaHandler } from './runCtaAction'\nimport type { CtaSlot, CtaState, RunHandlerOptions } from './types'\n\nconst EMPTY_CTA: PrimaryCTA = { label: '', block: '' }\n\nexport interface BeatCtaActions {\n runCta: (\n slot: CtaSlot,\n cta: PrimaryCTA | SecondaryCTA,\n params?: Record<string, unknown>,\n ) => Promise<void>\n primary: CtaState\n secondary: CtaState\n}\n\n/**\n * The card's click runner plus per-slot enabled state. Call from an `observer` so `disabledWhen`\n * store reads re-render. `beatActions` is a parameter: BaseLayout mounts its provider below this.\n */\nexport const useBeatCtaActions = (\n beat: Beat,\n beatActions: BeatActions = {},\n primaryCta: PrimaryCTA | SecondaryCTA = EMPTY_CTA,\n secondaryCta: PrimaryCTA | SecondaryCTA = EMPTY_CTA,\n): BeatCtaActions => {\n const stores = useGlobalStore()\n\n return {\n runCta: (slot, cta, params = {}) =>\n runCtaAction({ beat, cta, slot, stores, hostActions: beatActions, params }),\n primary: resolveCtaState({
|
|
1
|
+
{"version":3,"file":"useCtaAction.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/useCtaAction.ts"],"sourcesContent":["import { useEffect } from 'react'\n\nimport type { Beat, PrimaryCTA, SecondaryCTA } from '../../core'\nimport { useGlobalStore } from '../../common'\nimport type { BeatActions } from '../beatActions'\nimport type { CtaHandlerName } from './ctaHandlers'\nimport { resolveCtaState, resolveStep, runCtaAction, runCtaHandler } from './runCtaAction'\nimport type { CtaSlot, CtaState, RunHandlerOptions } from './types'\n\nconst EMPTY_CTA: PrimaryCTA = { label: '', block: '' }\n\nexport interface BeatCtaActions {\n runCta: (\n slot: CtaSlot,\n cta: PrimaryCTA | SecondaryCTA,\n params?: Record<string, unknown>,\n ) => Promise<void>\n primary: CtaState\n secondary: CtaState\n}\n\n/**\n * The card's click runner plus per-slot enabled state. Call from an `observer` so `disabledWhen`\n * store reads re-render. `beatActions` is a parameter: BaseLayout mounts its provider below this.\n */\nexport const useBeatCtaActions = (\n beat: Beat,\n beatActions: BeatActions = {},\n primaryCta: PrimaryCTA | SecondaryCTA = EMPTY_CTA,\n secondaryCta: PrimaryCTA | SecondaryCTA = EMPTY_CTA,\n): BeatCtaActions => {\n const stores = useGlobalStore()\n const prepare = resolveStep({ cta: primaryCta }).prepare\n const stateCtx = { beat, stores, hostActions: beatActions }\n\n // Once per beat (beat.guid; the beat object can be new each render): load what the step reads.\n useEffect(() => {\n prepare?.({ beat, stores })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [beat.guid, prepare, stores])\n\n return {\n runCta: (slot, cta, params = {}) =>\n runCtaAction({ beat, cta, slot, stores, hostActions: beatActions, params }),\n primary: resolveCtaState({ ...stateCtx, cta: primaryCta, slot: 'primary' }),\n secondary: resolveCtaState({ ...stateCtx, cta: secondaryCta, slot: 'secondary' }),\n }\n}\n\n/**\n * Runs a handler from inside a drawer, e.g. `runHandler('createBudget', { categoryGuid, amount },\n * { onSuccess: ['refreshBeat'] })`. Inside a block, pass `useBeatActions()` as `beatActions`.\n */\nexport const useCtaHandler = (beat: Beat, beatActions: BeatActions = {}) => {\n const stores = useGlobalStore()\n\n return (\n handlerName: CtaHandlerName,\n params: Record<string, unknown> = {},\n options?: RunHandlerOptions,\n ) => runCtaHandler({ beat, stores, hostActions: beatActions, params }, handlerName, options)\n}\n"],"mappings":";;;AASA,IAAM,IAAwB;AAAA,EAAE,OAAO;AAAA,EAAI,OAAO;AAAG,GAgBxC,IAAA,CACX,GACA,IAA2B,CAAC,GAC5B,IAAwC,GACxC,IAA0C,MACvB;AACnB,QAAM,IAAS,EAAe,GACxB,IAAU,EAAY,EAAE,KAAK,EAAW,CAAC,EAAE,SAC3C,IAAW;AAAA,IAAE,MAAA;AAAA,IAAM,QAAA;AAAA,IAAQ,aAAa;AAAA,EAAY;AAG1D,SAAA,EAAA,MAAgB;AACd,IAAA,IAAU;AAAA,MAAE,MAAA;AAAA,MAAM,QAAA;AAAA,IAAO,CAAC;AAAA,EAE5B,GAAG;AAAA,IAAC,EAAK;AAAA,IAAM;AAAA,IAAS;AAAA,EAAM,CAAC,GAExB;AAAA,IACL,QAAA,CAAS,GAAM,GAAK,IAAS,CAAC,MAC5B,EAAa;AAAA,MAAE,MAAA;AAAA,MAAM,KAAA;AAAA,MAAK,MAAA;AAAA,MAAM,QAAA;AAAA,MAAQ,aAAa;AAAA,MAAa,QAAA;AAAA,IAAO,CAAC;AAAA,IAC5E,SAAS,EAAgB;AAAA,MAAE,GAAG;AAAA,MAAU,KAAK;AAAA,MAAY,MAAM;AAAA,IAAU,CAAC;AAAA,IAC1E,WAAW,EAAgB;AAAA,MAAE,GAAG;AAAA,MAAU,KAAK;AAAA,MAAc,MAAM;AAAA,IAAY,CAAC;AAAA,EAClF;AACF,GAMa,IAAA,CAAiB,GAAY,IAA2B,CAAC,MAAM;AAC1E,QAAM,IAAS,EAAe;AAE9B,SAAA,CACE,GACA,IAAkC,CAAC,GACnC,MACG,EAAc;AAAA,IAAE,MAAA;AAAA,IAAM,QAAA;AAAA,IAAQ,aAAa;AAAA,IAAa,QAAA;AAAA,EAAO,GAAG,GAAa,CAAO;AAC7F"}
|