@mx-cartographer/experiences 9.6.10 → 9.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/core/stores/FinstrongStore.d.ts +1 -0
- package/dist/core/stores/FinstrongStore.es.js +42 -38
- package/dist/core/stores/FinstrongStore.es.js.map +1 -1
- package/dist/core/stores/GoalStore.d.ts +1 -0
- package/dist/core/stores/GoalStore.es.js +104 -100
- package/dist/core/stores/GoalStore.es.js.map +1 -1
- package/dist/core/stores/HelpStore.d.ts +1 -0
- package/dist/core/stores/HelpStore.es.js +10 -6
- package/dist/core/stores/HelpStore.es.js.map +1 -1
- package/dist/core/stores/InsightsV2Store.d.ts +1 -1
- package/dist/core/stores/InsightsV2Store.es.js.map +1 -1
- package/dist/core/stores/NetWorthStore.d.ts +1 -0
- package/dist/core/stores/NetWorthStore.es.js +12 -8
- package/dist/core/stores/NetWorthStore.es.js.map +1 -1
- package/dist/core/stores/NotificationStore.d.ts +1 -0
- package/dist/core/stores/NotificationStore.es.js +11 -7
- package/dist/core/stores/NotificationStore.es.js.map +1 -1
- package/dist/core/stores/SettingsStore.d.ts +1 -0
- package/dist/core/stores/SettingsStore.es.js +23 -19
- package/dist/core/stores/SettingsStore.es.js.map +1 -1
- package/dist/core/stores/UserStore.d.ts +1 -0
- package/dist/core/stores/UserStore.es.js +10 -6
- package/dist/core/stores/UserStore.es.js.map +1 -1
- package/dist/core/types/Insights.d.ts +17 -0
- package/dist/core/types/Insights.es.js.map +1 -1
- package/dist/core/types/index.d.ts +1 -1
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js +21 -21
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +63 -61
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +2 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +59 -38
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/util.d.ts +2 -2
- package/dist/insights-v2/actionBlocks/util.es.js +3 -3
- package/dist/insights-v2/actionBlocks/util.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +57 -55
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/IconComponent.d.ts +4 -2
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/IconComponent.es.js +54 -23
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/IconComponent.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.d.ts +2 -0
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js +14 -10
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/components/BaseLayout.es.js +119 -99
- package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
- package/dist/insights-v2/components/statusIcon.d.ts +7 -0
- package/dist/insights-v2/components/statusIcon.es.js +10 -0
- package/dist/insights-v2/components/statusIcon.es.js.map +1 -0
- package/dist/microinsights/cards/InsightCard.es.js +78 -73
- package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SettingsStore.es.js","names":[],"sources":["../../../src/core/stores/SettingsStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { AlertProps } from '@mui/material'\n\nimport {\n AccountNotificationTypes,\n BudgetNotificationTypes,\n InsightNotificationTypes,\n} from '../types'\n\nimport type {\n DetailedNotificationProfile,\n Device,\n NotificationProfile,\n SettingsCopy,\n TransactionRule,\n User,\n UserCommunicationProfile,\n} from '../types'\n\nimport { SettingsApi, TransactionApi } from '../api'\nimport { augmentNotificationProfiles } from '../utils/SettingsUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\ninterface SettingsAlertProps {\n message: string\n severity: AlertProps['severity']\n}\n\nexport class SettingsStore {\n globalStore: GlobalStore\n api: SettingsApi = new SettingsApi('/', '')\n transactionApi: TransactionApi = new TransactionApi('/', '')\n\n alert: SettingsAlertProps = { message: '', severity: undefined }\n devices: Device[] = []\n notificationProfiles: NotificationProfile[] = []\n selectedRule: TransactionRule | undefined = undefined\n transactionRules: TransactionRule[] = []\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new SettingsApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n this.transactionApi = new TransactionApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n\n makeAutoObservable(this)\n }\n\n get accountProfiles() {\n const ccp = this.globalStore.appDataStore.clientCommunicationProfile\n\n // TODO: There has to be a better way to do this, but for now, it works\n return this.detailedNotificationProfiles.filter(\n (np) =>\n (np.notification_type === AccountNotificationTypes.DebtPaymentReminder &&\n ccp.debt_payment_reminder_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.AccountBalanceLow &&\n ccp.low_balance_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.AccountDepositLarge &&\n ccp.large_deposit_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.TransactionExpenseLarge &&\n ccp.large_expense_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.TransactionFeeCharge &&\n ccp.transaction_fee_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.InternationalTransaction &&\n ccp.transaction_is_international_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.AccountDepositLargePosted &&\n ccp.large_deposit_posted_notifications_enabled),\n )\n }\n\n get budgetProfiles() {\n const ccp = this.globalStore.appDataStore.clientCommunicationProfile\n\n // TODO: There has to be a better way to do this, but for now, it works\n return this.detailedNotificationProfiles.filter(\n (np) =>\n (np.notification_type === BudgetNotificationTypes.BudgetExceeded &&\n ccp.budget_exceeded_notifications_enabled) ||\n (np.notification_type === BudgetNotificationTypes.BudgetOffTarget &&\n ccp.budget_off_target_notifications_enabled),\n )\n }\n\n get insightsProfiles() {\n return this.detailedNotificationProfiles.filter((np) =>\n Object.values(InsightNotificationTypes).includes(np.notification_type),\n )\n }\n\n get clientCommunicationProfile() {\n return this.globalStore.appDataStore.clientCommunicationProfile\n }\n\n get copy(): SettingsCopy {\n return this.globalStore.copyStore.copy.settings\n }\n\n get detailedNotificationProfiles(): DetailedNotificationProfile[] {\n // Don't attempt to augment profile if global store is not initialized\n if (!this.globalStore.isInitialized) return []\n\n return augmentNotificationProfiles(\n this.globalStore.accountStore.accounts,\n this.clientCommunicationProfile,\n this.copy,\n this.notificationProfiles,\n this.userCommunicationsProfile,\n this.globalStore.userStore.user,\n )\n }\n\n get userCommunicationsProfile() {\n return this.globalStore.appDataStore.userCommunicationProfile\n }\n\n deleteDevice = async (guid: string) => {\n try {\n await this.api.deleteDevice(guid)\n\n const index = this.devices.findIndex((d) => d.guid === guid)\n if (index >= 0) {\n runInAction(() => {\n this.devices.splice(index, 1)\n })\n }\n\n return { success: true }\n } catch (error) {\n console.error('Error deleting device:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n return { success: false }\n }\n }\n\n deleteTransactionRule = async () => {\n if (!this.selectedRule) {\n return\n }\n try {\n await this.transactionApi.removeTransactionRule(this.selectedRule?.guid)\n this.setAlert(this.copy.delete_rule_success, 'success')\n await this.loadTransactionRules()\n } catch (error) {\n console.error('Error deleting transaction rule:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n this.setAlert(this.copy.delete_rule_error, 'error')\n }\n }\n\n generateDeviceToken = async () => {\n try {\n return await this.api.generateDeviceToken()\n } catch (error) {\n console.error('Error generating device token:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n }\n return undefined\n }\n\n loadDevices = async () => {\n try {\n const devices = await this.api.getDevices()\n\n runInAction(() => {\n this.devices = devices\n })\n } catch (error) {\n console.error('Error loading devices:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n }\n }\n\n loadNotificationProfiles = async () => {\n try {\n const profiles = await this.api.getNotificationProfiles()\n\n runInAction(() => {\n this.notificationProfiles = profiles\n })\n } catch (error) {\n console.error('Error loading notification profiles:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n }\n }\n\n loadTransactionRules = async () => {\n try {\n const rules = await this.transactionApi.getTransactionRules()\n\n runInAction(() => {\n this.transactionRules = rules\n })\n } catch (error) {\n console.error('Error loading transaction rules:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n }\n }\n\n sendEmailVerification = async () => {\n try {\n await this.api.sendEmailVerification()\n this.setAlert(this.copy.verification_sent_success, 'success')\n } catch (error) {\n console.error('Error sending email verification:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n this.setAlert(this.copy.verification_sent_error, 'error')\n }\n }\n\n sendPhoneVerification = async () => {\n try {\n await this.api.sendPhoneVerification()\n this.setAlert(this.copy.verification_sent_success, 'success')\n } catch (error) {\n console.error('Error sending phone verification:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n this.setAlert(this.copy.verification_sent_error, 'error')\n }\n }\n\n setAlert = (message: string, severity: SettingsAlertProps['severity'] = undefined) =>\n (this.alert = { message, severity })\n\n setSelectedRule = (rule?: TransactionRule) => {\n this.selectedRule = rule\n }\n\n updatePassword = async (params: { new_password: string; new_password_again: string }) => {\n try {\n await this.api.updatePassword(params)\n this.setAlert(this.copy.password_updated_success, 'success')\n } catch (error) {\n console.error('Error updating password:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n this.setAlert(this.copy.password_updated_error, 'error')\n }\n }\n\n updateDevice = async (device: Device) => {\n try {\n const updatedDevice = await this.api.updateDevice(device)\n\n const index = this.devices.findIndex((d) => d.guid === device.guid)\n if (index >= 0) {\n runInAction(() => {\n this.devices[index] = updatedDevice\n })\n }\n return { success: true }\n } catch (error) {\n console.error('Error updating device:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n return { success: false }\n }\n }\n\n /** Resolves `true` when the profile was saved, `false` when the API call failed. */\n updateNotificationProfile = async (profile: NotificationProfile): Promise<boolean> => {\n try {\n const updatedProfile = await this.api.updateNotificationProfile(profile)\n\n const index = this.notificationProfiles.findIndex((p) => p.guid === profile.guid)\n if (index >= 0) {\n runInAction(() => {\n this.notificationProfiles[index] = updatedProfile\n })\n }\n return true\n } catch (error) {\n console.error('Error updating notification profile:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n return false\n }\n }\n\n updateRuleCategory = async (rule: TransactionRule) => {\n try {\n await this.transactionApi.updateTransactionRule(rule)\n await this.loadTransactionRules()\n } catch (error) {\n console.error('Error updating rule category:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n }\n }\n\n updateRulePayee = async (rule: TransactionRule) => {\n try {\n await this.transactionApi.updateTransactionRule(rule)\n this.setAlert(this.copy.edit_payee_success, 'success')\n await this.loadTransactionRules()\n } catch (error) {\n console.error('Error updating rule payee:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n this.setAlert(this.copy.edit_payee_error, 'error')\n }\n }\n\n updateUser = async (user: User) => {\n try {\n await this.globalStore.userStore.updateUser(user)\n this.setAlert(this.copy.information_updated_success, 'success')\n } catch {\n // Error is already logged and captured in UserStore.updateUser\n this.setAlert(this.copy.information_updated_error, 'error')\n }\n }\n\n updateUserCommunicationProfile = async (profile: UserCommunicationProfile) => {\n try {\n const updatedProfile = await this.api.updateUserCommunicationProfile(profile)\n\n this.globalStore.appDataStore.setUserCommunicationProfile(updatedProfile)\n } catch (error) {\n console.error('Error occurred while updating user communication profile:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n }\n }\n\n verifyPhoneToken = async (sms_verification_token: string) => {\n try {\n const { verified } = await this.api.verifyPhoneToken(sms_verification_token)\n if (!verified) {\n throw new Error()\n }\n this.setAlert(this.copy.verified_phone_success, 'success')\n } catch (error) {\n console.error('Error verifying phone token:', error)\n this.globalStore.captureException(error, { store: 'SettingsStore' })\n this.setAlert(this.copy.verified_phone_error, 'error')\n }\n }\n}\n"],"mappings":";;;;;AA8BA,IAAa,IAAb,MAA2B;AAAA,EACzB;AAAA,EACA,MAAmB,IAAI,EAAY,KAAK,EAAE;AAAA,EAC1C,iBAAiC,IAAI,EAAe,KAAK,EAAE;AAAA,EAE3D,QAA4B;AAAA,IAAE,SAAS;AAAA,IAAI,UAAU;AAAA,EAAU;AAAA,EAC/D,UAAoB,CAAC;AAAA,EACrB,uBAA8C,CAAC;AAAA,EAC/C,eAA4C;AAAA,EAC5C,mBAAsC,CAAC;AAAA,EAEvC,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EAAY,EAAY,UAAU,EAAY,cAAc,EAAY,OAAO,GAC9F,KAAK,iBAAiB,IAAI,EACxB,EAAY,UACZ,EAAY,cACZ,EAAY,OACd,GAEA,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,IAAI,kBAAkB;AACpB,UAAM,IAAM,KAAK,YAAY,aAAa;AAG1C,WAAO,KAAK,6BAA6B,OAAA,CACtC,MACE,EAAG,sBAAsB,EAAyB,uBACjD,EAAI,+CACL,EAAG,sBAAsB,EAAyB,qBACjD,EAAI,qCACL,EAAG,sBAAsB,EAAyB,uBACjD,EAAI,uCACL,EAAG,sBAAsB,EAAyB,2BACjD,EAAI,uCACL,EAAG,sBAAsB,EAAyB,wBACjD,EAAI,yCACL,EAAG,sBAAsB,EAAyB,4BACjD,EAAI,sDACL,EAAG,sBAAsB,EAAyB,6BACjD,EAAI,0CACV;AAAA,EACF;AAAA,EAEA,IAAI,iBAAiB;AACnB,UAAM,IAAM,KAAK,YAAY,aAAa;AAG1C,WAAO,KAAK,6BAA6B,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OAAO,gBAAgB,CAAC,GACnE,KAAK,SAAS,KAAK,KAAK,kBAAkB,OAAO;AAAA,IACnD;AAAA,EACF;AAAA,EAEA,aAAa,OAAO,MAAe;AACjC,QAAI;AACF,YAAM,KAAK,YAAY,UAAU,WAAW,CAAI,GAChD,KAAK,SAAS,KAAK,KAAK,6BAA6B,SAAS;AAAA,IAChE,QAAQ;AAEN,WAAK,SAAS,KAAK,KAAK,2BAA2B,OAAO;AAAA,IAC5D;AAAA,EACF;AAAA,EAEA,iCAAiC,OAAO,MAAsC;AAC5E,QAAI;AACF,YAAM,IAAiB,MAAM,KAAK,IAAI,+BAA+B,CAAO;AAE5E,WAAK,YAAY,aAAa,4BAA4B,CAAc;AAAA,IAC1E,SAAS,GAAO;AACd,cAAQ,MAAM,6DAA6D,CAAK,GAChF,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,gBAAgB,CAAC;AAAA,IACrE;AAAA,EACF;AAAA,EAEA,mBAAmB,OAAO,MAAmC;AAC3D,QAAI;AACF,YAAM,EAAE,UAAA,EAAA,IAAa,MAAM,KAAK,IAAI,iBAAiB,CAAsB;AAC3E,UAAI,CAAC,EACH,OAAM,IAAI,MAAM;AAElB,WAAK,SAAS,KAAK,KAAK,wBAAwB,SAAS;AAAA,IAC3D,SAAS,GAAO;AACd,cAAQ,MAAM,gCAAgC,CAAK,GACnD,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,gBAAgB,CAAC,GACnE,KAAK,SAAS,KAAK,KAAK,sBAAsB,OAAO;AAAA,IACvD;AAAA,EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"SettingsStore.es.js","names":[],"sources":["../../../src/core/stores/SettingsStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { AlertProps } from '@mui/material'\n\nimport {\n AccountNotificationTypes,\n BudgetNotificationTypes,\n InsightNotificationTypes,\n} from '../types'\n\nimport type {\n DetailedNotificationProfile,\n Device,\n NotificationProfile,\n SettingsCopy,\n TransactionRule,\n User,\n UserCommunicationProfile,\n} from '../types'\n\nimport { SettingsApi, TransactionApi } from '../api'\nimport { augmentNotificationProfiles } from '../utils/SettingsUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\ninterface SettingsAlertProps {\n message: string\n severity: AlertProps['severity']\n}\n\nexport class SettingsStore {\n globalStore: GlobalStore\n api: SettingsApi = new SettingsApi('/', '')\n transactionApi: TransactionApi = new TransactionApi('/', '')\n\n alert: SettingsAlertProps = { message: '', severity: undefined }\n devices: Device[] = []\n notificationProfiles: NotificationProfile[] = []\n selectedRule: TransactionRule | undefined = undefined\n transactionRules: TransactionRule[] = []\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new SettingsApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n this.transactionApi = new TransactionApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n\n makeAutoObservable(this)\n }\n\n get accountProfiles() {\n const ccp = this.globalStore.appDataStore.clientCommunicationProfile\n\n // TODO: There has to be a better way to do this, but for now, it works\n return this.detailedNotificationProfiles.filter(\n (np) =>\n (np.notification_type === AccountNotificationTypes.DebtPaymentReminder &&\n ccp.debt_payment_reminder_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.AccountBalanceLow &&\n ccp.low_balance_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.AccountDepositLarge &&\n ccp.large_deposit_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.TransactionExpenseLarge &&\n ccp.large_expense_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.TransactionFeeCharge &&\n ccp.transaction_fee_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.InternationalTransaction &&\n ccp.transaction_is_international_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.AccountDepositLargePosted &&\n ccp.large_deposit_posted_notifications_enabled),\n )\n }\n\n get budgetProfiles() {\n const ccp = this.globalStore.appDataStore.clientCommunicationProfile\n\n // TODO: There has to be a better way to do this, but for now, it works\n return this.detailedNotificationProfiles.filter(\n (np) =>\n (np.notification_type === BudgetNotificationTypes.BudgetExceeded &&\n ccp.budget_exceeded_notifications_enabled) ||\n (np.notification_type === BudgetNotificationTypes.BudgetOffTarget &&\n ccp.budget_off_target_notifications_enabled),\n )\n }\n\n get insightsProfiles() {\n return this.detailedNotificationProfiles.filter((np) =>\n Object.values(InsightNotificationTypes).includes(np.notification_type),\n )\n }\n\n get clientCommunicationProfile() {\n return this.globalStore.appDataStore.clientCommunicationProfile\n }\n\n get copy(): SettingsCopy {\n return this.globalStore.copyStore.copy.settings\n }\n\n get detailedNotificationProfiles(): DetailedNotificationProfile[] {\n // Don't attempt to augment profile if global store is not initialized\n if (!this.globalStore.isInitialized) return []\n\n return augmentNotificationProfiles(\n this.globalStore.accountStore.accounts,\n this.clientCommunicationProfile,\n this.copy,\n this.notificationProfiles,\n this.userCommunicationsProfile,\n this.globalStore.userStore.user,\n )\n }\n\n get userCommunicationsProfile() {\n return this.globalStore.appDataStore.userCommunicationProfile\n }\n\n deleteDevice = async (guid: string) => {\n try {\n await this.api.deleteDevice(guid)\n\n const index = this.devices.findIndex((d) => d.guid === guid)\n if (index >= 0) {\n runInAction(() => {\n this.devices.splice(index, 1)\n })\n }\n\n return { success: true }\n } catch (error) {\n this.captureError('deleteDevice', error)\n return { success: false }\n }\n }\n\n deleteTransactionRule = async () => {\n if (!this.selectedRule) {\n return\n }\n try {\n await this.transactionApi.removeTransactionRule(this.selectedRule?.guid)\n this.setAlert(this.copy.delete_rule_success, 'success')\n await this.loadTransactionRules()\n } catch (error) {\n this.captureError('deleteTransactionRule', error)\n this.setAlert(this.copy.delete_rule_error, 'error')\n }\n }\n\n generateDeviceToken = async () => {\n try {\n return await this.api.generateDeviceToken()\n } catch (error) {\n this.captureError('generateDeviceToken', error)\n }\n return undefined\n }\n\n loadDevices = async () => {\n try {\n const devices = await this.api.getDevices()\n\n runInAction(() => {\n this.devices = devices\n })\n } catch (error) {\n this.captureError('loadDevices', error)\n }\n }\n\n loadNotificationProfiles = async () => {\n try {\n const profiles = await this.api.getNotificationProfiles()\n\n runInAction(() => {\n this.notificationProfiles = profiles\n })\n } catch (error) {\n this.captureError('loadNotificationProfiles', error)\n }\n }\n\n loadTransactionRules = async () => {\n try {\n const rules = await this.transactionApi.getTransactionRules()\n\n runInAction(() => {\n this.transactionRules = rules\n })\n } catch (error) {\n this.captureError('loadTransactionRules', error)\n }\n }\n\n sendEmailVerification = async () => {\n try {\n await this.api.sendEmailVerification()\n this.setAlert(this.copy.verification_sent_success, 'success')\n } catch (error) {\n this.captureError('sendEmailVerification', error)\n this.setAlert(this.copy.verification_sent_error, 'error')\n }\n }\n\n sendPhoneVerification = async () => {\n try {\n await this.api.sendPhoneVerification()\n this.setAlert(this.copy.verification_sent_success, 'success')\n } catch (error) {\n this.captureError('sendPhoneVerification', error)\n this.setAlert(this.copy.verification_sent_error, 'error')\n }\n }\n\n setAlert = (message: string, severity: SettingsAlertProps['severity'] = undefined) =>\n (this.alert = { message, severity })\n\n setSelectedRule = (rule?: TransactionRule) => {\n this.selectedRule = rule\n }\n\n updatePassword = async (params: { new_password: string; new_password_again: string }) => {\n try {\n await this.api.updatePassword(params)\n this.setAlert(this.copy.password_updated_success, 'success')\n } catch (error) {\n this.captureError('updatePassword', error)\n this.setAlert(this.copy.password_updated_error, 'error')\n }\n }\n\n updateDevice = async (device: Device) => {\n try {\n const updatedDevice = await this.api.updateDevice(device)\n\n const index = this.devices.findIndex((d) => d.guid === device.guid)\n if (index >= 0) {\n runInAction(() => {\n this.devices[index] = updatedDevice\n })\n }\n return { success: true }\n } catch (error) {\n this.captureError('updateDevice', error)\n return { success: false }\n }\n }\n\n /** Resolves `true` when the profile was saved, `false` when the API call failed. */\n updateNotificationProfile = async (profile: NotificationProfile): Promise<boolean> => {\n try {\n const updatedProfile = await this.api.updateNotificationProfile(profile)\n\n const index = this.notificationProfiles.findIndex((p) => p.guid === profile.guid)\n if (index >= 0) {\n runInAction(() => {\n this.notificationProfiles[index] = updatedProfile\n })\n }\n return true\n } catch (error) {\n this.captureError('updateNotificationProfile', error)\n return false\n }\n }\n\n updateRuleCategory = async (rule: TransactionRule) => {\n try {\n await this.transactionApi.updateTransactionRule(rule)\n await this.loadTransactionRules()\n } catch (error) {\n this.captureError('updateRuleCategory', error)\n }\n }\n\n updateRulePayee = async (rule: TransactionRule) => {\n try {\n await this.transactionApi.updateTransactionRule(rule)\n this.setAlert(this.copy.edit_payee_success, 'success')\n await this.loadTransactionRules()\n } catch (error) {\n this.captureError('updateRulePayee', error)\n this.setAlert(this.copy.edit_payee_error, 'error')\n }\n }\n\n updateUser = async (user: User) => {\n try {\n await this.globalStore.userStore.updateUser(user)\n this.setAlert(this.copy.information_updated_success, 'success')\n } catch {\n // Error is already logged and captured in UserStore.updateUser\n this.setAlert(this.copy.information_updated_error, 'error')\n }\n }\n\n updateUserCommunicationProfile = async (profile: UserCommunicationProfile) => {\n try {\n const updatedProfile = await this.api.updateUserCommunicationProfile(profile)\n\n this.globalStore.appDataStore.setUserCommunicationProfile(updatedProfile)\n } catch (error) {\n this.captureError('updateUserCommunicationProfile', error)\n }\n }\n\n verifyPhoneToken = async (sms_verification_token: string) => {\n try {\n const { verified } = await this.api.verifyPhoneToken(sms_verification_token)\n if (!verified) {\n throw new Error()\n }\n this.setAlert(this.copy.verified_phone_success, 'success')\n } catch (error) {\n this.captureError('verifyPhoneToken', error)\n this.setAlert(this.copy.verified_phone_error, 'error')\n }\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'SettingsStore', action })\n}\n"],"mappings":";;;;;AA8BA,IAAa,IAAb,MAA2B;AAAA,EACzB;AAAA,EACA,MAAmB,IAAI,EAAY,KAAK,EAAE;AAAA,EAC1C,iBAAiC,IAAI,EAAe,KAAK,EAAE;AAAA,EAE3D,QAA4B;AAAA,IAAE,SAAS;AAAA,IAAI,UAAU;AAAA,EAAU;AAAA,EAC/D,UAAoB,C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AmB,CAAK,GAC1C,KAAK,SAAS,KAAK,KAAK,kBAAkB,OAAO;AAAA,IACnD;AAAA,EACF;AAAA,EAEA,aAAa,OAAO,MAAe;AACjC,QAAI;AACF,YAAM,KAAK,YAAY,UAAU,WAAW,CAAI,GAChD,KAAK,SAAS,KAAK,KAAK,6BAA6B,SAAS;AAAA,IAChE,QAAQ;AAEN,WAAK,SAAS,KAAK,KAAK,2BAA2B,OAAO;AAAA,IAC5D;AAAA,EACF;AAAA,EAEA,iCAAiC,OAAO,MAAsC;AAC5E,QAAI;AACF,YAAM,IAAiB,MAAM,KAAK,IAAI,+BAA+B,CAAO;AAE5E,WAAK,YAAY,aAAa,4BAA4B,CAAc;AAAA,IAC1E,SAAS,GAAO;AACd,WAAK,aAAa,kCAAkC,CAAK;AAAA,IAC3D;AAAA,EACF;AAAA,EAEA,mBAAmB,OAAO,MAAmC;AAC3D,QAAI;AACF,YAAM,EAAE,UAAA,EAAA,IAAa,MAAM,KAAK,IAAI,iBAAiB,CAAsB;AAC3E,UAAI,CAAC,EACH,OAAM,IAAI,MAAM;AAElB,WAAK,SAAS,KAAK,KAAK,wBAAwB,SAAS;AAAA,IAC3D,SAAS,GAAO;AACd,WAAK,aAAa,oBAAoB,CAAK,GAC3C,KAAK,SAAS,KAAK,KAAK,sBAAsB,OAAO;AAAA,IACvD;AAAA,EACF;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAiB,QAAA;AAAA,EAAO,CAAC;AAC/E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UserApi as t } from "../api/UserApi.es.js";
|
|
2
|
-
import { makeAutoObservable as s, runInAction as
|
|
2
|
+
import { makeAutoObservable as s, runInAction as a } from "mobx";
|
|
3
3
|
var u = class {
|
|
4
4
|
globalStore;
|
|
5
5
|
api = new t("/", "");
|
|
@@ -23,7 +23,7 @@ var u = class {
|
|
|
23
23
|
const e = await this.api.getUserFeatures();
|
|
24
24
|
this.setUserFeatures(e);
|
|
25
25
|
} catch (e) {
|
|
26
|
-
|
|
26
|
+
this.captureError("loadUserFeatures", e), this.setUserFeatures([]);
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
updateUser = async (e) => {
|
|
@@ -31,7 +31,7 @@ var u = class {
|
|
|
31
31
|
const r = await this.api.updateUser(e);
|
|
32
32
|
this.globalStore.appDataStore.setUser(r);
|
|
33
33
|
} catch (r) {
|
|
34
|
-
throw
|
|
34
|
+
throw this.captureError("updateUser", r), r;
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
updateUserProfile = async (e) => {
|
|
@@ -39,7 +39,7 @@ var u = class {
|
|
|
39
39
|
const r = await this.api.updateUserProfile(e);
|
|
40
40
|
this.globalStore.appDataStore.setUserProfile(r);
|
|
41
41
|
} catch (r) {
|
|
42
|
-
|
|
42
|
+
this.captureError("updateUserProfile", r);
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
setUserInsightProfile = (e) => {
|
|
@@ -52,13 +52,17 @@ var u = class {
|
|
|
52
52
|
...this.userInsightProfile,
|
|
53
53
|
...e
|
|
54
54
|
});
|
|
55
|
-
return
|
|
55
|
+
return a(() => {
|
|
56
56
|
this.userInsightProfile = r;
|
|
57
57
|
}), r;
|
|
58
58
|
} catch (r) {
|
|
59
|
-
throw
|
|
59
|
+
throw this.captureError("updateUserInsightProfile", r), r;
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
+
captureError = (e, r) => this.globalStore.captureException(r, {
|
|
63
|
+
store: "UserStore",
|
|
64
|
+
action: e
|
|
65
|
+
});
|
|
62
66
|
};
|
|
63
67
|
export {
|
|
64
68
|
u as UserStore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserStore.es.js","names":[],"sources":["../../../src/core/stores/UserStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { UserApi } from '../api'\nimport type { User, UserFeature, UserInsightProfile, UserProfile } from '../types'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class UserStore {\n globalStore: GlobalStore\n api: UserApi = new UserApi('/', '')\n\n userFeatures: UserFeature[] = []\n userFeaturesLoaded: boolean = false\n userInsightProfile: UserInsightProfile | null = null\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new UserApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n get userProfile() {\n return this.globalStore.appDataStore.userProfile\n }\n\n get user() {\n return this.globalStore.appDataStore.user\n }\n\n setUserFeatures = (features: UserFeature[]) => {\n this.userFeatures = features\n this.userFeaturesLoaded = true\n }\n\n loadUserFeatures = async () => {\n try {\n const features = await this.api.getUserFeatures()\n this.setUserFeatures(features)\n } catch (e) {\n
|
|
1
|
+
{"version":3,"file":"UserStore.es.js","names":[],"sources":["../../../src/core/stores/UserStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { UserApi } from '../api'\nimport type { User, UserFeature, UserInsightProfile, UserProfile } from '../types'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class UserStore {\n globalStore: GlobalStore\n api: UserApi = new UserApi('/', '')\n\n userFeatures: UserFeature[] = []\n userFeaturesLoaded: boolean = false\n userInsightProfile: UserInsightProfile | null = null\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new UserApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n get userProfile() {\n return this.globalStore.appDataStore.userProfile\n }\n\n get user() {\n return this.globalStore.appDataStore.user\n }\n\n setUserFeatures = (features: UserFeature[]) => {\n this.userFeatures = features\n this.userFeaturesLoaded = true\n }\n\n loadUserFeatures = async () => {\n try {\n const features = await this.api.getUserFeatures()\n this.setUserFeatures(features)\n } catch (e) {\n this.captureError('loadUserFeatures', e)\n this.setUserFeatures([])\n }\n }\n\n updateUser = async (user: User) => {\n try {\n const updatedUser = await this.api.updateUser(user)\n\n this.globalStore.appDataStore.setUser(updatedUser)\n } catch (error) {\n this.captureError('updateUser', error)\n throw error\n }\n }\n\n updateUserProfile = async (userProfile: UserProfile) => {\n try {\n const updatedProfile = await this.api.updateUserProfile(userProfile)\n\n this.globalStore.appDataStore.setUserProfile(updatedProfile)\n } catch (error) {\n this.captureError('updateUserProfile', error)\n }\n }\n\n /**\n * Seeds the profile. The host (pulse) loads `user_insight_profile` and pushes it in here;\n * experiences itself never fetches it.\n */\n setUserInsightProfile = (profile: UserInsightProfile | null) => {\n this.userInsightProfile = profile\n }\n\n /**\n * Merges `fields` into the seeded profile and PUTs the whole profile. The endpoint is an\n * upsert that writes every profile field from the request, so a partial body would null\n * the fields it omits; the merge is what keeps them. Throws if the host has not seeded the\n * profile yet, and rethrows API failures, so a caller driving UI state (e.g. an insight\n * CTA) reports the error instead of silently treating the save as done.\n */\n updateUserInsightProfile = async (fields: Partial<UserInsightProfile>) => {\n if (!this.userInsightProfile) {\n throw new Error('User insight profile has not been loaded; refusing a partial PUT')\n }\n\n try {\n const updated = await this.api.updateUserInsightProfile({\n ...this.userInsightProfile,\n ...fields,\n })\n\n runInAction(() => {\n this.userInsightProfile = updated\n })\n\n return updated\n } catch (error) {\n this.captureError('updateUserInsightProfile', error)\n throw error\n }\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'UserStore', action })\n}\n"],"mappings":";;AAOA,IAAa,IAAb,MAAuB;AAAA,EACrB;AAAA,EACA,MAAe,IAAI,EAAQ,KAAK,EAAE;AAAA,EAElC,eAA8B,CAAC;AAAA,EAC/B,qBAA8B;AAAA,EAC9B,qBAAgD;AAAA,EAEhD,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EAAQ,EAAY,UAAU,EAAY,cAAc,EAAY,OAAO,GAE1F,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,IAAI,cAAc;AAChB,WAAO,KAAK,YAAY,a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AA,EACF;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAa,QAAA;AAAA,EAAO,CAAC;AAC3E"}
|
|
@@ -63,6 +63,12 @@ export interface InsightsPayload {
|
|
|
63
63
|
/** V2: drilldown-only facts, e.g. `{ account_number: 'XXXXXXXX043' }`. */
|
|
64
64
|
drilldown_data?: DrilldownData;
|
|
65
65
|
footer?: Footer;
|
|
66
|
+
/**
|
|
67
|
+
* V2: the link inside the description: on the full card a drawer of its own (Low Account
|
|
68
|
+
* Balance's "Transactions ›"); on mini and micro the card's action, sent instead of `primary_cta`.
|
|
69
|
+
* Absent when the beat has no link.
|
|
70
|
+
*/
|
|
71
|
+
in_description_cta?: InDescriptionCTA;
|
|
66
72
|
guid: string;
|
|
67
73
|
user_guid: string;
|
|
68
74
|
client_guid?: string;
|
|
@@ -196,6 +202,17 @@ export interface SecondaryCTA {
|
|
|
196
202
|
action_key?: string | null;
|
|
197
203
|
metadata?: CtaPostMessageMetadata | null;
|
|
198
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* The description link: its label, the action block it opens and, like a CTA's, the variant that
|
|
207
|
+
* tells that block what to show (ditto's `in_description_cta_variant`, e.g. `low_balance`). On mini
|
|
208
|
+
* and micro it words the card's action; `block` is empty when that action opens no drawer.
|
|
209
|
+
*/
|
|
210
|
+
export interface InDescriptionCTA {
|
|
211
|
+
label: string;
|
|
212
|
+
block?: string;
|
|
213
|
+
variant?: string | null;
|
|
214
|
+
action_key?: string | null;
|
|
215
|
+
}
|
|
199
216
|
export interface Footer {
|
|
200
217
|
/** V1: a pre-formatted date string. */
|
|
201
218
|
date?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Insights.es.js","names":[],"sources":["../../../src/core/types/Insights.ts"],"sourcesContent":["// ============ Core InsightsV2 Types ============\n\nimport { InsightsInstanceSlotData } from './InsightsInstanceSlotData'\n\nexport interface ThemedSVGImageProps {\n divProps?: React.HTMLAttributes<HTMLDivElement>\n image: React.ComponentType<React.SVGProps<SVGSVGElement>>\n isMini?: boolean\n}\n\n/**\n * Emitted by a block when the user drills into a specific datum (e.g. clicks a\n * chart bar). Named fields rather than positional args so blocks with differing\n * shapes can extend this without the call sites transposing values.\n */\nexport interface DrilldownPayload {\n chartBarIndex: number\n tabIndex?: number\n transaction_guid?: string\n block?: string\n}\n\n/**\n * Which envelope a beat was fetched with. `embedded` (the transaction-row pill + details-drawer\n * card) and `notification` are V2 additions; a surface asks for one with `widget_type=` on the fetch.\n */\nexport type WidgetType = 'full' | 'mini' | 'micro' | 'embedded' | 'notification'\n\n/**\n * V2: the transaction-row tag, its own small section of the `embedded` envelope (the same grammar\n * as `description` / `footer`, with room for a tone or an icon later). Omitted for an insight that\n * tags no transaction row. It deliberately is *not* `short_title`, which stays a per-variant\n * attribute with a second consumer (the bank-holiday sub-header).\n */\nexport interface Pill {\n text: string\n}\n\n/**\n * V2: facts a drilldown shows that the card does not (e.g. the account number for the Transaction\n * Details drawer). A flat hash shared by every CTA of the card, omitted when the insight has none.\n * Never carries copy or user actions (memo, tags, hide, flag come from the transaction store).\n */\nexport type DrilldownData = Record<string, string | number | boolean | null>\n\nexport interface InsightsPayload {\n widget_type: WidgetType\n instance_slot: InstanceSlot\n /**\n * V1 only. The v2 contract carries everything a block needs on `instance_slot.data`,\n * and omits this key entirely (see the LargeTransactionV2 payload). Blocks that still require it\n * get it as a required field through `BlockProps`, which re-declares it.\n */\n instance_slot_data?: InsightsInstanceSlotData\n description: Description\n primary_cta?: PrimaryCTA\n secondary_cta?: SecondaryCTA\n title?: string\n sub_title?: Subtitle\n /**\n * V2 rename of `sub_title`: a flat string, with the logo promoted to the payload-level `logo`\n * field below. `sub_title` wins when both are present.\n */\n subtitle?: string\n /** V2: header logo paired with the flat `subtitle`: an entity guid or a status icon (`LogoRef`). */\n logo?: LogoRef\n /** V2: which design branch the backend picked (e.g. `no_merchant`). */\n variant?: string\n /** V2, `embedded` envelope only: the transaction-row pill. */\n pill?: Pill\n /** V2: drilldown-only facts, e.g. `{ account_number: 'XXXXXXXX043' }`. */\n drilldown_data?: DrilldownData\n footer?: Footer\n // TODO: Add in_description_cta to insights_payload from backend\n guid: string\n user_guid: string\n client_guid?: string\n /** Template name, e.g. `LargeTransactionV2`. */\n template?: string\n revision?: number\n /** Unix seconds. */\n created_at?: number\n /** Unix seconds. */\n updated_at?: number\n /** Unix seconds. */\n active_at?: number\n displayed_at?: number | null\n dismissed_at: number | null\n cta_clicked_at?: number | null\n has_been_displayed?: boolean\n is_dismissed: boolean\n is_deleted?: boolean\n is_hidden_by_system?: boolean\n is_obsolete?: boolean\n is_refreshable?: boolean\n is_sampled?: boolean\n is_zero_state?: boolean\n status?: string | null\n /**\n * V2 (LargeTransactionV2 onward): the entities the beat is about, carried on the payload so\n * action blocks do not have to reach back out to the beat envelope.\n */\n primary_account_guid?: string | null\n primary_transaction_guid?: string | null\n primary_category_guid?: string | null\n primary_merchant_guid?: string | null\n /**\n * V2: the repeating transaction a subscription beat is about (Upcoming Subscription, Subscription\n * Price Increase). Read by `recurring_transaction_block`, see\n * `actionBlocks/RecurringTransactionBlock/subscriptionBeats.ts`.\n */\n primary_repeating_transaction_guid?: string | null\n}\n\nexport interface Legends {\n label: string\n value: number\n additional_value?: number\n additional_value_type?: string\n value_type?: string\n}\n\nexport interface Logo {\n category_guid?: string\n category_name?: string\n institution_guid?: string\n institution_name?: string\n logo_color?: string\n logo_name?: string\n merchant_guid?: string\n merchant_name?: string\n}\n\nexport interface Subtitle {\n logo?: Logo\n text: string\n}\n\n/**\n * A V2 logo, shared by the header (`InsightsPayload.logo`) and every instance-slot row. It takes\n * one of two shapes:\n *\n * - **Entity**: `guid`, whose prefix (`INS-` / `MCH-` / `CAT-`) picks the logo component, plus an\n * optional `fallback_guid` for when that component's asset cannot load. Today that is the\n * category behind an `MCH-` guid, which `MerchantLogo` shows as a tile when the merchant image\n * is missing.\n * - **Status icon**: `icon` (an mx-icons name, e.g. `warning`) and `color` (a theme palette path,\n * e.g. `error.main`), for subheaders that show a state rather than an entity (V1's\n * `logo_name` / `logo_color`).\n *\n * `alt` is the accessible name for either shape. A logo sends one shape; if it sends both, `icon`\n * wins, as `logo_name` does in V1's `SubHeader`.\n */\nexport interface LogoRef {\n alt?: string\n color?: string\n fallback_guid?: string\n guid?: string\n icon?: string\n}\n\nexport interface CategoryLogo {\n category_guid: string\n category_name: string\n}\n\nexport interface MerchantLogo {\n merchant_guid: string\n merchant_name: string\n}\n\nexport interface InstitutionLogo {\n institution_guid: string\n institution_name: string\n}\n\nexport interface Description {\n text: string\n html_text: string\n}\n\n/**\n * Post message a CTA press sends to the host, resolved by the backend for the beat's current\n * state. Absent/null = the backend has not described one: the frontend uses the template's\n * interim `ctaPostMessages` entry if there is one, else sends no message. `payload` carries only\n * beat-specific extras; the frontend always adds `beat_guid`, `beat_template`, `user_guid` and\n * `action_string`.\n */\nexport interface CtaPostMessageMetadata {\n /** Post message event; defaults to `beat/cta`. */\n event?: string | null\n /** Operation the host should perform, e.g. `op_1`, `op_2`, `op_3`. Defaults to `op_1`. */\n action?: string | null\n /** Beat-specific fields merged into the message metadata (account ids, amounts, ...). */\n payload?: Record<string, unknown> | null\n}\n\nexport interface PrimaryCTA {\n label: string\n block: string\n variant?: string | null\n /**\n * What pressing the CTA does beyond opening its block, named by the backend (ditto\n * `primary_cta_action`, passed through by tupac). Looked up in `insights-v2/ctaActions`;\n * null / absent / unknown means the CTA only opens its block or posts its message.\n */\n action_key?: string | null\n metadata?: CtaPostMessageMetadata | null\n}\n\nexport interface SecondaryCTA {\n label: string\n block: string\n variant?: string | null\n /** See `PrimaryCTA.action_key` (ditto `secondary_cta_action`). */\n action_key?: string | null\n metadata?: CtaPostMessageMetadata | null\n}\n\nexport interface Footer {\n /** V1: a pre-formatted date string. */\n date?: string\n /**\n * The account label, on both V1 and V2. The backend resolves the plurality: one account sends\n * its name (e.g. `Epic Bank`), several send a localized count (e.g. `2 Accounts`), none sends\n * nothing. There is deliberately no separate `accounts` key — see tupac's `footer_account_label`.\n */\n account?: string\n /**\n * V2 (LargeTransactionV2 onward): unix seconds, formatted by `Footer` for display.\n * Replaces `date`; `date` wins when a beat somehow sends both.\n */\n timestamp?: number\n}\n\n// ============ Instance Slot Types ============\n// Values are the snake_case block names the backend sends on a beat's instance slot; the PascalCase\n// keys stay as friendly references (e.g. BlockType.BarChartBlock === 'bar_chart_block').\nexport const BlockType = {\n AccountBlock: 'account_block',\n AccountSwitchBlock: 'account_switch_block',\n BarChartBlock: 'bar_chart_block',\n BudgetBlock: 'budget_block',\n ImageBlock: 'image_block',\n TransactionBlock: 'transaction_block',\n DonutChartBlock: 'donut_chart_block',\n DoubleBarChartBlock: 'double_bar_chart_block',\n DoubleProgressBarBlock: 'double_progress_bar_block',\n DebtsBlock: 'debts_block',\n SaveExtraBlock: 'save_extra_block',\n SavingsOpportunityBlock: 'savings_opportunity_block',\n StepChartBlock: 'step_chart_block',\n SVGImageBlock: 'svg_image_block',\n UpcomingBillBlock: 'upcoming_bill_block',\n UpcomingSubscriptionBlock: 'upcoming_subscription_block',\n WithdrawalBlock: 'withdrawal_block',\n} as const\n\nexport type BlockType = (typeof BlockType)[keyof typeof BlockType]\n\n/**\n * A pre-localized row on a V2 instance slot. The backend resolves the copy and formatting; the\n * logo is a `LogoRef` (an entity guid or a status icon, see `logoFromRef`).\n */\nexport interface InstanceSlotRow {\n amount?: number\n logo?: LogoRef\n primary_text?: string\n secondary_text?: string\n}\n\n/**\n * V2: the slots a block's variant filled, keyed by slot name; ditto owns the names and omits any\n * slot it has no value for (`lib/ditto/blocks/<block>.yml`). Read with `slot()`, which names the\n * kind the caller expects.\n */\nexport interface InstanceSlotData {\n [slot: string]: unknown\n}\n\n/**\n * Reads one slot off a block's `data`; undefined when ditto did not fill it.\n *\n * The caller names the kind, because the slot's kind lives in the block's ditto schema and not\n * here — a block fills slots with whatever its card needs, so no fixed list of kinds would hold\n * (`account_switch_block` alone carries a boolean and `budget_block` a nested object).\n */\nexport const slot = <T = unknown>(\n data: InstanceSlotData | undefined,\n name: string,\n): T | undefined => data?.[name] as T | undefined\n\n/**\n * V2: which block renders this beat's content, and what it renders.\n *\n * `block` is optional: a beat whose template has no ditto config arrives as an empty `{}` and the\n * card renders its copy and CTAs alone, so a reader cannot assume a block is named. One interface\n * with `block` optional rather than a union with `Record<string, never>`, which TypeScript absorbs\n * — that union left `block` reading as required and typed a promise it did not keep.\n *\n * `variant` is optional for the same reason — the empty `{}` carries neither. Every ditto beat\n * file that names a block also names a variant, so a *filled* slot always has one; ditto drops a\n * nil variant rather than sending null, which is why the type is `string | null | undefined`.\n */\nexport interface InstanceSlot {\n block?: BlockType\n variant?: string | null\n /** The slots this block's variant declares in ditto. */\n data?: InstanceSlotData\n // Direct Deposit block (Set Up Direct Deposit, Switch Direct Deposit, Missing\n // Interest Rate): account facts carried flat on the slot, beside `data`.\n /** Primary line on the hero card, e.g. \"Epic Bank Checking, *1234\". */\n account_name?: string\n /** Secondary line beneath the name, e.g. \"Checking Account\" / \"Credit Card\". */\n account_type?: string\n /** Status pill label, e.g. \"Direct Deposit Not Set Up\" / \"Interest Rate: 19.99% APR\". */\n status_text?: string\n institution_guid?: string\n institution_name?: string\n // Shared across multiple V2 component blocks:\n // `amount` — UpcomingBillBlock (projected bill), SavingsOpportunityBlock (coupon),\n // UpcomingSubscriptionBlock (price per cadence).\n // `merchant_guid` / `merchant_name` — UpcomingBillBlock (bill row logo + name),\n // UpcomingSubscriptionBlock (hero logo + name).\n /** Dollar amount (unformatted); the block formats it as currency. */\n amount?: number\n /** Merchant guid used to render the inline / hero logo via `LogoFromGuid` (`MCH-...`). */\n merchant_guid?: string\n /** Merchant display name — shown as logo alt text and as the merchant/hero label. */\n merchant_name?: string\n // Upcoming Bill block (Projected Bill Payment): the block derives the Sun→Sat week strip\n // around `due_date` at render time.\n /** Due date of the projected bill in ISO form (e.g. `2025-10-30`). */\n due_date?: string\n // Savings Opportunity block (Save An Extra, Potential Savings, Embedded): purely data-driven\n // coupon card. Backend sends the caption and the amount, plus `slot` to toggle the green\n // gradient background when the card is embedded in a parent surface that supplies its own.\n /** Caption shown above the amount, e.g. `Save an extra` or `Potential savings`. */\n label?: string\n /**\n * Whether to render the green gradient slot behind the coupon. Defaults to true. Backend sends\n * `false` when the coupon is embedded in a parent surface that supplies its own background.\n */\n slot?: boolean\n // Upcoming Subscription block: billing cadence for the price pill (`${amount} / ${cadence}`).\n /** Billing cadence word that trails the price, e.g. `month` or `year`. */\n cadence?: string\n // Account block (status on/off-track, deposit, payoff variants): card content carried flat on\n // the slot (the V2 contract drops `instance_slot_data`). `amount`, `label`, `merchant_guid`,\n // `merchant_name`, `institution_guid`, `institution_name` are shared fields declared above.\n /** Secondary line beneath the amount on the standard card, e.g. \"Remaining after expenses\". */\n sub_text?: string\n /** Header bar text (standard card) or the colored category strip label (deposit cards). */\n header_text?: string\n /** Generic-tile icon name used when no merchant/institution logo is available. */\n icon_name?: string\n /** Category guid used to render the deposit-card logo fallback. */\n category_guid?: string\n // Debts block: `amount` is the current balance; the shared account/institution fields above.\n /** Projected payoff date in ISO form (e.g. `2027-03-01`); the block formats it as month + year. */\n payoff_date?: string\n /** Monthly payment toward the debt (unformatted); the block formats it as currency. */\n monthly_payment?: number\n /** Annual interest rate as a percentage (e.g. `19.99`); the block formats it as a percent. */\n interest_rate?: number\n}\n"],"mappings":"AA+RA,IAAa,IAAA,CACX,GACA,MACkB,IAAO,CAAA"}
|
|
1
|
+
{"version":3,"file":"Insights.es.js","names":[],"sources":["../../../src/core/types/Insights.ts"],"sourcesContent":["// ============ Core InsightsV2 Types ============\n\nimport { InsightsInstanceSlotData } from './InsightsInstanceSlotData'\n\nexport interface ThemedSVGImageProps {\n divProps?: React.HTMLAttributes<HTMLDivElement>\n image: React.ComponentType<React.SVGProps<SVGSVGElement>>\n isMini?: boolean\n}\n\n/**\n * Emitted by a block when the user drills into a specific datum (e.g. clicks a\n * chart bar). Named fields rather than positional args so blocks with differing\n * shapes can extend this without the call sites transposing values.\n */\nexport interface DrilldownPayload {\n chartBarIndex: number\n tabIndex?: number\n transaction_guid?: string\n block?: string\n}\n\n/**\n * Which envelope a beat was fetched with. `embedded` (the transaction-row pill + details-drawer\n * card) and `notification` are V2 additions; a surface asks for one with `widget_type=` on the fetch.\n */\nexport type WidgetType = 'full' | 'mini' | 'micro' | 'embedded' | 'notification'\n\n/**\n * V2: the transaction-row tag, its own small section of the `embedded` envelope (the same grammar\n * as `description` / `footer`, with room for a tone or an icon later). Omitted for an insight that\n * tags no transaction row. It deliberately is *not* `short_title`, which stays a per-variant\n * attribute with a second consumer (the bank-holiday sub-header).\n */\nexport interface Pill {\n text: string\n}\n\n/**\n * V2: facts a drilldown shows that the card does not (e.g. the account number for the Transaction\n * Details drawer). A flat hash shared by every CTA of the card, omitted when the insight has none.\n * Never carries copy or user actions (memo, tags, hide, flag come from the transaction store).\n */\nexport type DrilldownData = Record<string, string | number | boolean | null>\n\nexport interface InsightsPayload {\n widget_type: WidgetType\n instance_slot: InstanceSlot\n /**\n * V1 only. The v2 contract carries everything a block needs on `instance_slot.data`,\n * and omits this key entirely (see the LargeTransactionV2 payload). Blocks that still require it\n * get it as a required field through `BlockProps`, which re-declares it.\n */\n instance_slot_data?: InsightsInstanceSlotData\n description: Description\n primary_cta?: PrimaryCTA\n secondary_cta?: SecondaryCTA\n title?: string\n sub_title?: Subtitle\n /**\n * V2 rename of `sub_title`: a flat string, with the logo promoted to the payload-level `logo`\n * field below. `sub_title` wins when both are present.\n */\n subtitle?: string\n /** V2: header logo paired with the flat `subtitle`: an entity guid or a status icon (`LogoRef`). */\n logo?: LogoRef\n /** V2: which design branch the backend picked (e.g. `no_merchant`). */\n variant?: string\n /** V2, `embedded` envelope only: the transaction-row pill. */\n pill?: Pill\n /** V2: drilldown-only facts, e.g. `{ account_number: 'XXXXXXXX043' }`. */\n drilldown_data?: DrilldownData\n footer?: Footer\n /**\n * V2: the link inside the description: on the full card a drawer of its own (Low Account\n * Balance's \"Transactions ›\"); on mini and micro the card's action, sent instead of `primary_cta`.\n * Absent when the beat has no link.\n */\n in_description_cta?: InDescriptionCTA\n guid: string\n user_guid: string\n client_guid?: string\n /** Template name, e.g. `LargeTransactionV2`. */\n template?: string\n revision?: number\n /** Unix seconds. */\n created_at?: number\n /** Unix seconds. */\n updated_at?: number\n /** Unix seconds. */\n active_at?: number\n displayed_at?: number | null\n dismissed_at: number | null\n cta_clicked_at?: number | null\n has_been_displayed?: boolean\n is_dismissed: boolean\n is_deleted?: boolean\n is_hidden_by_system?: boolean\n is_obsolete?: boolean\n is_refreshable?: boolean\n is_sampled?: boolean\n is_zero_state?: boolean\n status?: string | null\n /**\n * V2 (LargeTransactionV2 onward): the entities the beat is about, carried on the payload so\n * action blocks do not have to reach back out to the beat envelope.\n */\n primary_account_guid?: string | null\n primary_transaction_guid?: string | null\n primary_category_guid?: string | null\n primary_merchant_guid?: string | null\n /**\n * V2: the repeating transaction a subscription beat is about (Upcoming Subscription, Subscription\n * Price Increase). Read by `recurring_transaction_block`, see\n * `actionBlocks/RecurringTransactionBlock/subscriptionBeats.ts`.\n */\n primary_repeating_transaction_guid?: string | null\n}\n\nexport interface Legends {\n label: string\n value: number\n additional_value?: number\n additional_value_type?: string\n value_type?: string\n}\n\nexport interface Logo {\n category_guid?: string\n category_name?: string\n institution_guid?: string\n institution_name?: string\n logo_color?: string\n logo_name?: string\n merchant_guid?: string\n merchant_name?: string\n}\n\nexport interface Subtitle {\n logo?: Logo\n text: string\n}\n\n/**\n * A V2 logo, shared by the header (`InsightsPayload.logo`) and every instance-slot row. It takes\n * one of two shapes:\n *\n * - **Entity**: `guid`, whose prefix (`INS-` / `MCH-` / `CAT-`) picks the logo component, plus an\n * optional `fallback_guid` for when that component's asset cannot load. Today that is the\n * category behind an `MCH-` guid, which `MerchantLogo` shows as a tile when the merchant image\n * is missing.\n * - **Status icon**: `icon` (an mx-icons name, e.g. `warning`) and `color` (a theme palette path,\n * e.g. `error.main`), for subheaders that show a state rather than an entity (V1's\n * `logo_name` / `logo_color`).\n *\n * `alt` is the accessible name for either shape. A logo sends one shape; if it sends both, `icon`\n * wins, as `logo_name` does in V1's `SubHeader`.\n */\nexport interface LogoRef {\n alt?: string\n color?: string\n fallback_guid?: string\n guid?: string\n icon?: string\n}\n\nexport interface CategoryLogo {\n category_guid: string\n category_name: string\n}\n\nexport interface MerchantLogo {\n merchant_guid: string\n merchant_name: string\n}\n\nexport interface InstitutionLogo {\n institution_guid: string\n institution_name: string\n}\n\nexport interface Description {\n text: string\n html_text: string\n}\n\n/**\n * Post message a CTA press sends to the host, resolved by the backend for the beat's current\n * state. Absent/null = the backend has not described one: the frontend uses the template's\n * interim `ctaPostMessages` entry if there is one, else sends no message. `payload` carries only\n * beat-specific extras; the frontend always adds `beat_guid`, `beat_template`, `user_guid` and\n * `action_string`.\n */\nexport interface CtaPostMessageMetadata {\n /** Post message event; defaults to `beat/cta`. */\n event?: string | null\n /** Operation the host should perform, e.g. `op_1`, `op_2`, `op_3`. Defaults to `op_1`. */\n action?: string | null\n /** Beat-specific fields merged into the message metadata (account ids, amounts, ...). */\n payload?: Record<string, unknown> | null\n}\n\nexport interface PrimaryCTA {\n label: string\n block: string\n variant?: string | null\n /**\n * What pressing the CTA does beyond opening its block, named by the backend (ditto\n * `primary_cta_action`, passed through by tupac). Looked up in `insights-v2/ctaActions`;\n * null / absent / unknown means the CTA only opens its block or posts its message.\n */\n action_key?: string | null\n metadata?: CtaPostMessageMetadata | null\n}\n\nexport interface SecondaryCTA {\n label: string\n block: string\n variant?: string | null\n /** See `PrimaryCTA.action_key` (ditto `secondary_cta_action`). */\n action_key?: string | null\n metadata?: CtaPostMessageMetadata | null\n}\n\n/**\n * The description link: its label, the action block it opens and, like a CTA's, the variant that\n * tells that block what to show (ditto's `in_description_cta_variant`, e.g. `low_balance`). On mini\n * and micro it words the card's action; `block` is empty when that action opens no drawer.\n */\nexport interface InDescriptionCTA {\n label: string\n block?: string\n variant?: string | null\n action_key?: string | null\n}\n\nexport interface Footer {\n /** V1: a pre-formatted date string. */\n date?: string\n /**\n * The account label, on both V1 and V2. The backend resolves the plurality: one account sends\n * its name (e.g. `Epic Bank`), several send a localized count (e.g. `2 Accounts`), none sends\n * nothing. There is deliberately no separate `accounts` key — see tupac's `footer_account_label`.\n */\n account?: string\n /**\n * V2 (LargeTransactionV2 onward): unix seconds, formatted by `Footer` for display.\n * Replaces `date`; `date` wins when a beat somehow sends both.\n */\n timestamp?: number\n}\n\n// ============ Instance Slot Types ============\n// Values are the snake_case block names the backend sends on a beat's instance slot; the PascalCase\n// keys stay as friendly references (e.g. BlockType.BarChartBlock === 'bar_chart_block').\nexport const BlockType = {\n AccountBlock: 'account_block',\n AccountSwitchBlock: 'account_switch_block',\n BarChartBlock: 'bar_chart_block',\n BudgetBlock: 'budget_block',\n ImageBlock: 'image_block',\n TransactionBlock: 'transaction_block',\n DonutChartBlock: 'donut_chart_block',\n DoubleBarChartBlock: 'double_bar_chart_block',\n DoubleProgressBarBlock: 'double_progress_bar_block',\n DebtsBlock: 'debts_block',\n SaveExtraBlock: 'save_extra_block',\n SavingsOpportunityBlock: 'savings_opportunity_block',\n StepChartBlock: 'step_chart_block',\n SVGImageBlock: 'svg_image_block',\n UpcomingBillBlock: 'upcoming_bill_block',\n UpcomingSubscriptionBlock: 'upcoming_subscription_block',\n WithdrawalBlock: 'withdrawal_block',\n} as const\n\nexport type BlockType = (typeof BlockType)[keyof typeof BlockType]\n\n/**\n * A pre-localized row on a V2 instance slot. The backend resolves the copy and formatting; the\n * logo is a `LogoRef` (an entity guid or a status icon, see `logoFromRef`).\n */\nexport interface InstanceSlotRow {\n amount?: number\n logo?: LogoRef\n primary_text?: string\n secondary_text?: string\n}\n\n/**\n * V2: the slots a block's variant filled, keyed by slot name; ditto owns the names and omits any\n * slot it has no value for (`lib/ditto/blocks/<block>.yml`). Read with `slot()`, which names the\n * kind the caller expects.\n */\nexport interface InstanceSlotData {\n [slot: string]: unknown\n}\n\n/**\n * Reads one slot off a block's `data`; undefined when ditto did not fill it.\n *\n * The caller names the kind, because the slot's kind lives in the block's ditto schema and not\n * here — a block fills slots with whatever its card needs, so no fixed list of kinds would hold\n * (`account_switch_block` alone carries a boolean and `budget_block` a nested object).\n */\nexport const slot = <T = unknown>(\n data: InstanceSlotData | undefined,\n name: string,\n): T | undefined => data?.[name] as T | undefined\n\n/**\n * V2: which block renders this beat's content, and what it renders.\n *\n * `block` is optional: a beat whose template has no ditto config arrives as an empty `{}` and the\n * card renders its copy and CTAs alone, so a reader cannot assume a block is named. One interface\n * with `block` optional rather than a union with `Record<string, never>`, which TypeScript absorbs\n * — that union left `block` reading as required and typed a promise it did not keep.\n *\n * `variant` is optional for the same reason — the empty `{}` carries neither. Every ditto beat\n * file that names a block also names a variant, so a *filled* slot always has one; ditto drops a\n * nil variant rather than sending null, which is why the type is `string | null | undefined`.\n */\nexport interface InstanceSlot {\n block?: BlockType\n variant?: string | null\n /** The slots this block's variant declares in ditto. */\n data?: InstanceSlotData\n // Direct Deposit block (Set Up Direct Deposit, Switch Direct Deposit, Missing\n // Interest Rate): account facts carried flat on the slot, beside `data`.\n /** Primary line on the hero card, e.g. \"Epic Bank Checking, *1234\". */\n account_name?: string\n /** Secondary line beneath the name, e.g. \"Checking Account\" / \"Credit Card\". */\n account_type?: string\n /** Status pill label, e.g. \"Direct Deposit Not Set Up\" / \"Interest Rate: 19.99% APR\". */\n status_text?: string\n institution_guid?: string\n institution_name?: string\n // Shared across multiple V2 component blocks:\n // `amount` — UpcomingBillBlock (projected bill), SavingsOpportunityBlock (coupon),\n // UpcomingSubscriptionBlock (price per cadence).\n // `merchant_guid` / `merchant_name` — UpcomingBillBlock (bill row logo + name),\n // UpcomingSubscriptionBlock (hero logo + name).\n /** Dollar amount (unformatted); the block formats it as currency. */\n amount?: number\n /** Merchant guid used to render the inline / hero logo via `LogoFromGuid` (`MCH-...`). */\n merchant_guid?: string\n /** Merchant display name — shown as logo alt text and as the merchant/hero label. */\n merchant_name?: string\n // Upcoming Bill block (Projected Bill Payment): the block derives the Sun→Sat week strip\n // around `due_date` at render time.\n /** Due date of the projected bill in ISO form (e.g. `2025-10-30`). */\n due_date?: string\n // Savings Opportunity block (Save An Extra, Potential Savings, Embedded): purely data-driven\n // coupon card. Backend sends the caption and the amount, plus `slot` to toggle the green\n // gradient background when the card is embedded in a parent surface that supplies its own.\n /** Caption shown above the amount, e.g. `Save an extra` or `Potential savings`. */\n label?: string\n /**\n * Whether to render the green gradient slot behind the coupon. Defaults to true. Backend sends\n * `false` when the coupon is embedded in a parent surface that supplies its own background.\n */\n slot?: boolean\n // Upcoming Subscription block: billing cadence for the price pill (`${amount} / ${cadence}`).\n /** Billing cadence word that trails the price, e.g. `month` or `year`. */\n cadence?: string\n // Account block (status on/off-track, deposit, payoff variants): card content carried flat on\n // the slot (the V2 contract drops `instance_slot_data`). `amount`, `label`, `merchant_guid`,\n // `merchant_name`, `institution_guid`, `institution_name` are shared fields declared above.\n /** Secondary line beneath the amount on the standard card, e.g. \"Remaining after expenses\". */\n sub_text?: string\n /** Header bar text (standard card) or the colored category strip label (deposit cards). */\n header_text?: string\n /** Generic-tile icon name used when no merchant/institution logo is available. */\n icon_name?: string\n /** Category guid used to render the deposit-card logo fallback. */\n category_guid?: string\n // Debts block: `amount` is the current balance; the shared account/institution fields above.\n /** Projected payoff date in ISO form (e.g. `2027-03-01`); the block formats it as month + year. */\n payoff_date?: string\n /** Monthly payment toward the debt (unformatted); the block formats it as currency. */\n monthly_payment?: number\n /** Annual interest rate as a percentage (e.g. `19.99`); the block formats it as a percent. */\n interest_rate?: number\n}\n"],"mappings":"AAgTA,IAAa,IAAA,CACX,GACA,MACkB,IAAO,CAAA"}
|
|
@@ -13,7 +13,7 @@ export type { Expense } from './Expense';
|
|
|
13
13
|
export { ExpenseStatus, ScheduledPaymentTypes } from './Expense';
|
|
14
14
|
export type { DynamicCopyElement, GlobalCopy } from './GlobalCopy';
|
|
15
15
|
export { GoalType, MetaType, TrackType } from './Goal';
|
|
16
|
-
export type { ThemedSVGImageProps, DrilldownData, DrilldownPayload, InsightsPayload, InstanceSlot, InstanceSlotData, Pill, WidgetType, InstanceSlotRow, BlockType, Description, PrimaryCTA, CtaPostMessageMetadata, SecondaryCTA, Subtitle, Footer, Logo, LogoRef, CategoryLogo, MerchantLogo, InstitutionLogo, Legends, } from './Insights';
|
|
16
|
+
export type { ThemedSVGImageProps, DrilldownData, DrilldownPayload, InsightsPayload, InstanceSlot, InstanceSlotData, Pill, WidgetType, InstanceSlotRow, BlockType, Description, PrimaryCTA, CtaPostMessageMetadata, SecondaryCTA, Subtitle, Footer, Logo, LogoRef, InDescriptionCTA, CategoryLogo, MerchantLogo, InstitutionLogo, Legends, } from './Insights';
|
|
17
17
|
export { slot } from './Insights';
|
|
18
18
|
export type { Goal, MonthlyCashFlowProfile, RetirementGoalAccount } from './Goal';
|
|
19
19
|
export type { Debt } from './Debt';
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { useGlobalCopyStore as
|
|
1
|
+
import { useGlobalCopyStore as C, useGlobalUiStore as _, useInsightsV2Store as h } from "../../common/context/hooks.es.js";
|
|
2
2
|
import B from "../../common/components/drawer/Drawer.es.js";
|
|
3
|
-
import
|
|
4
|
-
import { getDynamicCtaBasedOnTriggers as
|
|
5
|
-
import { hasDrawerBlock as
|
|
6
|
-
import { actionBlocks as
|
|
7
|
-
import { observer as
|
|
8
|
-
import
|
|
9
|
-
import { Text as
|
|
3
|
+
import v from "../../common/components/Loader.es.js";
|
|
4
|
+
import { getDynamicCtaBasedOnTriggers as w } from "./util.es.js";
|
|
5
|
+
import { hasDrawerBlock as D } from "../mappings/hasDrawerBlock.es.js";
|
|
6
|
+
import { actionBlocks as b } from "../mappings/blocks.es.js";
|
|
7
|
+
import { observer as L } from "mobx-react-lite";
|
|
8
|
+
import x from "@mui/material/Stack";
|
|
9
|
+
import { Text as A } from "@mxenabled/mxui";
|
|
10
10
|
import { jsx as e } from "react/jsx-runtime";
|
|
11
11
|
var m = ({ actionBlock: s, ...o }) => {
|
|
12
12
|
const { Component: i, usePrepare: n } = s;
|
|
13
13
|
return n(o), /* @__PURE__ */ e(i, { ...o });
|
|
14
|
-
},
|
|
15
|
-
const i =
|
|
14
|
+
}, q = L(function({ beat: o }) {
|
|
15
|
+
const i = C(), n = i.common, { isCopyLoaded: p } = _(), { actionDrawer: c, closeActionDrawer: d } = h();
|
|
16
16
|
if (!o.insights_payload) return null;
|
|
17
|
-
const { primary_cta:
|
|
18
|
-
if (!p) return
|
|
19
|
-
const r =
|
|
20
|
-
if (t?.presentation === "modal") return
|
|
17
|
+
const { primary_cta: u, secondary_cta: f, in_description_cta: k } = o.insights_payload, a = c.isDrawerOpen && c.guid === o.guid;
|
|
18
|
+
if (!p) return a ? /* @__PURE__ */ e(v, {}) : null;
|
|
19
|
+
const r = w(c, u, f, k), l = D(r?.block), t = l ? b[r?.block] : void 0;
|
|
20
|
+
if (t?.presentation === "modal") return a ? /* @__PURE__ */ e(m, {
|
|
21
21
|
actionBlock: t,
|
|
22
22
|
beat: o
|
|
23
23
|
}, r?.block) : null;
|
|
24
|
-
const
|
|
24
|
+
const y = t?.title?.(r?.variant, i, o), g = t ? y || r?.label || "" : l ? n.error_heading : r?.label ?? "";
|
|
25
25
|
return /* @__PURE__ */ e(B, {
|
|
26
26
|
ariaLabelClose: n.close_aria,
|
|
27
|
-
isOpen:
|
|
28
|
-
onClose:
|
|
29
|
-
title:
|
|
27
|
+
isOpen: a,
|
|
28
|
+
onClose: d,
|
|
29
|
+
title: g,
|
|
30
30
|
children: t ? /* @__PURE__ */ e(m, {
|
|
31
31
|
actionBlock: t,
|
|
32
32
|
beat: o
|
|
33
|
-
}, r?.block) :
|
|
33
|
+
}, r?.block) : l ? /* @__PURE__ */ e(x, {
|
|
34
34
|
sx: { p: 24 },
|
|
35
|
-
children: /* @__PURE__ */ e(
|
|
35
|
+
children: /* @__PURE__ */ e(A, { children: n.error_message })
|
|
36
36
|
}) : null
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
export {
|
|
40
|
-
|
|
40
|
+
q as ActionBlockLayer
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
//# sourceMappingURL=ActionBlockLayer.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBlockLayer.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/ActionBlockLayer.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Drawer,\n Loader,\n useGlobalCopyStore,\n useGlobalUiStore,\n useInsightsV2Store,\n} from '../../common'\nimport { type Beat } from '../../core'\nimport {\n actionBlocks,\n hasDrawerBlock,\n type ActionBlockEntry,\n type ActionBlockProps,\n} from '../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from './util'\n\ninterface ActionBlockLayerProps {\n beat: Beat\n}\n\n/**\n * Renders a registered action block. Callers MUST key this per block name — a\n * block with `usePrepare` and one without run a different number of hooks, so\n * reusing the same fiber across a block switch violates the rules of hooks.\n */\nconst ActionBlockRunner = ({\n actionBlock,\n ...blockProps\n}: ActionBlockProps & { actionBlock: ActionBlockEntry }) => {\n const { Component, usePrepare } = actionBlock\n\n usePrepare(blockProps)\n\n return <Component {...blockProps} />\n}\n\n// `observer` is required: this reads `isCopyLoaded` off GlobalUiStore and the\n// action drawer off InsightsV2Store. Without it the component never re-renders\n// and stays stuck on <Loader /> forever.\nexport const ActionBlockLayer = observer(function ActionBlockLayer({\n beat,\n}: ActionBlockLayerProps) {\n const copy = useGlobalCopyStore()\n const commonCopy = copy.common\n const { isCopyLoaded } = useGlobalUiStore()\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n\n // Mirrors BaseLayout's guard — the layer is exported, so callers are not\n // guaranteed to have narrowed this already.\n if (!beat.insights_payload) return null\n\n const { primary_cta, secondary_cta } = beat.insights_payload\n\n // Every card in the feed renders its own layer against the shared store, so\n // this card's drawer only opens when its beat is the one that triggered it.\n const isCurrentBeatOpen = actionDrawer.isDrawerOpen && actionDrawer.guid === beat.guid\n\n if (!isCopyLoaded) return isCurrentBeatOpen ? <Loader /> : null\n\n const currentCta = getDynamicCtaBasedOnTriggers(actionDrawer
|
|
1
|
+
{"version":3,"file":"ActionBlockLayer.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/ActionBlockLayer.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Drawer,\n Loader,\n useGlobalCopyStore,\n useGlobalUiStore,\n useInsightsV2Store,\n} from '../../common'\nimport { type Beat } from '../../core'\nimport {\n actionBlocks,\n hasDrawerBlock,\n type ActionBlockEntry,\n type ActionBlockProps,\n} from '../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from './util'\n\ninterface ActionBlockLayerProps {\n beat: Beat\n}\n\n/**\n * Renders a registered action block. Callers MUST key this per block name — a\n * block with `usePrepare` and one without run a different number of hooks, so\n * reusing the same fiber across a block switch violates the rules of hooks.\n */\nconst ActionBlockRunner = ({\n actionBlock,\n ...blockProps\n}: ActionBlockProps & { actionBlock: ActionBlockEntry }) => {\n const { Component, usePrepare } = actionBlock\n\n usePrepare(blockProps)\n\n return <Component {...blockProps} />\n}\n\n// `observer` is required: this reads `isCopyLoaded` off GlobalUiStore and the\n// action drawer off InsightsV2Store. Without it the component never re-renders\n// and stays stuck on <Loader /> forever.\nexport const ActionBlockLayer = observer(function ActionBlockLayer({\n beat,\n}: ActionBlockLayerProps) {\n const copy = useGlobalCopyStore()\n const commonCopy = copy.common\n const { isCopyLoaded } = useGlobalUiStore()\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n\n // Mirrors BaseLayout's guard — the layer is exported, so callers are not\n // guaranteed to have narrowed this already.\n if (!beat.insights_payload) return null\n\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload\n\n // Every card in the feed renders its own layer against the shared store, so\n // this card's drawer only opens when its beat is the one that triggered it.\n const isCurrentBeatOpen = actionDrawer.isDrawerOpen && actionDrawer.guid === beat.guid\n\n if (!isCopyLoaded) return isCurrentBeatOpen ? <Loader /> : null\n\n const currentCta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n primary_cta,\n secondary_cta,\n in_description_cta,\n )\n\n // A CTA without a real block never opens a drawer (BaseLayout won't trigger it);\n // a real-but-unknown block shows the error (\"oops\") content.\n const blockValid = hasDrawerBlock(currentCta?.block)\n const actionBlock = blockValid\n ? actionBlocks[currentCta?.block as keyof typeof actionBlocks]\n : undefined\n\n // A modal block owns its dialog: no drawer behind it, and nothing mounted until it is opened.\n if (actionBlock?.presentation === 'modal') {\n return isCurrentBeatOpen ? (\n <ActionBlockRunner actionBlock={actionBlock} beat={beat} key={currentCta?.block} />\n ) : null\n }\n\n const resolvedTitle = actionBlock?.title?.(currentCta?.variant, copy, beat)\n const drawerTitle = actionBlock\n ? resolvedTitle || currentCta?.label || ''\n : blockValid\n ? commonCopy.error_heading\n : (currentCta?.label ?? '')\n\n return (\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isCurrentBeatOpen}\n onClose={closeActionDrawer}\n title={drawerTitle}\n >\n {actionBlock ? (\n <ActionBlockRunner actionBlock={actionBlock} beat={beat} key={currentCta?.block} />\n ) : blockValid ? (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy.error_message}</Text>\n </Stack>\n ) : null}\n </Drawer>\n )\n})\n"],"mappings":";;;;;;;;;;AA8BA,IAAM,IAAA,CAAqB,EACzB,aAAA,GACA,GAAG,EAAA,MACuD;AAC1D,QAAM,EAAE,WAAA,GAAW,YAAA,EAAA,IAAe;AAElC,SAAA,EAAW,CAAU,GAEd,gBAAA,EAAC,GAAD,EAAW,GAAI,EAAa,CAAA;AACrC,GAKa,IAAmB,EAAS,SAA0B,EACjE,MAAA,EAAA,G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
2
|
-
import { formatCurrency as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { BarChartV2 as
|
|
6
|
-
import { EmptyBarChart as
|
|
7
|
-
import { TransactionDrillDown as
|
|
8
|
-
import { useTransactionHistory as
|
|
9
|
-
import { getDefaultSelection as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { useGlobalCopyStore as W, useGlobalUiStore as X, useInsightsV2Store as Y } from "../../../common/context/hooks.es.js";
|
|
2
|
+
import { formatCurrency as Z } from "../../../core/utils/NumberFormatting.es.js";
|
|
3
|
+
import tt from "../../../common/components/drawer/Drawer.es.js";
|
|
4
|
+
import et from "../../../common/components/Loader.es.js";
|
|
5
|
+
import { BarChartV2 as at } from "../../components/chartblocks/BarchartV2.es.js";
|
|
6
|
+
import { EmptyBarChart as ot } from "../../components/chartblocks/EmptyBarChart.es.js";
|
|
7
|
+
import { TransactionDrillDown as nt } from "./TransactionDrillDown.es.js";
|
|
8
|
+
import { useTransactionHistory as rt } from "./useTransactionHistory.es.js";
|
|
9
|
+
import { getDefaultSelection as it, getDrillDownConfig as st, getFlattenedDataSeries as lt, toStoreFilter as ct } from "./utils.es.js";
|
|
10
|
+
import { getDynamicCtaBasedOnTriggers as dt } from "../util.es.js";
|
|
11
|
+
import { TransactionDetailsBlock as mt } from "../TransactionDetailsBlock/TransactionDetailsBlock.es.js";
|
|
12
|
+
import { useLayoutEffect as gt, useState as u } from "react";
|
|
13
|
+
import { observer as pt } from "mobx-react-lite";
|
|
14
|
+
import { Fragment as ut, jsx as n, jsxs as ht } from "react/jsx-runtime";
|
|
15
|
+
import { useTheme as bt } from "@mui/material/styles";
|
|
16
|
+
var jt = pt(({ beat: a }) => {
|
|
17
|
+
const h = bt(), { instanceSlotData: e, beatTransactions: l, spendCategoryGuids: b, allAccountGuids: f, categoryName: v, displayedDateRange: g, transactionStore: x } = rt(a), { actionDrawer: y, setActionContext: C } = Y(), { common: B, insights_feed: c } = W(), { isCopyLoaded: F } = X(), [I, T] = u(!1), [G, A] = u(!1), { insights_payload: o } = a, j = dt(y, o?.primary_cta, o?.secondary_cta, o?.in_description_cta)?.variant, { top: r, filterMode: d, header: k, colors: w, filterStrategy: H, tipSection: S } = st(j ?? ""), { dataSeries: m, chartData: i, comparisonBars: O } = lt({
|
|
17
18
|
data: e?.data_series,
|
|
18
19
|
ariaLabel: e?.ariaLabel ?? "",
|
|
19
|
-
top:
|
|
20
|
-
beatTransactions:
|
|
20
|
+
top: r,
|
|
21
|
+
beatTransactions: l,
|
|
21
22
|
payload: e
|
|
22
|
-
}), { chartBarIndex: E, subTabIndex: K } =
|
|
23
|
-
chartTabCount:
|
|
23
|
+
}), { chartBarIndex: E, subTabIndex: K } = it({
|
|
24
|
+
chartTabCount: i.length,
|
|
24
25
|
comparisonTabCount: O.length,
|
|
25
26
|
actionDrawer: y,
|
|
26
27
|
beatGuid: a.guid
|
|
27
|
-
}), [
|
|
28
|
+
}), [s, _] = u(E), D = (t) => H({
|
|
28
29
|
beat: a,
|
|
29
|
-
beatTransactions:
|
|
30
|
-
dataSeries:
|
|
30
|
+
beatTransactions: l,
|
|
31
|
+
dataSeries: m,
|
|
31
32
|
selectedIndex: t,
|
|
32
33
|
subIndex: K,
|
|
33
|
-
isLastTab: t ===
|
|
34
|
+
isLastTab: t === m.length - 1,
|
|
34
35
|
instanceSlotData: e,
|
|
35
36
|
spendCategoryGuids: b,
|
|
36
|
-
displayedDateRange:
|
|
37
|
-
}), V =
|
|
38
|
-
|
|
37
|
+
displayedDateRange: g
|
|
38
|
+
}), V = l.map((t) => t.guid).join(","), R = b.join(","), M = f.join(","), N = r === "list" || m.length > 0, L = () => {
|
|
39
|
+
d !== "store" || !N || x.setFilter(ct(D(s), {
|
|
39
40
|
allAccountGuids: f,
|
|
40
|
-
displayedDateRange:
|
|
41
|
+
displayedDateRange: g
|
|
41
42
|
}));
|
|
42
43
|
};
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
gt(() => {
|
|
45
|
+
L();
|
|
45
46
|
}, [
|
|
46
47
|
a.guid,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
s,
|
|
49
|
+
d,
|
|
50
|
+
m.length,
|
|
50
51
|
e,
|
|
51
|
-
|
|
52
|
+
g,
|
|
52
53
|
R,
|
|
53
54
|
M,
|
|
54
|
-
V
|
|
55
|
+
V,
|
|
56
|
+
r
|
|
55
57
|
]);
|
|
56
58
|
const p = k?.({
|
|
57
|
-
title:
|
|
58
|
-
subHeader:
|
|
59
|
-
categoryName:
|
|
60
|
-
selectedDate:
|
|
61
|
-
}),
|
|
62
|
-
if (!F) return /* @__PURE__ */
|
|
63
|
-
const
|
|
59
|
+
title: o?.title,
|
|
60
|
+
subHeader: o?.sub_title,
|
|
61
|
+
categoryName: v,
|
|
62
|
+
selectedDate: i[s]?.date ?? void 0
|
|
63
|
+
}), P = w(h, e?.category_guid);
|
|
64
|
+
if (!F) return /* @__PURE__ */ n(et, {});
|
|
65
|
+
const U = [c.general.monthly_amount, c.general.trend], [$, q] = e?.legends?.length ? e.legends.map((t) => t.label) : U, z = d === "local" ? (t) => D(t).custom ?? (() => !0) : void 0, J = d === "local" ? l : void 0, Q = r === "singleBar" || r === "upcomingBill" ? i.length ? /* @__PURE__ */ n(at, {
|
|
64
66
|
amounts: {
|
|
65
67
|
average: e?.average_amount,
|
|
66
|
-
formattedAverage:
|
|
68
|
+
formattedAverage: Z(e?.average_amount ?? 0, "0,0.00")
|
|
67
69
|
},
|
|
68
|
-
color:
|
|
69
|
-
data:
|
|
70
|
+
color: P[0] ?? h.palette.primary.main,
|
|
71
|
+
data: i,
|
|
70
72
|
legendPosition: "top",
|
|
71
73
|
heightOverride: 142,
|
|
72
74
|
margin: {
|
|
@@ -75,41 +77,41 @@ var It = mt(({ beat: a }) => {
|
|
|
75
77
|
left: 24,
|
|
76
78
|
right: 24
|
|
77
79
|
},
|
|
78
|
-
monthlyAmountLabel:
|
|
80
|
+
monthlyAmountLabel: $,
|
|
79
81
|
onBarClick: _,
|
|
80
|
-
selectedTabIndex:
|
|
81
|
-
trendAmountLabel:
|
|
82
|
-
}) : /* @__PURE__ */
|
|
83
|
-
return /* @__PURE__ */
|
|
82
|
+
selectedTabIndex: s,
|
|
83
|
+
trendAmountLabel: q
|
|
84
|
+
}) : /* @__PURE__ */ n(ot, {}) : null;
|
|
85
|
+
return /* @__PURE__ */ ht(ut, { children: [/* @__PURE__ */ n(nt, {
|
|
84
86
|
ariaLabel: e?.ariaLabel,
|
|
85
|
-
baseTransactions:
|
|
87
|
+
baseTransactions: J,
|
|
86
88
|
heading: p?.heading,
|
|
87
89
|
icon: p?.icon,
|
|
88
90
|
onSelectionChange: _,
|
|
89
|
-
selectedIndex:
|
|
91
|
+
selectedIndex: s,
|
|
90
92
|
subHeadingText: p?.subHeadingText,
|
|
91
|
-
tabs:
|
|
93
|
+
tabs: i.map((t) => ({
|
|
92
94
|
ariaLabel: t.ariaLabel,
|
|
93
95
|
label: t.label
|
|
94
96
|
})),
|
|
95
|
-
top:
|
|
96
|
-
...S && { tipSection: !G && S(A,
|
|
97
|
-
transactionFilter:
|
|
97
|
+
top: Q,
|
|
98
|
+
...S && { tipSection: !G && S(A, c, o?.sub_title?.text) },
|
|
99
|
+
transactionFilter: z,
|
|
98
100
|
onEachRowClick: (t) => {
|
|
99
101
|
C({ transaction_guid: t }), T(!0);
|
|
100
102
|
}
|
|
101
|
-
}), /* @__PURE__ */
|
|
103
|
+
}), /* @__PURE__ */ n(tt, {
|
|
102
104
|
ariaLabelClose: B.close_aria,
|
|
103
105
|
isOpen: I,
|
|
104
106
|
onClose: () => {
|
|
105
|
-
T(!1), C({ transaction_guid: void 0 }),
|
|
107
|
+
T(!1), C({ transaction_guid: void 0 }), L();
|
|
106
108
|
},
|
|
107
|
-
title:
|
|
108
|
-
children: /* @__PURE__ */
|
|
109
|
+
title: c.general.transaction_details_title,
|
|
110
|
+
children: /* @__PURE__ */ n(mt, { beat: a })
|
|
109
111
|
})] });
|
|
110
112
|
});
|
|
111
113
|
export {
|
|
112
|
-
|
|
114
|
+
jt as TransactionHistoryBlock
|
|
113
115
|
};
|
|
114
116
|
|
|
115
117
|
//# sourceMappingURL=TransactionHistoryBlock.es.js.map
|