@mx-cartographer/experiences 9.7.97 → 9.7.99-alpha-ram-cs-1
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 +13 -0
- package/dist/core/types/Insights.d.ts +26 -119
- package/dist/core/types/Insights.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.d.ts +2 -7
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +79 -72
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.d.ts +5 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js +61 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.d.ts +2 -6
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js +13 -12
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js +166 -113
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js +4 -4
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.d.ts +5 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js +39 -26
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +42 -55
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.d.ts +8 -6
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js +23 -17
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/util.d.ts +2 -11
- package/dist/insights-v2/actionBlocks/util.es.js +14 -7
- package/dist/insights-v2/actionBlocks/util.es.js.map +1 -1
- package/dist/insights-v2/analytics/analyticsEventsConfig.d.ts +16 -0
- package/dist/insights-v2/analytics/analyticsEventsConfig.es.js +19 -2
- package/dist/insights-v2/analytics/analyticsEventsConfig.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js +30 -29
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/layout.d.ts +1 -0
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/layout.es.js +4 -3
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/components/ExportCsvButton.d.ts +9 -0
- package/dist/insights-v2/components/ExportCsvButton.es.js +25 -0
- package/dist/insights-v2/components/ExportCsvButton.es.js.map +1 -0
- package/dist/insights-v2/components/Header.es.js +5 -2
- package/dist/insights-v2/components/Header.es.js.map +1 -1
- package/dist/insights-v2/mappings/blocks.es.js +151 -146
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmountInputModalBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport MuiDialog from '@mui/material/Dialog'\nimport IconButton from '@mui/material/IconButton'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n Loader,\n buildDynamicCopy,\n useGlobalCopyStore,\n useInsightsV2Store,\n useSettingsStore,\n useUserStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\nimport {\n AMOUNT_INPUT_VARIANTS,\n findLowBalanceProfile,\n isAmountInputVariant,\n isWholeAmount,\n resolveAmountInputVariant,\n toInputValue,\n} from './layout'\n\n/**\n * The dialog frame for the states that have no form: loading, and a non-retriable problem. Named by\n * its heading and closable by button, Esc and backdrop, like the form dialog.\n */\nconst StatusDialog = ({\n children,\n closeAriaLabel,\n heading,\n onClose,\n}: React.PropsWithChildren<{ closeAriaLabel?: string; heading?: string; onClose: () => void }>) => {\n const headingId = React.useId()\n\n return (\n <MuiDialog\n aria-labelledby={heading ? headingId : undefined}\n maxWidth=\"xs\"\n onClose={onClose}\n open={true}\n >\n <Stack sx={{ gap: 12, p: 24, position: 'relative' }}>\n {heading && <H3 id={headingId}>{heading}</H3>}\n <IconButton\n aria-label={closeAriaLabel || 'Close'}\n onClick={onClose}\n sx={{ position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n {children}\n </Stack>\n </MuiDialog>\n )\n}\n\n/**\n * `amount_input_modal_block`: one whole-dollar setting edited in a dialog (Figma 441:24913 and\n * 5402:34137). The CTA's variant picks what is edited:\n * - `low_balance_threshold`: the `threshold` on the beat account's low-balance alert profile;\n * - `safety_net`: `savings_opportunity_minimum_checking_account_balance` on the insight profile.\n *\n * Registered with `presentation: 'modal'`, so no drawer opens behind it; closing the dialog ends\n * the action-drawer session. `observer` is required: the starting values are read from stores.\n */\nexport const AmountInputModalBlock = observer(function AmountInputModalBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n const settingsStore = useSettingsStore()\n const { userInsightProfile } = useUserStore()\n const runHandler = useCtaHandler(beat, useBeatActions())\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n const cta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n primary_cta,\n secondary_cta,\n in_description_cta,\n )\n const variant = resolveAmountInputVariant(cta)\n const copy = insightsFeedCopy?.amount_input_modal\n const isLowBalance = variant === AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD\n\n const lowBalanceProfile = isLowBalance\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined\n const savedAmount = isLowBalance\n ? lowBalanceProfile?.threshold\n : userInsightProfile?.savings_opportunity_minimum_checking_account_balance\n\n // Mounted only while open (modal presentation), so mounting is the open: profiles are reloaded\n // here on each open, so the threshold prefills as saved now. `SettingsStore` swallows a failed\n // request, which leaves no profile for the account: the missing-profile error below covers it.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(isLowBalance)\n // False once unmounted: a save that resolves after the user closed the dialog must not close\n // (or update) whatever action session is open by then.\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n React.useEffect(() => {\n if (!isLowBalance) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [isLowBalance, settingsStore])\n\n // `null` until the user types: the field shows the saved amount until then.\n const [typed, setTyped] = React.useState<string | null>(null)\n const [isSaving, setIsSaving] = React.useState(false)\n const [saveFailed, setSaveFailed] = React.useState(false)\n\n const value = typed ?? toInputValue(savedAmount)\n\n if (isLoadingProfiles) {\n return (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n }\n\n // Copy ships separately (see the doc's Rollout order), so check every string the form renders:\n // a partial ship falls to the error dialog instead of throwing mid-render.\n const variantCopy = isAmountInputVariant(variant) ? copy?.[variant] : undefined\n const hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!copy?.whole_number_error &&\n !!copy.save_error &&\n !!commonCopy?.save_button &&\n // Cancel renders for the low-balance variant only.\n (!isLowBalance || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = isLowBalance ? !!lowBalanceProfile : !!userInsightProfile\n\n if (!copy || !variantCopy || !hasCopy || !hasProfile) {\n // One message to the user; distinct warnings so a rollout problem can be traced to its cause.\n console.warn(\n `amount_input_modal_block: ${\n !copy\n ? 'copy namespace missing'\n : !isAmountInputVariant(variant)\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : isLowBalance\n ? 'no low-balance profile for the account'\n : 'user insight profile not set by the host'\n }`,\n )\n\n return (\n <StatusDialog\n closeAriaLabel={commonCopy?.close_aria}\n heading={commonCopy?.error_heading}\n onClose={closeActionDrawer}\n >\n <Text>{commonCopy?.error_message}</Text>\n </StatusDialog>\n )\n }\n\n // Trigger 4 — user dismissed without saving (close icon, Cancel button, backdrop). Pulse\n // parity: EditThreshold.js close button / EditSafetyNet.js cancel button.\n const handleDismiss = () => {\n fireAnalyticsEvent(\n isLowBalance\n ? ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED\n : ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n )\n closeActionDrawer()\n }\n\n const isEdit = !isLowBalance && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = isWholeAmount(value)\n const isInvalid = value !== '' && !isValid\n\n const handleSave = async () => {\n // Guarded here too, not only by the disabled button: Enter submits the dialog's form directly.\n if (!isValid || isSaving) return\n\n const amount = Number(value)\n\n setIsSaving(true)\n setSaveFailed(false)\n\n // Trigger 2: save analytics ride the handler run, fired only on success.\n const ok = isLowBalance\n ? await runHandler(\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE },\n )\n : await runHandler(\n 'updateUserInsightProfile',\n { fields: { savings_opportunity_minimum_checking_account_balance: amount } },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE },\n )\n\n if (!isMounted.current) return\n\n setIsSaving(false)\n\n if (ok) closeActionDrawer()\n else setSaveFailed(true)\n }\n\n return (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n // Only strings and the <strong> go in, so the result is renderable (the helper's type also\n // admits raw DOM nodes).\n content={\n buildDynamicCopy(\n (isEdit && variantCopy.description_edit) || variantCopy.description,\n <strong key=\"account\">{accountName}</strong>,\n ) as React.ReactNode\n }\n errorText={isInvalid ? copy.whole_number_error : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={\n // Pulse fires input-selected for the threshold dialog only (EditThreshold.js); the\n // safety-net dialog has no input event.\n isLowBalance\n ? () => fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED)\n : undefined\n }\n handleModalClose={handleDismiss}\n handlePrimaryAction={() => void handleSave()}\n handleSecondaryAction={handleDismiss}\n inputLabel={variantCopy.input_label}\n inputValue={value}\n isOpen={true}\n isPrimaryDisabled={isSaving || !isValid}\n primaryText={commonCopy.save_button}\n secondaryText={isLowBalance ? commonCopy.cancel_button : undefined}\n subtitle={\n isLowBalance && beat.primary_account ? (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n {/* Decorative: the account name is the visible text beside it. */}\n <InstitutionLogo\n alt=\"\"\n institutionGuid={beat.primary_account.institution_guid ?? ''}\n size={16}\n />\n <Text color=\"text.secondary\" uppercase={true} variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n ) : undefined\n }\n title={(isEdit && variantCopy.title_edit) || variantCopy.title}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,IAAM,IAAA,CAAgB,EACpB,UAAA,GACA,gBAAA,GACA,SAAA,GACA,SAAA,EAAA,MACiG;AACjG,QAAM,IAAY,EAAM,MAAM;AAE9B,SACE,gBAAA,EAAC,IAAD;AAAA,IACE,mBAAiB,IAAU,IAAY;AAAA,IACvC,UAAS;AAAA,IACA,SAAA;AAAA,IACT,MAAM;AAAA,IAEN,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,KAAK;AAAA,QAAI,GAAG;AAAA,QAAI,UAAU;AAAA,MAAW;AAAA,MAAlD,UAAA;AAAA,QACG,KAAW,gBAAA,EAAC,IAAD;AAAA,UAAI,IAAI;AAAA,UAAY,UAAA;AAAA,QAAY,CAAA;AAAA,QAC5C,gBAAA,EAAC,IAAD;AAAA,UACE,cAAY,KAAkB;AAAA,UAC9B,SAAS;AAAA,UACT,IAAI;AAAA,YAAE,UAAU;AAAA,YAAY,OAAO;AAAA,YAAG,KAAK;AAAA,UAAG;AAAA,UAE9C,UAAA,gBAAA,EAAC,IAAD;AAAA,YAAM,MAAK;AAAA,YAAQ,IAAI,EAAE,OAAO,gBAAgB;AAAA,UAAI,CAAA;AAAA,QAC1C,CAAA;AAAA,QACX;AAAA,MAC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A;AAAA,IAEN,OAAQ,KAAU,EAAY,cAAe,EAAY;AAAA,EAC1D,CAAA;AAEL,CAAC"}
|
|
1
|
+
{"version":3,"file":"AmountInputModalBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport MuiDialog from '@mui/material/Dialog'\nimport IconButton from '@mui/material/IconButton'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n Loader,\n buildDynamicCopy,\n useGlobalCopyStore,\n useInsightsV2Store,\n useSettingsStore,\n useUserStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\nimport { CreateBudgetDialog } from './CreateBudgetDialog'\nimport {\n AMOUNT_INPUT_VARIANTS,\n CREATE_BUDGET_VARIANT,\n findLowBalanceProfile,\n isAmountInputVariant,\n isWholeAmount,\n resolveAmountInputVariant,\n toInputValue,\n} from './layout'\n\n/** Dialog frame for the formless states: loading and a non-retriable problem. */\nconst StatusDialog = ({\n children,\n closeAriaLabel,\n heading,\n onClose,\n}: React.PropsWithChildren<{ closeAriaLabel?: string; heading?: string; onClose: () => void }>) => {\n const headingId = React.useId()\n\n return (\n <MuiDialog\n aria-labelledby={heading ? headingId : undefined}\n maxWidth=\"xs\"\n onClose={onClose}\n open={true}\n >\n <Stack sx={{ gap: 12, p: 24, position: 'relative' }}>\n {heading && <H3 id={headingId}>{heading}</H3>}\n <IconButton\n aria-label={closeAriaLabel || 'Close'}\n onClick={onClose}\n sx={{ position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n {children}\n </Stack>\n </MuiDialog>\n )\n}\n\n/**\n * `amount_input_modal_block`: one whole-dollar setting in a modal, picked by the CTA variant\n * (low-balance threshold, safety net or create budget).\n */\nexport const AmountInputModalBlock = observer(function AmountInputModalBlock({\n beat,\n}: ActionBlockProps) {\n const { actionDrawer } = useInsightsV2Store()\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n // Read once on open: a refreshed beat must not swap the dialog under its snackbar.\n const [variant] = React.useState(() =>\n resolveAmountInputVariant(\n getDynamicCtaBasedOnTriggers(actionDrawer, primary_cta, secondary_cta, in_description_cta),\n ),\n )\n\n return variant === CREATE_BUDGET_VARIANT ? (\n <CreateBudgetDialog beat={beat} />\n ) : (\n <AmountSettingDialog beat={beat} variant={variant} />\n )\n})\n\n/** The low-balance threshold and safety-net settings (the two `AMOUNT_INPUT_VARIANTS`). */\nconst AmountSettingDialog = observer(function AmountSettingDialog({\n beat,\n variant,\n}: ActionBlockProps & { variant?: string }) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const settingsStore = useSettingsStore()\n const { userInsightProfile } = useUserStore()\n const runHandler = useCtaHandler(beat, useBeatActions())\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const copy = insightsFeedCopy?.amount_input_modal\n const isLowBalance = variant === AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD\n\n const lowBalanceProfile = isLowBalance\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined\n const savedAmount = isLowBalance\n ? lowBalanceProfile?.threshold\n : userInsightProfile?.savings_opportunity_minimum_checking_account_balance\n\n // Mounting is the open, so profiles reload here and the threshold prefills as saved now.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(isLowBalance)\n // False once unmounted: a save that resolves after the user closed the dialog must not close\n // (or update) whatever action session is open by then.\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n React.useEffect(() => {\n if (!isLowBalance) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [isLowBalance, settingsStore])\n\n // `null` until the user types: the field shows the saved amount until then.\n const [typed, setTyped] = React.useState<string | null>(null)\n const [isSaving, setIsSaving] = React.useState(false)\n const [saveFailed, setSaveFailed] = React.useState(false)\n\n const value = typed ?? toInputValue(savedAmount)\n\n if (isLoadingProfiles) {\n return (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n }\n\n // Copy ships separately (see the doc's Rollout order), so check every string the form renders:\n // a partial ship falls to the error dialog instead of throwing mid-render.\n const variantCopy = isAmountInputVariant(variant) ? copy?.[variant] : undefined\n const hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!copy?.whole_number_error &&\n !!copy.save_error &&\n !!commonCopy?.save_button &&\n // Cancel renders for the low-balance variant only.\n (!isLowBalance || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = isLowBalance ? !!lowBalanceProfile : !!userInsightProfile\n\n if (!copy || !variantCopy || !hasCopy || !hasProfile) {\n // One message to the user; distinct warnings so a rollout problem can be traced to its cause.\n console.warn(\n `amount_input_modal_block: ${\n !copy\n ? 'copy namespace missing'\n : !isAmountInputVariant(variant)\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : isLowBalance\n ? 'no low-balance profile for the account'\n : 'user insight profile not set by the host'\n }`,\n )\n\n return (\n <StatusDialog\n closeAriaLabel={commonCopy?.close_aria}\n heading={commonCopy?.error_heading}\n onClose={closeActionDrawer}\n >\n <Text>{commonCopy?.error_message}</Text>\n </StatusDialog>\n )\n }\n\n // Trigger 4 — user dismissed without saving (close icon, Cancel button, backdrop). Pulse\n // parity: EditThreshold.js close button / EditSafetyNet.js cancel button.\n const handleDismiss = () => {\n fireAnalyticsEvent(\n isLowBalance\n ? ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED\n : ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n )\n closeActionDrawer()\n }\n\n const isEdit = !isLowBalance && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = isWholeAmount(value)\n const isInvalid = value !== '' && !isValid\n\n const handleSave = async () => {\n // Guarded here too, not only by the disabled button: Enter submits the dialog's form directly.\n if (!isValid || isSaving) return\n\n const amount = Number(value)\n\n setIsSaving(true)\n setSaveFailed(false)\n\n // Trigger 2: save analytics ride the handler run, fired only on success.\n const ok = isLowBalance\n ? await runHandler(\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE },\n )\n : await runHandler(\n 'updateUserInsightProfile',\n { fields: { savings_opportunity_minimum_checking_account_balance: amount } },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE },\n )\n\n if (!isMounted.current) return\n\n setIsSaving(false)\n\n if (ok) closeActionDrawer()\n else setSaveFailed(true)\n }\n\n return (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n // Only strings and the <strong> go in, so the result is renderable (the helper's type also\n // admits raw DOM nodes).\n content={\n buildDynamicCopy(\n (isEdit && variantCopy.description_edit) || variantCopy.description,\n <strong key=\"account\">{accountName}</strong>,\n ) as React.ReactNode\n }\n errorText={isInvalid ? copy.whole_number_error : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={\n // Pulse fires input-selected for the threshold dialog only (EditThreshold.js); the\n // safety-net dialog has no input event.\n isLowBalance\n ? () => fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED)\n : undefined\n }\n handleModalClose={handleDismiss}\n handlePrimaryAction={() => void handleSave()}\n handleSecondaryAction={handleDismiss}\n inputLabel={variantCopy.input_label}\n inputValue={value}\n isOpen={true}\n isPrimaryDisabled={isSaving || !isValid}\n primaryText={commonCopy.save_button}\n secondaryText={isLowBalance ? commonCopy.cancel_button : undefined}\n subtitle={\n isLowBalance && beat.primary_account ? (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n {/* Decorative: the account name is the visible text beside it. */}\n <InstitutionLogo\n alt=\"\"\n institutionGuid={beat.primary_account.institution_guid ?? ''}\n size={16}\n />\n <Text color=\"text.secondary\" uppercase={true} variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n ) : undefined\n }\n title={(isEdit && variantCopy.title_edit) || variantCopy.title}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCA,IAAM,IAAA,CAAgB,EACpB,UAAA,GACA,gBAAA,GACA,SAAA,GACA,SAAA,EAAA,MACiG;AACjG,QAAM,IAAY,EAAM,MAAM;AAE9B,SACE,gBAAA,EAAC,IAAD;AAAA,IACE,mBAAiB,IAAU,IAAY;AAAA,IACvC,UAAS;AAAA,IACA,SAAA;AAAA,IACT,MAAM;AAAA,IAEN,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,KAAK;AAAA,QAAI,GAAG;AAAA,QAAI,UAAU;AAAA,MAAW;AAAA,MAAlD,UAAA;AAAA,QACG,KAAW,gBAAA,EAAC,IAAD;AAAA,UAAI,IAAI;AAAA,UAAY,UAAA;AAAA,QAAY,CAAA;AAAA,QAC5C,gBAAA,EAAC,IAAD;AAAA,UACE,cAAY,KAAkB;AAAA,UAC9B,SAAS;AAAA,UACT,IAAI;AAAA,YAAE,UAAU;AAAA,YAAY,OA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AChC,aAAa,EAAW;AAAA,IACxB,eAAe,IAAe,EAAW,gBAAgB;AAAA,IACzD,UACE,KAAgB,EAAK,kBACnB,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,YAAY;AAAA,QAAU,eAAe;AAAA,QAAO,KAAK;AAAA,MAAE;AAAA,MAAhE,UAAA,CAEE,gBAAA,EAAC,IAAD;AAAA,QACE,KAAI;AAAA,QACJ,iBAAiB,EAAK,gBAAgB,oBAAoB;AAAA,QAC1D,MAAM;AAAA,MACP,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,QAAM,OAAM;AAAA,QAAiB,WAAW;AAAA,QAAM,SAAQ;AAAA,QACnD,UAAA;AAAA,MACG,CAAA,CACD;AAAA,IACL,CAAA,IAAA;AAAA,IAEN,OAAQ,KAAU,EAAY,cAAe,EAAY;AAAA,EAC1D,CAAA;AAEL,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ActionBlockProps } from '../../mappings/blocks';
|
|
2
|
+
/** Category Spending's "Create a Budget" dialog: creates the budget, refreshes the beat, shows the result. */
|
|
3
|
+
export declare const CreateBudgetDialog: (({ beat }: ActionBlockProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { buildDynamicCopy as h } from "../../../core/utils/Localization.es.js";
|
|
2
|
+
import { useCategoryStore as I, useGlobalCopyStore as N, useInsightsV2Store as k } from "../../../common/context/hooks.es.js";
|
|
3
|
+
import { slot as F } from "../../../core/types/Insights.es.js";
|
|
4
|
+
import { formatCurrency as P } from "../../../core/utils/NumberFormatting.es.js";
|
|
5
|
+
import T from "../../../common/components/CurrencyDialog.es.js";
|
|
6
|
+
import { useBeatActions as j } from "../../beatActions.es.js";
|
|
7
|
+
import { resolveBudgetFacts as w } from "../BudgetDetailsBlock/layout.es.js";
|
|
8
|
+
import { useCtaHandler as G } from "../../ctaActions/useCtaAction.es.js";
|
|
9
|
+
import H from "../../components/shared/StatusSnackbar.es.js";
|
|
10
|
+
import e from "react";
|
|
11
|
+
import { observer as M } from "mobx-react-lite";
|
|
12
|
+
import { jsx as m, jsxs as O } from "react/jsx-runtime";
|
|
13
|
+
var R = (s) => s !== "" && Number(s) > 0, $ = M(function({ beat: i }) {
|
|
14
|
+
const { budgets: t, common: a, insights_feed: S } = N(), o = I(), { closeActionDrawer: c } = k(), v = G(i, j()), g = i.insights_payload, { categoryGuid: f = "" } = w(i), A = F(g?.instance_slot?.data, "average_amount") ?? 0, p = o.categories.find(({ guid: r }) => r === f)?.name ?? g?.subtitle ?? "", [u, x] = e.useState(""), [B, y] = e.useState(!0), [D, _] = e.useState(!1), [n, l] = e.useState(null), d = e.useRef(!0);
|
|
15
|
+
e.useEffect(() => (d.current = !0, o.categoriesLoaded || o.loadCategories(), () => {
|
|
16
|
+
d.current = !1;
|
|
17
|
+
}), [o]);
|
|
18
|
+
const C = (r) => h(r, p), b = R(u) && !D && o.categoriesLoaded, L = async () => {
|
|
19
|
+
if (!b) return;
|
|
20
|
+
_(!0);
|
|
21
|
+
const r = await v("createBudget", {
|
|
22
|
+
categoryGuid: f,
|
|
23
|
+
amount: Number(u)
|
|
24
|
+
}, { onSuccess: ["refreshBeat"] });
|
|
25
|
+
d.current && (_(!1), y(!1), l(r ? "created" : "failed"));
|
|
26
|
+
};
|
|
27
|
+
return /* @__PURE__ */ O(e.Fragment, { children: [/* @__PURE__ */ m(T, {
|
|
28
|
+
closeAriaLabel: a.close_aria,
|
|
29
|
+
content: h(t.create_budget_content, /* @__PURE__ */ m("strong", { children: p }, "category"), P(A, "0,0")),
|
|
30
|
+
handleInputChange: x,
|
|
31
|
+
handleModalClose: c,
|
|
32
|
+
handlePrimaryAction: () => {
|
|
33
|
+
L();
|
|
34
|
+
},
|
|
35
|
+
handleSecondaryAction: c,
|
|
36
|
+
inputLabel: a.amount_text,
|
|
37
|
+
inputValue: u,
|
|
38
|
+
isOpen: B,
|
|
39
|
+
isPrimaryDisabled: !b,
|
|
40
|
+
primaryText: t.dialog_primary_button_text,
|
|
41
|
+
secondaryText: a.cancel_button,
|
|
42
|
+
title: t.dialog_create_budget_title
|
|
43
|
+
}), /* @__PURE__ */ m(H, {
|
|
44
|
+
actionText: n === "failed" ? S?.general?.try_again : void 0,
|
|
45
|
+
closeAriaLabel: a.close_aria,
|
|
46
|
+
message: C(n === "created" ? t.alert_budget_created : t.alert_merchant_budget_not_created),
|
|
47
|
+
onActionClick: () => {
|
|
48
|
+
l(null), y(!0);
|
|
49
|
+
},
|
|
50
|
+
onClose: () => {
|
|
51
|
+
l(null), c();
|
|
52
|
+
},
|
|
53
|
+
open: !!n,
|
|
54
|
+
severity: n === "created" ? "success" : "error"
|
|
55
|
+
})] });
|
|
56
|
+
});
|
|
57
|
+
export {
|
|
58
|
+
$ as CreateBudgetDialog
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=CreateBudgetDialog.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateBudgetDialog.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.tsx"],"sourcesContent":["import React from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n buildDynamicCopy,\n formatCurrency,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n} from '../../../common'\nimport { slot } from '../../../core/types/Insights'\nimport StatusSnackbar from '../../components/shared/StatusSnackbar'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { resolveBudgetFacts } from '../BudgetDetailsBlock/layout'\n\ntype Notice = 'created' | 'failed'\n\nconst isPositiveAmount = (value: string) => value !== '' && Number(value) > 0\n\n/** Category Spending's \"Create a Budget\" dialog: creates the budget, refreshes the beat, shows the result. */\nexport const CreateBudgetDialog = observer(function CreateBudgetDialog({ beat }: ActionBlockProps) {\n const {\n budgets: budgetsCopy,\n common: commonCopy,\n insights_feed: insightsFeedCopy,\n } = useGlobalCopyStore()\n const categoryStore = useCategoryStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const runHandler = useCtaHandler(beat, useBeatActions())\n\n const payload = beat.insights_payload\n const { categoryGuid = '' } = resolveBudgetFacts(beat)\n const averageAmount = slot<number>(payload?.instance_slot?.data, 'average_amount') ?? 0\n const category = categoryStore.categories.find(({ guid }) => guid === categoryGuid)\n const categoryName = category?.name ?? payload?.subtitle ?? ''\n\n const [amount, setAmount] = React.useState('')\n const [isOpen, setIsOpen] = React.useState(true)\n const [isSaving, setIsSaving] = React.useState(false)\n const [notice, setNotice] = React.useState<Notice | null>(null)\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n // `createBudget` needs the category in the store.\n if (!categoryStore.categoriesLoaded) void categoryStore.loadCategories()\n\n return () => {\n isMounted.current = false\n }\n }, [categoryStore])\n\n const named = (copy: string) => buildDynamicCopy(copy, categoryName) as string\n\n const canCreate = isPositiveAmount(amount) && !isSaving && categoryStore.categoriesLoaded\n\n const handleCreate = async () => {\n if (!canCreate) return\n\n setIsSaving(true)\n const ok = await runHandler(\n 'createBudget',\n { categoryGuid, amount: Number(amount) },\n { onSuccess: ['refreshBeat'] },\n )\n if (!isMounted.current) return\n\n setIsSaving(false)\n setIsOpen(false)\n setNotice(ok ? 'created' : 'failed')\n }\n\n return (\n <React.Fragment>\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n content={\n buildDynamicCopy(\n budgetsCopy.create_budget_content,\n <strong key=\"category\">{categoryName}</strong>,\n formatCurrency(averageAmount, '0,0'),\n ) as React.ReactNode\n }\n handleInputChange={setAmount}\n handleModalClose={closeActionDrawer}\n handlePrimaryAction={() => void handleCreate()}\n handleSecondaryAction={closeActionDrawer}\n inputLabel={commonCopy.amount_text}\n inputValue={amount}\n isOpen={isOpen}\n isPrimaryDisabled={!canCreate}\n primaryText={budgetsCopy.dialog_primary_button_text}\n secondaryText={commonCopy.cancel_button}\n title={budgetsCopy.dialog_create_budget_title}\n />\n <StatusSnackbar\n actionText={notice === 'failed' ? insightsFeedCopy?.general?.try_again : undefined}\n closeAriaLabel={commonCopy.close_aria}\n message={\n notice === 'created'\n ? named(budgetsCopy.alert_budget_created)\n : named(budgetsCopy.alert_merchant_budget_not_created)\n }\n onActionClick={() => {\n setNotice(null)\n setIsOpen(true)\n }}\n onClose={() => {\n setNotice(null)\n closeActionDrawer()\n }}\n open={Boolean(notice)}\n severity={notice === 'created' ? 'success' : 'error'}\n />\n </React.Fragment>\n )\n})\n"],"mappings":";;;;;;;;;;;;AAqBA,IAAM,IAAA,CAAoB,MAAkB,MAAU,MAAM,OAAO,CAAK,IAAI,GAG/D,IAAqB,EAAS,SAA4B,EAAE,MAAA,EAAA,GAA0B;AACjG,QAAM,EACJ,SAAS,GACT,QAAQ,GACR,eAAe,EAAA,IACb,EAAmB,GACjB,IAAgB,EAAiB,GACjC,EAAE,mBAAA,EAAA,IAAsB,EAAmB,GAC3C,IAAa,EAAc,GAAM,EAAe,CAAC,GAEjD,IAAU,EAAK,kBACf,EAAE,cAAA,IAAe,GAAA,IAAO,EAAmB,CAAI,GAC/C,IAAgB,EAAa,GAAS,eAAe,MAAM,gBAAgB,KAAK,GAEhF,IADW,EAAc,WAAW,KAAA,CAAM,EAAE,MAAA,EAAA,MAAW,MAAS,CACjD,GAAU,QAAQ,GAAS,YAAY,IAEtD,CAAC,GAAQ,CAAA,IAAa,EAAM,SAAS,EAAE,GACvC,CAAC,GAAQ,CAAA,IAAa,EAAM,SAAS,EAAI,GACzC,CAAC,GAAU,CAAA,IAAe,EAAM,SAAS,EAAK,GAC9C,CAAC,GAAQ,CAAA,IAAa,EAAM,SAAwB,IAAI,GACxD,IAAY,EAAM,OAAO,EAAI;AAEnC,EAAA,EAAM,UAAA,OACJ,EAAU,UAAU,IAEf,EAAc,oBAAkB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AA,IAChB;AAAA,IACA,SAAA,MAAe;AACb,MAAA,EAAU,IAAI,GACd,EAAkB;AAAA,IACpB;AAAA,IACA,MAAM,EAAQ;AAAA,IACd,UAAU,MAAW,YAAY,YAAY;AAAA,EAC9C,CAAA,CACa,EAAA,CAAA;AAEpB,CAAC"}
|
|
@@ -4,14 +4,10 @@ export declare const AMOUNT_INPUT_VARIANTS: {
|
|
|
4
4
|
readonly LOW_BALANCE_THRESHOLD: "low_balance_threshold";
|
|
5
5
|
readonly SAFETY_NET: "safety_net";
|
|
6
6
|
};
|
|
7
|
+
export declare const CREATE_BUDGET_VARIANT = "create_budget";
|
|
7
8
|
export type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS];
|
|
8
9
|
export declare const isAmountInputVariant: (variant?: string | null) => variant is AmountInputVariant;
|
|
9
|
-
/**
|
|
10
|
-
* The variant the modal edits, from the CTA that opened it. ditto drives the shared
|
|
11
|
-
* `amount_input_modal_block` by an explicit CTA variant, but gives Savings Opportunity's safety-net
|
|
12
|
-
* reminder a dedicated `safety_net_block` with no variant, so there the block name selects it. An
|
|
13
|
-
* explicit variant always wins (so an unknown one still falls to the block's "unknown variant" path).
|
|
14
|
-
*/
|
|
10
|
+
/** The variant to edit: the CTA's, else `safety_net` for the dedicated `safety_net_block`. */
|
|
15
11
|
export declare const resolveAmountInputVariant: (cta?: {
|
|
16
12
|
block?: string | null;
|
|
17
13
|
variant?: string | null;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { AccountNotificationTypes as
|
|
2
|
-
import { actionBlocksKey as
|
|
3
|
-
var
|
|
1
|
+
import { AccountNotificationTypes as a } from "../../../core/types/Notification.es.js";
|
|
2
|
+
import { actionBlocksKey as o } from "../../mappings/actionBlocksKey.es.js";
|
|
3
|
+
var e = {
|
|
4
4
|
LOW_BALANCE_THRESHOLD: "low_balance_threshold",
|
|
5
5
|
SAFETY_NET: "safety_net"
|
|
6
|
-
}, T = (t) => Object.values(
|
|
6
|
+
}, T = "create_budget", u = (t) => Object.values(e).includes(t ?? ""), N = (t) => {
|
|
7
7
|
if (t?.variant) return t.variant;
|
|
8
|
-
if (t?.block ===
|
|
9
|
-
},
|
|
8
|
+
if (t?.block === o.SAFETY_NET_ACTION_BLOCK) return e.SAFETY_NET;
|
|
9
|
+
}, i = 1e9, c = (t) => /^\d+$/.test(t) && Number(t) >= 1 && Number(t) <= i, v = (t) => t ? String(Math.round(t)) : "", E = (t, r) => r ? t.find((n) => n.entity_guid === r && n.notification_type === a.AccountBalanceLow) : void 0;
|
|
10
10
|
export {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
e as AMOUNT_INPUT_VARIANTS,
|
|
12
|
+
T as CREATE_BUDGET_VARIANT,
|
|
13
|
+
E as findLowBalanceProfile,
|
|
14
|
+
u as isAmountInputVariant,
|
|
15
|
+
c as isWholeAmount,
|
|
16
|
+
N as resolveAmountInputVariant,
|
|
17
|
+
v as toInputValue
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
//# sourceMappingURL=layout.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/layout.ts"],"sourcesContent":["import type { NotificationProfile } from '../../../core'\nimport { AccountNotificationTypes } from '../../../core/types/Notification'\nimport { actionBlocksKey } from '../../mappings/actionBlocksKey'\n\n/** CTA variants `amount_input_modal_block` serves (ditto sets one on the beat's CTA). */\nexport const AMOUNT_INPUT_VARIANTS = {\n LOW_BALANCE_THRESHOLD: 'low_balance_threshold',\n SAFETY_NET: 'safety_net',\n} as const\n\nexport type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS]\n\nexport const isAmountInputVariant = (variant?: string | null): variant is AmountInputVariant =>\n Object.values<string>(AMOUNT_INPUT_VARIANTS).includes(variant ?? '')\n\n
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/layout.ts"],"sourcesContent":["import type { NotificationProfile } from '../../../core'\nimport { AccountNotificationTypes } from '../../../core/types/Notification'\nimport { actionBlocksKey } from '../../mappings/actionBlocksKey'\n\n/** CTA variants `amount_input_modal_block` serves (ditto sets one on the beat's CTA). */\nexport const AMOUNT_INPUT_VARIANTS = {\n LOW_BALANCE_THRESHOLD: 'low_balance_threshold',\n SAFETY_NET: 'safety_net',\n} as const\n\nexport const CREATE_BUDGET_VARIANT = 'create_budget'\n\nexport type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS]\n\nexport const isAmountInputVariant = (variant?: string | null): variant is AmountInputVariant =>\n Object.values<string>(AMOUNT_INPUT_VARIANTS).includes(variant ?? '')\n\n/** The variant to edit: the CTA's, else `safety_net` for the dedicated `safety_net_block`. */\nexport const resolveAmountInputVariant = (cta?: {\n block?: string | null\n variant?: string | null\n}): string | undefined => {\n if (cta?.variant) return cta.variant\n if (cta?.block === actionBlocksKey.SAFETY_NET_ACTION_BLOCK)\n return AMOUNT_INPUT_VARIANTS.SAFETY_NET\n return undefined\n}\n\n/** Pulse v1's upper bound for a safety net; applied to both variants. */\nconst MAX_AMOUNT = 1_000_000_000\n\n/** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for both settings. */\nexport const isWholeAmount = (value: string): boolean =>\n /^\\d+$/.test(value) && Number(value) >= 1 && Number(value) <= MAX_AMOUNT\n\n/** A saved amount as the field's starting text; nothing saved (or zero) starts empty. */\nexport const toInputValue = (amount?: number | null): string =>\n amount ? String(Math.round(amount)) : ''\n\n/** The account's low-balance alert profile, which holds the threshold (as pulse v1 looked it up). */\nexport const findLowBalanceProfile = (\n profiles: NotificationProfile[],\n accountGuid?: string | null,\n): NotificationProfile | undefined =>\n accountGuid\n ? profiles.find(\n (profile) =>\n profile.entity_guid === accountGuid &&\n profile.notification_type === AccountNotificationTypes.AccountBalanceLow,\n )\n : undefined\n"],"mappings":";;AAKA,IAAa,IAAwB;AAAA,EACnC,uBAAuB;AAAA,EACvB,YAAY;AACd,GAEa,IAAwB,iBAIxB,IAAA,CAAwB,MACnC,OAAO,OAAe,CAAqB,EAAE,SAAS,KAAW,EAAE,GAGxD,IAAA,CAA6B,MAGhB;AACxB,MAAI,GAAK,QAAS,QAAO,EAAI;AAC7B,MAAI,GAAK,UAAU,EAAgB,wBACjC,QAAO,EAAsB;AAEjC,GAGM,IAAa,KAGN,IAAA,CAAiB,MAC5B,QAAQ,KAAK,CAAK,KAAK,OAAO,CAAK,KAAK,KAAK,OAAO,CAAK,KAAK,GAGnD,IAAA,CAAgB,MAC3B,IAAS,OAAO,KAAK,MAAM,CAAM,CAAC,IAAI,IAG3B,IAAA,CACX,GACA,MAEA,IACI,EAAS,KAAA,CACN,MACC,EAAQ,gBAAgB,KACxB,EAAQ,sBAAsB,EAAyB,iBAC3D,IACA"}
|
|
@@ -1,130 +1,160 @@
|
|
|
1
|
-
import { buildDynamicCopy as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { buildDynamicCopy as W } from "../../../core/utils/Localization.es.js";
|
|
2
|
+
import { DATE_FORMATS_INTL as ae, formatDate as ie } from "../../../core/constants/DateFormats.es.js";
|
|
3
|
+
import { useBudgetsStore as ne, useCategoryStore as se, useGlobalCopyStore as de, useGlobalStore as ce, useTransactionStore as le } from "../../../common/context/hooks.es.js";
|
|
4
|
+
import { getCategoryColor as Y } from "../../../core/utils/CategoryUtil.es.js";
|
|
5
|
+
import ue from "../../../common/components/Loader.es.js";
|
|
6
|
+
import me from "../../../common/components/CurrencyDialog.es.js";
|
|
7
|
+
import ge from "../../../transactions/components/shared/TransactionList.es.js";
|
|
8
|
+
import { budgetMonthOf as _e, budgetTransactionFilter as fe, daysLeftInBudgetMonth as ye, resolveBudgetFacts as pe } from "./layout.es.js";
|
|
9
|
+
import { ANALYTICS_EVENTS_CONFIG as x } from "../../analytics/analyticsEventsConfig.es.js";
|
|
10
|
+
import { useAnalyticsEvent as he } from "../../analytics/useAnalyticsEvent.es.js";
|
|
11
|
+
import be from "../../components/shared/StatusSnackbar.es.js";
|
|
12
|
+
import { ExportCsvButton as Te } from "../../components/ExportCsvButton.es.js";
|
|
13
|
+
import { BudgetSummary as Be } from "./BudgetSummary.es.js";
|
|
14
|
+
import { useEffect as xe, useRef as Ce, useState as C } from "react";
|
|
15
|
+
import { observer as De } from "mobx-react-lite";
|
|
16
|
+
import D from "@mui/material/Stack";
|
|
17
|
+
import { CategoryIcon as Ee, MerchantLogo as Se, Text as M } from "@mxenabled/mxui";
|
|
18
|
+
import w from "@mui/material/Button";
|
|
19
|
+
import { jsx as r, jsxs as F } from "react/jsx-runtime";
|
|
20
|
+
import { alpha as ve, useTheme as Ge } from "@mui/material/styles";
|
|
21
|
+
import Le from "@mui/material/Box";
|
|
22
|
+
import ke from "@mui/material/Skeleton";
|
|
23
|
+
var et = De(function({ beat: g }) {
|
|
24
|
+
const I = Ge(), { copyStore: H, emitUpdate: $ } = ce(), { budgets: e, common: l, insights_feed: N } = de(), i = ne(), u = se(), f = le(), y = he(), [q, J] = C(!1), [a, E] = C(null), [p, h] = C(""), [s, _] = C(null), S = Ce(!1), O = N?.budget_details, { categories: K } = u, Q = i.isDataLoaded && u.categoriesLoaded;
|
|
25
|
+
if (xe(() => {
|
|
26
|
+
Promise.allSettled([i.isDataLoaded || i.loadBudgets(), u.categoriesLoaded || u.loadCategories()]).then(() => J(!(i.isDataLoaded && u.categoriesLoaded))), f.isTransactionDataLoaded || f.loadMissingTransactionData();
|
|
27
|
+
}, [
|
|
28
|
+
i,
|
|
29
|
+
u,
|
|
30
|
+
f
|
|
31
|
+
]), !H.isInitialized) return /* @__PURE__ */ r(ue, {});
|
|
32
|
+
if (!O) return /* @__PURE__ */ r(D, {
|
|
23
33
|
sx: { p: 24 },
|
|
24
|
-
children: /* @__PURE__ */ r(
|
|
34
|
+
children: /* @__PURE__ */ r(M, { children: l?.error_message })
|
|
25
35
|
});
|
|
26
|
-
const o =
|
|
36
|
+
const o = pe(g), b = o.categoryGuid ? K.find(({ guid: t }) => t === o.categoryGuid) : void 0, d = o.categoryGuid ? i.budgets.find(({ category_guid: t }) => t === o.categoryGuid) : void 0, c = !o.categoryGuid && o.merchantGuid ? i.getMerchantBudgetByMerchantGuid(o.merchantGuid) : void 0, U = b?.name ?? c?.merchant_name ?? g.payload?.merchant_name ?? "", j = d?.amount ?? c?.amount ?? o.budgeted ?? 0, X = o.spent ?? d?.transaction_total ?? c?.transaction_total ?? 0, Z = o.categoryGuid ? /* @__PURE__ */ r(Ee, {
|
|
27
37
|
categoryGuid: o.categoryGuid,
|
|
28
38
|
size: 44,
|
|
29
39
|
sx: {
|
|
30
|
-
bgcolor:
|
|
31
|
-
border: `1px solid ${
|
|
40
|
+
bgcolor: ve(Y(o.categoryGuid, I), 0.15),
|
|
41
|
+
border: `1px solid ${Y(o.categoryGuid, I)}`,
|
|
32
42
|
color: "text.primary"
|
|
33
43
|
}
|
|
34
|
-
}) : /* @__PURE__ */ r(
|
|
44
|
+
}) : /* @__PURE__ */ r(Se, {
|
|
35
45
|
categoryGuid: "",
|
|
36
46
|
merchantGuid: o.merchantGuid ?? "",
|
|
37
47
|
size: 44
|
|
38
|
-
}),
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
|
|
48
|
+
}), R = _e(g), T = f.detailedTransactions.filter(fe(o, R)), v = (t) => {
|
|
49
|
+
t === "delete" && y(x.BUDGET_DELETE_START), h(t === "edit" ? String(j) : ""), E(t);
|
|
50
|
+
}, z = () => {
|
|
51
|
+
E(null), h("");
|
|
52
|
+
}, P = () => {
|
|
53
|
+
a === "delete" && y(x.BUDGET_DELETE_CANCEL), z();
|
|
54
|
+
}, n = (t) => W(t, U), B = (t) => n({
|
|
55
|
+
create: e.alert_merchant_budget_not_created,
|
|
56
|
+
edit: e.error_alert_edit_merchant_budget,
|
|
57
|
+
delete: e.error_alert_delete_merchant_budget
|
|
58
|
+
}[t]), ee = async (t, m) => {
|
|
59
|
+
if (c) {
|
|
44
60
|
if (t === "delete") {
|
|
45
|
-
const { isSuccess:
|
|
61
|
+
const { isSuccess: A } = await i.deleteMerchantBudget(c.guid);
|
|
46
62
|
return {
|
|
47
|
-
ok:
|
|
48
|
-
success:
|
|
49
|
-
failure:
|
|
63
|
+
ok: A,
|
|
64
|
+
success: n(e.success_alert_delete_merchant_budget),
|
|
65
|
+
failure: n(e.error_alert_delete_merchant_budget)
|
|
50
66
|
};
|
|
51
67
|
}
|
|
52
|
-
const { isSuccess:
|
|
53
|
-
...
|
|
54
|
-
amount:
|
|
68
|
+
const { isSuccess: k } = await i.updateMerchantBudget({
|
|
69
|
+
...c,
|
|
70
|
+
amount: m
|
|
55
71
|
});
|
|
56
72
|
return {
|
|
57
|
-
ok:
|
|
58
|
-
success:
|
|
59
|
-
failure:
|
|
73
|
+
ok: k,
|
|
74
|
+
success: n(e.success_alert_edit_merchant_budget),
|
|
75
|
+
failure: n(e.error_alert_edit_merchant_budget)
|
|
60
76
|
};
|
|
61
77
|
}
|
|
62
|
-
return t === "delete" &&
|
|
63
|
-
ok: await
|
|
64
|
-
success:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
78
|
+
return t === "delete" && d ? {
|
|
79
|
+
ok: await i.deleteBudget(d.guid),
|
|
80
|
+
success: n(e.alert_budget_deleted),
|
|
81
|
+
failure: B(t)
|
|
82
|
+
} : t === "edit" && d ? {
|
|
83
|
+
ok: await i.updateBudget({
|
|
84
|
+
...d,
|
|
85
|
+
amount: m
|
|
69
86
|
}),
|
|
70
|
-
success:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
87
|
+
success: n(e.alert_budget_updated),
|
|
88
|
+
failure: B(t)
|
|
89
|
+
} : t === "create" && b ? {
|
|
90
|
+
ok: await i.addBudget(b, m),
|
|
91
|
+
success: n(e.alert_budget_created),
|
|
92
|
+
failure: B(t)
|
|
74
93
|
} : {
|
|
75
94
|
ok: !1,
|
|
76
95
|
success: ""
|
|
77
96
|
};
|
|
78
|
-
},
|
|
79
|
-
if (
|
|
80
|
-
const t = Number(
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
}, te = async () => {
|
|
98
|
+
if (S.current || !a) return;
|
|
99
|
+
const t = Number(p);
|
|
100
|
+
if (a !== "delete" && !(Number.isFinite(t) && t > 0)) return;
|
|
101
|
+
S.current = !0;
|
|
102
|
+
const m = {
|
|
103
|
+
action: a,
|
|
104
|
+
amount: p
|
|
105
|
+
};
|
|
106
|
+
try {
|
|
107
|
+
const { ok: k, success: A, failure: oe } = await ee(a, t);
|
|
108
|
+
k ? ($({ staleBeatGuid: g.guid }), a === "edit" && y({
|
|
109
|
+
...x.BUDGET_EDIT_SAVE,
|
|
110
|
+
value: p
|
|
111
|
+
}), a === "delete" && y(x.BUDGET_DELETE_END), _({
|
|
112
|
+
message: A,
|
|
113
|
+
severity: "success"
|
|
114
|
+
})) : _({
|
|
115
|
+
message: oe ?? l.error_message,
|
|
116
|
+
severity: "error",
|
|
117
|
+
retry: m
|
|
118
|
+
});
|
|
119
|
+
} catch {
|
|
120
|
+
_({
|
|
121
|
+
message: B(a),
|
|
122
|
+
severity: "error",
|
|
123
|
+
retry: m
|
|
124
|
+
});
|
|
125
|
+
} finally {
|
|
126
|
+
S.current = !1, z();
|
|
97
127
|
}
|
|
98
|
-
},
|
|
128
|
+
}, V = !!(d ?? c), re = q ? /* @__PURE__ */ r(M, {
|
|
99
129
|
color: "text.secondary",
|
|
100
130
|
variant: "body2",
|
|
101
|
-
children:
|
|
102
|
-
}) :
|
|
131
|
+
children: l.error_message
|
|
132
|
+
}) : Q ? V ? /* @__PURE__ */ F(D, {
|
|
103
133
|
sx: {
|
|
104
134
|
flexDirection: "row",
|
|
105
135
|
gap: 12
|
|
106
136
|
},
|
|
107
|
-
children: [/* @__PURE__ */ r(
|
|
137
|
+
children: [/* @__PURE__ */ r(w, {
|
|
108
138
|
fullWidth: !0,
|
|
109
|
-
onClick: () =>
|
|
139
|
+
onClick: () => v("edit"),
|
|
110
140
|
variant: "outlined",
|
|
111
141
|
children: e.details_edit_button
|
|
112
|
-
}), /* @__PURE__ */ r(
|
|
142
|
+
}), /* @__PURE__ */ r(w, {
|
|
113
143
|
color: "error",
|
|
114
144
|
fullWidth: !0,
|
|
115
|
-
onClick: () =>
|
|
145
|
+
onClick: () => v("delete"),
|
|
116
146
|
variant: "outlined",
|
|
117
147
|
children: e.details_delete_button
|
|
118
148
|
})]
|
|
119
|
-
}) : !
|
|
149
|
+
}) : !V && b ? /* @__PURE__ */ r(w, {
|
|
120
150
|
fullWidth: !0,
|
|
121
|
-
onClick: () =>
|
|
151
|
+
onClick: () => v("create"),
|
|
122
152
|
variant: "contained",
|
|
123
153
|
children: e.dialog_primary_button_text
|
|
124
|
-
}) : null : /* @__PURE__ */ r(
|
|
154
|
+
}) : null : /* @__PURE__ */ r(ke, {
|
|
125
155
|
height: 40,
|
|
126
156
|
variant: "rounded"
|
|
127
|
-
}),
|
|
157
|
+
}), G = a === "delete", L = {
|
|
128
158
|
create: {
|
|
129
159
|
content: e.add_description_bottom,
|
|
130
160
|
primaryText: e.dialog_primary_button_text,
|
|
@@ -141,52 +171,75 @@ var we = ne(function({ beat: _ }) {
|
|
|
141
171
|
title: e.delete_title
|
|
142
172
|
}
|
|
143
173
|
};
|
|
144
|
-
return /* @__PURE__ */
|
|
174
|
+
return /* @__PURE__ */ F(D, {
|
|
145
175
|
sx: {
|
|
146
176
|
bgcolor: "background.paper",
|
|
147
177
|
gap: 24,
|
|
148
178
|
p: 24
|
|
149
179
|
},
|
|
150
180
|
children: [
|
|
151
|
-
/* @__PURE__ */
|
|
181
|
+
/* @__PURE__ */ F(D, {
|
|
182
|
+
sx: {
|
|
183
|
+
alignItems: "center",
|
|
184
|
+
flexDirection: "row",
|
|
185
|
+
justifyContent: "space-between"
|
|
186
|
+
},
|
|
187
|
+
children: [/* @__PURE__ */ r(M, {
|
|
188
|
+
bold: !0,
|
|
189
|
+
variant: "body1",
|
|
190
|
+
children: ie(R, ae.MONTH_YEAR)
|
|
191
|
+
}), T.length > 0 && /* @__PURE__ */ r(Te, { transactions: T })]
|
|
192
|
+
}),
|
|
193
|
+
/* @__PURE__ */ r(Be, {
|
|
152
194
|
budgetsCopy: e,
|
|
153
|
-
copy:
|
|
154
|
-
daysLeft:
|
|
155
|
-
icon:
|
|
156
|
-
limit:
|
|
157
|
-
spent:
|
|
195
|
+
copy: O,
|
|
196
|
+
daysLeft: ye(g),
|
|
197
|
+
icon: Z,
|
|
198
|
+
limit: j,
|
|
199
|
+
spent: X
|
|
158
200
|
}),
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
closeAriaLabel:
|
|
162
|
-
content:
|
|
163
|
-
handleInputChange:
|
|
164
|
-
handleModalClose:
|
|
201
|
+
re,
|
|
202
|
+
a && /* @__PURE__ */ r(me, {
|
|
203
|
+
closeAriaLabel: l.close_aria,
|
|
204
|
+
content: W(L[a].content, /* @__PURE__ */ r("b", { children: U })),
|
|
205
|
+
handleInputChange: h,
|
|
206
|
+
handleModalClose: P,
|
|
165
207
|
handlePrimaryAction: () => {
|
|
166
|
-
|
|
208
|
+
te();
|
|
167
209
|
},
|
|
168
|
-
handleSecondaryAction:
|
|
169
|
-
inputLabel:
|
|
170
|
-
inputValue:
|
|
210
|
+
handleSecondaryAction: P,
|
|
211
|
+
inputLabel: G ? void 0 : e.add_label,
|
|
212
|
+
inputValue: p,
|
|
171
213
|
isOpen: !0,
|
|
172
|
-
primaryColor:
|
|
173
|
-
primaryText:
|
|
174
|
-
secondaryColor:
|
|
175
|
-
secondaryText:
|
|
176
|
-
title:
|
|
214
|
+
primaryColor: G ? "error" : "primary",
|
|
215
|
+
primaryText: L[a].primaryText,
|
|
216
|
+
secondaryColor: G ? "inherit" : "primary",
|
|
217
|
+
secondaryText: l.cancel_button,
|
|
218
|
+
title: L[a].title
|
|
177
219
|
}),
|
|
178
|
-
/* @__PURE__ */ r(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
220
|
+
T.length > 0 && /* @__PURE__ */ r(Le, {
|
|
221
|
+
sx: {
|
|
222
|
+
bgcolor: "background.default",
|
|
223
|
+
mx: -24
|
|
224
|
+
},
|
|
225
|
+
children: /* @__PURE__ */ r(ge, { transaction: T })
|
|
226
|
+
}),
|
|
227
|
+
/* @__PURE__ */ r(be, {
|
|
228
|
+
actionText: s?.retry ? N?.general?.try_again : void 0,
|
|
229
|
+
closeAriaLabel: l.close_aria,
|
|
230
|
+
message: s?.message ?? "",
|
|
231
|
+
onActionClick: () => {
|
|
232
|
+
s?.retry && (h(s.retry.amount), E(s.retry.action), _(null));
|
|
233
|
+
},
|
|
234
|
+
onClose: () => _(null),
|
|
235
|
+
open: !!s,
|
|
236
|
+
severity: s?.severity
|
|
184
237
|
})
|
|
185
238
|
]
|
|
186
239
|
});
|
|
187
240
|
});
|
|
188
241
|
export {
|
|
189
|
-
|
|
242
|
+
et as BudgetDetailsBlock
|
|
190
243
|
};
|
|
191
244
|
|
|
192
245
|
//# sourceMappingURL=BudgetDetailsBlock.es.js.map
|