@burdenoff/microfe-subscriberbot 2026.1107.5 → 2026.1107.6
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/dist/stories/pages/BankConnectionsPage.stories.d.ts +2 -0
- package/dist/stories/pages/BankConnectionsPage.stories.d.ts.map +1 -1
- package/dist/stories/support/bankingFixtures.d.ts.map +1 -1
- package/dist/subscriberbot/hooks/useBankingApi.d.ts +1 -0
- package/dist/subscriberbot/hooks/useBankingApi.d.ts.map +1 -1
- package/dist/subscriberbot/hooks/useBankingApi.js +3 -3
- package/dist/subscriberbot/hooks/useBankingApi.js.map +1 -1
- package/dist/subscriberbot/pages/banking/BankConnectionsPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/banking/BankConnectionsPage.js +402 -299
- package/dist/subscriberbot/pages/banking/BankConnectionsPage.js.map +1 -1
- package/dist/subscriberbot/pages/banking/ConnectBankModal.d.ts +17 -0
- package/dist/subscriberbot/pages/banking/ConnectBankModal.d.ts.map +1 -0
- package/dist/subscriberbot/pages/banking/ConnectBankModal.js +156 -0
- package/dist/subscriberbot/pages/banking/ConnectBankModal.js.map +1 -0
- package/dist/subscriberbot/types/banking.d.ts +12 -1
- package/dist/subscriberbot/types/banking.d.ts.map +1 -1
- package/dist/subscriberbot/utils/bankRedirectLink.d.ts +27 -0
- package/dist/subscriberbot/utils/bankRedirectLink.d.ts.map +1 -0
- package/dist/subscriberbot/utils/bankRedirectLink.js +68 -0
- package/dist/subscriberbot/utils/bankRedirectLink.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BankConnectionsPage.js","names":[],"sources":["../../../../src/subscriberbot/pages/banking/BankConnectionsPage.tsx"],"sourcesContent":["import { useFormError } from '../../hooks/useFormError';\nimport { useFormatters } from '../../hooks/useFormatters';\n/**\n * Bank & card connections\n * @module subscriberbot/pages/banking\n *\n * `/subscriberbot/banking` — link a bank or card through Plaid, or import a\n * statement export (CSV) from any bank, and review the recurring charges\n * Subscriber Bot found in the transactions: track each as a subscription or\n * dismiss it (BOFF-4161). Everything here belongs to the signed-in user only.\n */\n\nimport { useMemo, useState, type FormEvent } from 'react';\nimport {\n CalendarClock,\n FileUp,\n Landmark,\n Link2,\n RefreshCw,\n Repeat,\n ShieldCheck,\n Trash2,\n} from 'lucide-react';\nimport { PagePurpose } from '@burdenoff/fe-libs/ui';\nimport {\n EmptyState,\n ErrorView,\n LoadingView,\n MetricsCard,\n Modal,\n PageLayout,\n Section,\n StatusBadge,\n} from '../../components';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport {\n useBankAggregators,\n useBankConnections,\n useCompleteBankLink,\n useCreateBankLinkSession,\n useDismissRecurringCharge,\n useImportBankStatement,\n useRecurringCharges,\n useRemoveBankConnection,\n useRestoreRecurringCharge,\n useSyncBankConnection,\n useTrackRecurringCharge,\n} from '../../hooks/useBankingApi';\nimport { useTr } from '../../hooks/useTr';\nimport { cn } from '../../utils/cn';\n\nimport { openPlaidLink } from '../../utils/plaidLink';\nimport type {\n SubBankConnection,\n SubBankSyncResult,\n SubRecurringCharge,\n SubRecurringChargeStatus,\n SubStatementAmountConvention,\n SubStatementDateFormat,\n} from '../../types/banking';\n\nconst inputCls =\n 'w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\nconst primaryBtn =\n 'inline-flex items-center gap-2 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50';\nconst secondaryBtn =\n 'inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50';\nconst smallBtn =\n 'inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-2.5 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50';\n\nconst CHARGE_FILTERS: SubRecurringChargeStatus[] = ['DETECTED', 'TRACKED', 'DISMISSED'];\nconst CHARGE_FILTER_LABEL: Record<SubRecurringChargeStatus, { key: string; fallback: string }> = {\n DETECTED: { key: 'banking.charges.detected', fallback: 'To review' },\n TRACKED: { key: 'banking.charges.tracked', fallback: 'Tracked' },\n DISMISSED: { key: 'banking.charges.dismissed', fallback: 'Dismissed' },\n};\nconst MAX_FILE_BYTES = 2_000_000;\n\nconst errorText = (error: unknown, tr: ReturnType<typeof useTr>): string =>\n error instanceof Error ? error.message : tr('common.somethingWentWrong', 'Something went wrong');\n\ninterface Notice {\n tone: 'success' | 'error';\n text: string;\n}\n\nexport function BankConnectionsPage() {\n const { formatCurrency, formatDate, formatIntervalSuffix } = useFormatters();\n\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const [filter, setFilter] = useState<SubRecurringChargeStatus>('DETECTED');\n const [importOpen, setImportOpen] = useState(false);\n const [notice, setNotice] = useState<Notice | null>(null);\n const [linking, setLinking] = useState(false);\n\n const aggregators = useBankAggregators();\n const connections = useBankConnections();\n const charges = useRecurringCharges(filter);\n const detected = useRecurringCharges('DETECTED');\n const tracked = useRecurringCharges('TRACKED');\n\n const createLink = useCreateBankLinkSession();\n const completeLink = useCompleteBankLink();\n const sync = useSyncBankConnection();\n const remove = useRemoveBankConnection();\n const track = useTrackRecurringCharge();\n const dismiss = useDismissRecurringCharge();\n const restore = useRestoreRecurringCharge();\n\n const plaid = aggregators.data?.find((a) => a.aggregator === 'PLAID');\n const connectionItems = connections.data?.items ?? [];\n const chargeItems = charges.data?.items ?? [];\n\n const detectedYearly = useMemo(() => {\n const totals = new Map<string, number>();\n for (const c of detected.data?.items ?? []) {\n totals.set(c.currency, (totals.get(c.currency) ?? 0) + c.annualCost);\n }\n return [...totals.entries()]\n .map(([currency, amount]) => formatCurrency(amount, currency))\n .join(' + ');\n }, [detected.data, formatCurrency]);\n\n const summarise = (result: SubBankSyncResult): string =>\n tr(\n 'banking.notice.synced',\n '{{added}} new transaction(s) from {{institution}}; {{recurring}} recurring charge(s) found.',\n {\n added: result.added,\n institution: result.connection.institutionName,\n recurring: result.recurringDetected,\n }\n );\n\n const connectBank = async () => {\n setNotice(null);\n setLinking(true);\n try {\n const session = await createLink.mutateAsync({ aggregator: 'PLAID' });\n const linked = await openPlaidLink(session.linkToken, tr);\n if (!linked) return;\n const result = await completeLink.mutateAsync({\n input: {\n aggregator: 'PLAID',\n publicToken: linked.publicToken,\n institutionId: linked.institutionId,\n institutionName: linked.institutionName,\n },\n });\n setNotice({ tone: 'success', text: summarise(result) });\n } catch (error) {\n setNotice({ tone: 'error', text: errorText(error, tr) });\n } finally {\n setLinking(false);\n }\n };\n\n // Update mode (BOFF-10810): the customer signs in to the bank again for an\n // existing connection, then a sync moves it back to ACTIVE with its history.\n const reconnect = async (connection: SubBankConnection) => {\n setNotice(null);\n setLinking(true);\n try {\n const session = await createLink.mutateAsync({\n aggregator: 'PLAID',\n connectionId: connection.id,\n });\n const linked = await openPlaidLink(session.linkToken, tr);\n if (!linked) return;\n setNotice({\n tone: 'success',\n text: summarise(await sync.mutateAsync({ id: connection.id })),\n });\n } catch (error) {\n setNotice({ tone: 'error', text: errorText(error, tr) });\n } finally {\n setLinking(false);\n }\n };\n\n const runSync = async (connection: SubBankConnection) => {\n setNotice(null);\n try {\n setNotice({\n tone: 'success',\n text: summarise(await sync.mutateAsync({ id: connection.id })),\n });\n } catch (error) {\n setNotice({ tone: 'error', text: errorText(error, tr) });\n }\n };\n\n const disconnect = async (connection: SubBankConnection) => {\n const confirmed = window.confirm(\n tr(\n 'banking.disconnect.confirm',\n 'Disconnect {{institution}}? Its accounts and transactions are deleted from Subscriber Bot. Subscriptions you already track stay.',\n { institution: connection.institutionName }\n )\n );\n if (!confirmed) return;\n setNotice(null);\n try {\n await remove.mutateAsync({ id: connection.id });\n setNotice({\n tone: 'success',\n text: tr('banking.notice.disconnected', '{{institution}} was disconnected.', {\n institution: connection.institutionName,\n }),\n });\n } catch (error) {\n setNotice({ tone: 'error', text: errorText(error, tr) });\n }\n };\n\n const decide = async (action: 'track' | 'dismiss' | 'restore', charge: SubRecurringCharge) => {\n setNotice(null);\n try {\n const mutation = { track, dismiss, restore }[action];\n const updated = await mutation.mutateAsync({ id: charge.id });\n if (action === 'track') {\n setNotice({\n tone: 'success',\n text: tr('banking.notice.tracked', '{{name}} is now tracked as a subscription.', {\n name: updated.displayName,\n }),\n });\n }\n } catch (error) {\n setNotice({ tone: 'error', text: errorText(error, tr) });\n }\n };\n\n const actions = (\n <div className=\"flex flex-wrap gap-2\" data-tour=\"subscriberbot-banking-connect\">\n <button type=\"button\" className={secondaryBtn} onClick={() => setImportOpen(true)}>\n <FileUp className=\"h-4 w-4\" aria-hidden /> {tr('banking.import.open', 'Import a statement')}\n </button>\n <button\n type=\"button\"\n className={primaryBtn}\n onClick={() => void connectBank()}\n disabled={!plaid?.available || linking}\n title={\n plaid?.available\n ? undefined\n : tr(\n 'banking.plaid.unavailable',\n 'Bank linking is not switched on yet. Import a statement instead.'\n )\n }\n >\n <Link2 className=\"h-4 w-4\" aria-hidden />\n {linking\n ? tr('banking.plaid.linking', 'Connecting…')\n : tr('banking.plaid.connect', 'Connect a bank')}\n </button>\n </div>\n );\n\n return (\n <PageLayout\n dataTour=\"subscriberbot-banking\"\n title={tr('banking.title', 'Bank & card connections')}\n description={tr(\n 'banking.description',\n 'Find every subscription in your bank and card transactions.'\n )}\n actions={actions}\n >\n <PagePurpose className=\"mb-6\">\n {tr(\n 'banking.purpose',\n 'Connect a US bank or card through Plaid, or import the CSV export any bank lets you download. Subscriber Bot spots the charges that repeat every week, month, quarter or year so you can track them or wave them off. Your bank password is never shared with Subscriber Bot, and only you can see these accounts.'\n )}\n </PagePurpose>\n\n {plaid && !plaid.available && (\n <p\n className=\"mb-4 flex items-start gap-2 rounded-lg border border-border-subtle bg-bg-sunken px-3 py-2 text-sm text-text-secondary\"\n data-testid=\"plaid-unavailable\"\n >\n <ShieldCheck className=\"mt-0.5 h-4 w-4 shrink-0\" aria-hidden />\n {tr(\n 'banking.plaid.unavailableLong',\n 'Direct bank linking is being switched on. Until then, import a statement export: it finds the same recurring charges.'\n )}\n </p>\n )}\n\n {notice && (\n <p\n role={notice.tone === 'error' ? 'alert' : 'status'}\n className={cn(\n 'mb-4 rounded-lg px-3 py-2 text-sm',\n notice.tone === 'error'\n ? 'bg-status-error-bg-subtle text-status-error-text'\n : 'bg-status-success-bg-subtle text-status-success-text'\n )}\n data-testid=\"banking-notice\"\n >\n {notice.text}\n </p>\n )}\n\n <div\n className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\"\n data-tour=\"subscriberbot-banking-metrics\"\n >\n <MetricsCard\n icon={<Landmark className=\"h-5 w-5\" />}\n value={connections.isLoading ? '—' : connectionItems.length}\n label={tr('banking.metrics.connections', 'Connected accounts')}\n />\n <MetricsCard\n icon={<Repeat className=\"h-5 w-5\" />}\n value={detected.isLoading ? '—' : (detected.data?.items.length ?? 0)}\n label={tr('banking.metrics.detected', 'Charges to review')}\n />\n <MetricsCard\n icon={<CalendarClock className=\"h-5 w-5\" />}\n value={detected.isLoading ? '—' : detectedYearly || formatCurrency(0, 'USD')}\n label={tr('banking.metrics.yearly', 'Yearly cost to review')}\n />\n <MetricsCard\n icon={<ShieldCheck className=\"h-5 w-5\" />}\n value={tracked.isLoading ? '—' : (tracked.data?.items.length ?? 0)}\n label={tr('banking.metrics.tracked', 'Tracked from your bank')}\n />\n </div>\n\n <Section\n dataTour=\"subscriberbot-banking-charges\"\n title={tr('banking.charges.title', 'Recurring charges found')}\n description={tr(\n 'banking.charges.description',\n 'Charges from the same merchant at a steady amount and rhythm.'\n )}\n >\n <div\n role=\"tablist\"\n aria-label={tr('banking.charges.filter', 'Charge status')}\n className=\"mb-3 flex gap-1.5\"\n >\n {CHARGE_FILTERS.map((f) => (\n <button\n key={f}\n type=\"button\"\n role=\"tab\"\n aria-selected={filter === f}\n onClick={() => setFilter(f)}\n className={cn(\n 'rounded-lg px-3 py-1.5 text-xs font-medium',\n filter === f\n ? 'bg-action-primary-bg text-action-primary-text'\n : 'border border-border-subtle text-text-primary hover:bg-bg-sunken'\n )}\n >\n {tr(CHARGE_FILTER_LABEL[f].key, CHARGE_FILTER_LABEL[f].fallback)}\n </button>\n ))}\n </div>\n\n {charges.isLoading ? (\n <LoadingView label={tr('banking.charges.loading', 'Loading recurring charges…')} />\n ) : charges.isError ? (\n <ErrorView\n message={errorText(charges.error, tr)}\n onRetry={() => void charges.refetch()}\n />\n ) : chargeItems.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('banking.charges.empty.title', 'Nothing here yet')}\n description={tr(\n 'banking.charges.empty.description',\n 'Import a statement with at least two months of transactions, or connect a bank, and repeating charges show up here.'\n )}\n />\n ) : (\n <ul className=\"grid grid-cols-1 gap-3 lg:grid-cols-2\" data-testid=\"recurring-charge-list\">\n {chargeItems.map((charge) => (\n <li\n key={charge.id}\n className=\"rounded-xl border border-border-subtle bg-bg-surface p-4\"\n data-testid=\"recurring-charge\"\n >\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-semibold text-text-primary\">\n {charge.displayName}\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {tr(\n 'banking.charges.meta',\n '{{count}} charges since {{first}} · {{confidence}}% sure',\n {\n count: charge.occurrences,\n first: formatDate(charge.firstChargedOn),\n confidence: charge.confidence,\n }\n )}\n </p>\n </div>\n <span className=\"shrink-0 text-sm font-semibold text-text-primary\">\n {formatCurrency(charge.lastAmount, charge.currency)}\n {formatIntervalSuffix(charge.interval)}\n </span>\n </div>\n <p className=\"mt-2 text-xs text-text-secondary\">\n {tr('banking.charges.dates', 'Last charged {{last}}', {\n last: formatDate(charge.lastChargedOn),\n })}\n {charge.nextExpectedOn &&\n ` · ${tr('banking.charges.next', 'next expected {{next}}', {\n next: formatDate(charge.nextExpectedOn),\n })}`}\n {` · ${tr('banking.charges.yearly', '{{amount}} a year', {\n amount: formatCurrency(charge.annualCost, charge.currency),\n })}`}\n </p>\n <div className=\"mt-3 flex flex-wrap gap-2\">\n {charge.status === 'DETECTED' && (\n <>\n <button\n type=\"button\"\n className={primaryBtn}\n onClick={() => void decide('track', charge)}\n disabled={track.isPending}\n >\n {tr('banking.charges.track', 'Track as subscription')}\n </button>\n <button\n type=\"button\"\n className={secondaryBtn}\n onClick={() => void decide('dismiss', charge)}\n disabled={dismiss.isPending}\n >\n {tr('banking.charges.dismiss', 'Not a subscription')}\n </button>\n </>\n )}\n {charge.status === 'TRACKED' && charge.relationshipId && (\n <button\n type=\"button\"\n className={secondaryBtn}\n onClick={() => navigateTo(`/relationships/${charge.relationshipId}`)}\n >\n {tr('banking.charges.view', 'View subscription')}\n </button>\n )}\n {charge.status === 'DISMISSED' && (\n <button\n type=\"button\"\n className={secondaryBtn}\n onClick={() => void decide('restore', charge)}\n disabled={restore.isPending}\n >\n {tr('banking.charges.restore', 'Review again')}\n </button>\n )}\n </div>\n </li>\n ))}\n </ul>\n )}\n </Section>\n\n <Section\n dataTour=\"subscriberbot-banking-connections\"\n title={tr('banking.connections.title', 'Your connections')}\n description={tr(\n 'banking.connections.description',\n 'Disconnecting deletes the accounts and transactions from Subscriber Bot.'\n )}\n >\n {connections.isLoading ? (\n <LoadingView label={tr('banking.connections.loading', 'Loading connections…')} />\n ) : connections.isError ? (\n <ErrorView\n message={errorText(connections.error, tr)}\n onRetry={() => void connections.refetch()}\n />\n ) : connectionItems.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('banking.connections.empty.title', 'No bank or card connected')}\n description={tr(\n 'banking.connections.empty.description',\n 'Download a CSV of your transactions from your bank or card website and import it, or connect a bank.'\n )}\n action={\n <button type=\"button\" className={primaryBtn} onClick={() => setImportOpen(true)}>\n <FileUp className=\"h-4 w-4\" aria-hidden />{' '}\n {tr('banking.import.open', 'Import a statement')}\n </button>\n }\n />\n ) : (\n <ul className=\"space-y-3\" data-testid=\"bank-connection-list\">\n {connectionItems.map((connection) => (\n <li\n key={connection.id}\n className=\"flex flex-col gap-3 rounded-xl border border-border-subtle bg-bg-surface p-4 sm:flex-row sm:items-center sm:justify-between\"\n data-testid=\"bank-connection\"\n >\n <div className=\"min-w-0\">\n <div className=\"flex items-center gap-2\">\n <p className=\"truncate text-sm font-semibold text-text-primary\">\n {connection.institutionName}\n </p>\n <StatusBadge status={connection.status} />\n </div>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {connection.aggregator === 'PLAID'\n ? tr('banking.connections.viaPlaid', 'Linked with Plaid')\n : tr('banking.connections.viaImport', 'Statement import')}\n {' · '}\n {connection.accounts\n .map((a) => (a.mask ? `${a.name} ••${a.mask}` : a.name))\n .join(', ') || tr('banking.connections.noAccounts', 'no accounts yet')}\n {' · '}\n {tr('banking.connections.count', '{{count}} transactions', {\n count: connection.transactionCount,\n })}\n {connection.lastSyncedAt &&\n ` · ${tr('banking.connections.synced', 'updated {{date}}', {\n date: formatDate(connection.lastSyncedAt),\n })}`}\n </p>\n {connection.lastSyncError && (\n <p className=\"mt-1 text-xs text-status-error-text\">\n {connection.lastSyncError}\n </p>\n )}\n {connection.status === 'NEEDS_REAUTH' && (\n <p\n className=\"mt-1 text-xs text-status-warning-text\"\n data-testid=\"bank-connection-hint\"\n >\n {tr(\n 'banking.connections.needsReauth',\n 'The bank needs you to sign in again. Reconnect to keep syncing; your history is kept.'\n )}\n </p>\n )}\n {connection.status === 'REVOKED' && (\n <p\n className=\"mt-1 text-xs text-text-secondary\"\n data-testid=\"bank-connection-hint\"\n >\n {tr(\n 'banking.connections.revoked',\n 'Access was revoked at the bank. Disconnect this connection and link the bank again to keep tracking it.'\n )}\n </p>\n )}\n </div>\n <div className=\"flex shrink-0 gap-2\">\n {connection.aggregator === 'PLAID' && connection.status === 'NEEDS_REAUTH' && (\n <button\n type=\"button\"\n className={smallBtn}\n onClick={() => void reconnect(connection)}\n disabled={linking || !plaid?.available}\n >\n <Link2 className=\"h-3.5 w-3.5\" aria-hidden />{' '}\n {tr('banking.connections.reconnect', 'Reconnect')}\n </button>\n )}\n {connection.aggregator === 'PLAID' &&\n connection.status !== 'REVOKED' &&\n connection.status !== 'NEEDS_REAUTH' && (\n <button\n type=\"button\"\n className={smallBtn}\n onClick={() => void runSync(connection)}\n disabled={sync.isPending || !plaid?.available}\n >\n <RefreshCw className=\"h-3.5 w-3.5\" aria-hidden />{' '}\n {tr('banking.connections.sync', 'Sync')}\n </button>\n )}\n <button\n type=\"button\"\n className={smallBtn}\n onClick={() => void disconnect(connection)}\n disabled={remove.isPending}\n >\n <Trash2 className=\"h-3.5 w-3.5\" aria-hidden />{' '}\n {tr('banking.connections.disconnect', 'Disconnect')}\n </button>\n </div>\n </li>\n ))}\n </ul>\n )}\n </Section>\n\n {importOpen && (\n <ImportStatementModal\n connections={connectionItems.filter((c) => c.aggregator === 'STATEMENT_IMPORT')}\n onClose={() => setImportOpen(false)}\n onImported={(result) => {\n setImportOpen(false);\n setFilter('DETECTED');\n setNotice({ tone: 'success', text: summarise(result) });\n }}\n />\n )}\n </PageLayout>\n );\n}\n\ninterface ImportStatementModalProps {\n connections: SubBankConnection[];\n onClose: () => void;\n onImported: (result: SubBankSyncResult) => void;\n}\n\nfunction ImportStatementModal({ connections, onClose, onImported }: ImportStatementModalProps) {\n const tr = useTr();\n const importStatement = useImportBankStatement();\n const [connectionId, setConnectionId] = useState('');\n const [institutionName, setInstitutionName] = useState('');\n const [accountName, setAccountName] = useState('');\n const [accountMask, setAccountMask] = useState('');\n const [currency, setCurrency] = useState('USD');\n const [convention, setConvention] = useState<SubStatementAmountConvention>('OUTFLOW_NEGATIVE');\n const [dateFormat, setDateFormat] = useState<SubStatementDateFormat>('MDY');\n const [csv, setCsv] = useState('');\n const [error, setError, fieldErrorProps, formErrorId] = useFormError();\n\n const onFile = async (file: File | undefined) => {\n setError(null);\n // A new selection always replaces the previous statement, so a rejected\n // replacement can never leave the earlier file's rows ready to import.\n setCsv('');\n if (!file) return;\n if (file.size > MAX_FILE_BYTES) {\n setError(\n tr(\n 'banking.import.tooLarge',\n 'That file is larger than 2 MB. Export a shorter date range.'\n ),\n 'statement-file'\n );\n return;\n }\n setCsv(await file.text());\n };\n\n const submit = async (event: FormEvent) => {\n event.preventDefault();\n setError(null);\n if (!csv.trim()) {\n setError(tr('banking.import.required', 'Choose a CSV file or paste the statement.'), [\n 'statement-csv',\n 'statement-file',\n ]);\n return;\n }\n try {\n const result = await importStatement.mutateAsync({\n input: {\n connectionId: connectionId || null,\n institutionName: connectionId ? null : institutionName || null,\n accountName: accountName || null,\n accountMask: accountMask || null,\n currency: currency || 'USD',\n csv,\n amountConvention: convention,\n dateFormat,\n },\n });\n onImported(result);\n } catch (err) {\n setError(errorText(err, tr));\n }\n };\n\n return (\n <Modal\n title={tr('banking.import.title', 'Import a bank or card statement')}\n description={tr(\n 'banking.import.description',\n 'Download your transactions as CSV from your bank or card website (two months or more works best).'\n )}\n onClose={onClose}\n maxWidthClassName=\"max-w-xl\"\n >\n <form\n onSubmit={(e) => void submit(e)}\n className=\"space-y-3\"\n data-testid=\"import-statement-form\"\n >\n {connections.length > 0 && (\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.target', 'Add to')}\n <select\n className={cn(inputCls, 'mt-1')}\n value={connectionId}\n onChange={(e) => setConnectionId(e.target.value)}\n >\n <option value=\"\">{tr('banking.import.newConnection', 'A new connection')}</option>\n {connections.map((c) => (\n <option key={c.id} value={c.id}>\n {c.institutionName}\n </option>\n ))}\n </select>\n </label>\n )}\n {!connectionId && (\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.institution', 'Bank or card issuer')}\n <input\n className={cn(inputCls, 'mt-1')}\n value={institutionName}\n onChange={(e) => setInstitutionName(e.target.value)}\n placeholder={tr('banking.import.institutionPlaceholder', 'e.g. Chase')}\n maxLength={255}\n />\n </label>\n )}\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <label className=\"block text-sm text-text-primary sm:col-span-2\">\n {tr('banking.import.account', 'Account name')}\n <input\n className={cn(inputCls, 'mt-1')}\n value={accountName}\n onChange={(e) => setAccountName(e.target.value)}\n placeholder={tr('banking.import.accountPlaceholder', 'e.g. Sapphire card')}\n maxLength={255}\n />\n </label>\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.mask', 'Last 4 digits')}\n <input\n className={cn(inputCls, 'mt-1')}\n value={accountMask}\n onChange={(e) => setAccountMask(e.target.value.replace(/\\D/g, '').slice(-4))}\n inputMode=\"numeric\"\n maxLength={4}\n />\n </label>\n </div>\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.currency', 'Currency')}\n <input\n className={cn(inputCls, 'mt-1 uppercase')}\n value={currency}\n onChange={(e) => setCurrency(e.target.value.toUpperCase().slice(0, 3))}\n maxLength={3}\n />\n </label>\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.convention', 'Money out is')}\n <select\n className={cn(inputCls, 'mt-1')}\n value={convention}\n onChange={(e) => setConvention(e.target.value as SubStatementAmountConvention)}\n >\n <option value=\"OUTFLOW_NEGATIVE\">\n {tr('banking.import.negative', 'Negative (bank)')}\n </option>\n <option value=\"OUTFLOW_POSITIVE\">\n {tr('banking.import.positive', 'Positive (card)')}\n </option>\n </select>\n </label>\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.dateFormat', 'Date format')}\n <select\n className={cn(inputCls, 'mt-1')}\n value={dateFormat}\n onChange={(e) => setDateFormat(e.target.value as SubStatementDateFormat)}\n >\n <option value=\"MDY\">MM/DD/YYYY</option>\n <option value=\"DMY\">DD/MM/YYYY</option>\n <option value=\"YMD\">YYYY-MM-DD</option>\n </select>\n </label>\n </div>\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.file', 'CSV file')}\n <input\n type=\"file\"\n accept=\".csv,text/csv,text/plain\"\n className={cn(inputCls, 'mt-1')}\n onChange={(e) => void onFile(e.target.files?.[0])}\n id=\"statement-file\"\n {...fieldErrorProps('statement-file')}\n data-testid=\"import-statement-file\"\n />\n </label>\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.paste', 'Or paste the statement')}\n <textarea\n className={cn(inputCls, 'mt-1 h-32 font-mono text-xs')}\n value={csv}\n onChange={(e) => setCsv(e.target.value)}\n placeholder={'Date,Description,Amount\\n10/05/2026,NETFLIX.COM,-15.49'}\n id=\"statement-csv\"\n {...fieldErrorProps('statement-csv')}\n data-testid=\"import-statement-csv\"\n />\n </label>\n {error && (\n <p id={formErrorId} tabIndex={-1} role=\"alert\" className=\"text-sm text-status-error-text\">\n {error}\n </p>\n )}\n <div className=\"flex justify-end gap-2 pt-1\">\n <button type=\"button\" className={secondaryBtn} onClick={onClose}>\n {tr('common.cancel', 'Cancel')}\n </button>\n <button type=\"submit\" className={primaryBtn} disabled={importStatement.isPending}>\n {importStatement.isPending\n ? tr('banking.import.submitting', 'Importing…')\n : tr('banking.import.submit', 'Import and find subscriptions')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA6DA,IAAM,IACJ,wMACI,IACJ,8JACI,IACJ,gKACI,IACJ,sKAEI,KAA6C;CAAC;CAAY;CAAW;AAAW,GAChF,KAA2F;CAC/F,UAAU;EAAE,KAAK;EAA4B,UAAU;CAAY;CACnE,SAAS;EAAE,KAAK;EAA2B,UAAU;CAAU;CAC/D,WAAW;EAAE,KAAK;EAA6B,UAAU;CAAY;AACvE,GACM,KAAiB,KAEjB,KAAa,GAAgB,MACjC,aAAiB,QAAQ,EAAM,UAAU,EAAG,6BAA6B,sBAAsB;AAOjG,SAAgB,IAAsB;CACpC,IAAM,EAAE,mBAAgB,eAAY,4BAAyB,EAAc,GAErE,IAAK,EAAM,GACX,EAAE,mBAAe,EAAiB,GAClC,CAAC,GAAQ,KAAa,EAAmC,UAAU,GACnE,CAAC,IAAY,KAAiB,EAAS,EAAK,GAC5C,CA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,EAAgB,YACb,EAAG,6BAA6B,YAAY,IAC5C,EAAG,yBAAyB,+BAA+B;KACzD,CAAA,CACL;;GACD;;CACD,CAAA;AAEX"}
|
|
1
|
+
{"version":3,"file":"BankConnectionsPage.js","names":[],"sources":["../../../../src/subscriberbot/pages/banking/BankConnectionsPage.tsx"],"sourcesContent":["import { useFormError } from '../../hooks/useFormError';\nimport { useFormatters } from '../../hooks/useFormatters';\n/**\n * Bank & card connections\n * @module subscriberbot/pages/banking\n *\n * `/subscriberbot/banking` — link a bank or card through Plaid (US),\n * TrueLayer (UK / EU open banking) or an RBI Account Aggregator (India,\n * BOFF-10811), or import a statement export (CSV) from any bank, and review\n * the recurring charges Subscriber Bot found in the transactions: track each\n * as a subscription or dismiss it (BOFF-4161). Everything here belongs to the\n * signed-in user only.\n *\n * TrueLayer and the Account Aggregator leave the page and come back here with\n * a one-time result in the URL; `consumeBankRedirect` picks it up on mount\n * and completes the link.\n */\n\nimport { useEffect, useMemo, useRef, useState, type FormEvent } from 'react';\nimport {\n CalendarClock,\n FileUp,\n Landmark,\n Link2,\n RefreshCw,\n Repeat,\n ShieldCheck,\n Trash2,\n} from 'lucide-react';\nimport { PagePurpose } from '@burdenoff/fe-libs/ui';\nimport {\n EmptyState,\n ErrorView,\n LoadingView,\n MetricsCard,\n Modal,\n PageLayout,\n Section,\n StatusBadge,\n} from '../../components';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport {\n useBankAggregators,\n useBankConnections,\n useCompleteBankLink,\n useCreateBankLinkSession,\n useDismissRecurringCharge,\n useImportBankStatement,\n useRecurringCharges,\n useRemoveBankConnection,\n useRestoreRecurringCharge,\n useSyncBankConnection,\n useTrackRecurringCharge,\n} from '../../hooks/useBankingApi';\nimport { useTr } from '../../hooks/useTr';\nimport { cn } from '../../utils/cn';\n\nimport { consumeBankRedirect, savePendingBankLink } from '../../utils/bankRedirectLink';\nimport { openPlaidLink } from '../../utils/plaidLink';\nimport { ConnectBankModal } from './ConnectBankModal';\nimport type {\n SubBankAggregator,\n SubBankConnection,\n SubBankSyncResult,\n SubRecurringCharge,\n SubRecurringChargeStatus,\n SubStatementAmountConvention,\n SubStatementDateFormat,\n} from '../../types/banking';\n\nconst inputCls =\n 'w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\nconst primaryBtn =\n 'inline-flex items-center gap-2 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50';\nconst secondaryBtn =\n 'inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50';\nconst smallBtn =\n 'inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-2.5 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50';\n\nconst CHARGE_FILTERS: SubRecurringChargeStatus[] = ['DETECTED', 'TRACKED', 'DISMISSED'];\nconst CHARGE_FILTER_LABEL: Record<SubRecurringChargeStatus, { key: string; fallback: string }> = {\n DETECTED: { key: 'banking.charges.detected', fallback: 'To review' },\n TRACKED: { key: 'banking.charges.tracked', fallback: 'Tracked' },\n DISMISSED: { key: 'banking.charges.dismissed', fallback: 'Dismissed' },\n};\nconst MAX_FILE_BYTES = 2_000_000;\n/** Aggregators the customer links through a hosted flow (everything except statement import). */\nconst LINKED: ReadonlySet<SubBankAggregator> = new Set([\n 'PLAID',\n 'TRUELAYER',\n 'ACCOUNT_AGGREGATOR',\n]);\nconst VIA_LABEL: Record<SubBankAggregator, { key: string; fallback: string }> = {\n PLAID: { key: 'banking.connections.viaPlaid', fallback: 'Linked with Plaid' },\n TRUELAYER: { key: 'banking.connections.viaTrueLayer', fallback: 'Open banking via TrueLayer' },\n ACCOUNT_AGGREGATOR: { key: 'banking.connections.viaAa', fallback: 'Account Aggregator consent' },\n STATEMENT_IMPORT: { key: 'banking.connections.viaImport', fallback: 'Statement import' },\n};\n\nconst isHttpsUrl = (value: string | null): value is string => {\n if (!value) return false;\n try {\n return new URL(value).protocol === 'https:';\n } catch {\n return false;\n }\n};\n\nconst errorText = (error: unknown, tr: ReturnType<typeof useTr>): string =>\n error instanceof Error ? error.message : tr('common.somethingWentWrong', 'Something went wrong');\n\ninterface Notice {\n tone: 'success' | 'error';\n text: string;\n}\n\nexport function BankConnectionsPage() {\n const { formatCurrency, formatDate, formatIntervalSuffix } = useFormatters();\n\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const [filter, setFilter] = useState<SubRecurringChargeStatus>('DETECTED');\n const [importOpen, setImportOpen] = useState(false);\n const [notice, setNotice] = useState<Notice | null>(null);\n const [linking, setLinking] = useState(false);\n /** The connect chooser: open for a new link, or for reconnecting a connection. */\n const [connectFor, setConnectFor] = useState<{ connection: SubBankConnection | null } | null>(\n null\n );\n const redirectHandled = useRef(false);\n\n const aggregators = useBankAggregators();\n const connections = useBankConnections();\n const charges = useRecurringCharges(filter);\n const detected = useRecurringCharges('DETECTED');\n const tracked = useRecurringCharges('TRACKED');\n\n const createLink = useCreateBankLinkSession();\n const completeLink = useCompleteBankLink();\n const sync = useSyncBankConnection();\n const remove = useRemoveBankConnection();\n const track = useTrackRecurringCharge();\n const dismiss = useDismissRecurringCharge();\n const restore = useRestoreRecurringCharge();\n\n const linkable = useMemo(\n () => (aggregators.data ?? []).filter((a) => LINKED.has(a.aggregator)),\n [aggregators.data]\n );\n const anyLinkable = linkable.some((a) => a.available);\n const isAvailable = (aggregator: SubBankAggregator): boolean =>\n linkable.some((a) => a.aggregator === aggregator && a.available);\n const connectionItems = connections.data?.items ?? [];\n const chargeItems = charges.data?.items ?? [];\n\n const detectedYearly = useMemo(() => {\n const totals = new Map<string, number>();\n for (const c of detected.data?.items ?? []) {\n totals.set(c.currency, (totals.get(c.currency) ?? 0) + c.annualCost);\n }\n return [...totals.entries()]\n .map(([currency, amount]) => formatCurrency(amount, currency))\n .join(' + ');\n }, [detected.data, formatCurrency]);\n\n const summarise = (result: SubBankSyncResult): string =>\n tr(\n 'banking.notice.synced',\n '{{added}} new transaction(s) from {{institution}}; {{recurring}} recurring charge(s) found.',\n {\n added: result.added,\n institution: result.connection.institutionName,\n recurring: result.recurringDetected,\n }\n );\n\n const connectPlaid = async () => {\n setNotice(null);\n setLinking(true);\n try {\n const session = await createLink.mutateAsync({ aggregator: 'PLAID' });\n const linked = await openPlaidLink(session.linkToken, tr);\n if (!linked) return;\n const result = await completeLink.mutateAsync({\n input: {\n aggregator: 'PLAID',\n publicToken: linked.publicToken,\n institutionId: linked.institutionId,\n institutionName: linked.institutionName,\n },\n });\n setNotice({ tone: 'success', text: summarise(result) });\n } catch (error) {\n setNotice({ tone: 'error', text: errorText(error, tr) });\n } finally {\n setLinking(false);\n }\n };\n\n // Redirect aggregators (BOFF-10811): keep the signed link token for this\n // tab and send the browser to the bank or Account Aggregator. It comes back\n // here and the effect below completes the link (or the reconnect).\n const startRedirect = async (\n aggregator: SubBankAggregator,\n customerIdentifier: string | null,\n connection: SubBankConnection | null\n ) => {\n setNotice(null);\n setLinking(true);\n try {\n const session = await createLink.mutateAsync({\n aggregator,\n ...(connection ? { connectionId: connection.id } : {}),\n ...(customerIdentifier ? { customerIdentifier } : {}),\n });\n // Only ever navigate to an https consent URL (the service enforces this too).\n if (!isHttpsUrl(session.linkUrl)) {\n throw new Error(tr('common.somethingWentWrong', 'Something went wrong'));\n }\n savePendingBankLink({\n aggregator,\n linkToken: session.linkToken,\n connectionId: connection?.id ?? null,\n });\n window.location.assign(session.linkUrl);\n } catch (error) {\n setNotice({ tone: 'error', text: errorText(error, tr) });\n setLinking(false);\n }\n };\n\n const onConnectChoice = (aggregator: SubBankAggregator, customerIdentifier: string | null) => {\n const connection = connectFor?.connection ?? null;\n setConnectFor(null);\n if (aggregator === 'PLAID') {\n void (connection ? reconnect(connection) : connectPlaid());\n return;\n }\n void startRedirect(aggregator, customerIdentifier, connection);\n };\n\n useEffect(() => {\n if (redirectHandled.current) return;\n redirectHandled.current = true;\n const result = consumeBankRedirect();\n if (!result) return;\n if (result.kind === 'expired') {\n setNotice({\n tone: 'error',\n text: tr(\n 'banking.redirect.expired',\n 'That bank link could not be finished here. Start connecting the bank again.'\n ),\n });\n return;\n }\n if (result.kind === 'declined') {\n setNotice({\n tone: 'error',\n text: tr(\n 'banking.redirect.declined',\n 'The bank or Account Aggregator did not grant access, so nothing was connected.'\n ),\n });\n return;\n }\n setLinking(true);\n completeLink\n .mutateAsync({\n input: {\n aggregator: result.aggregator,\n publicToken: result.publicToken,\n state: result.state,\n },\n })\n .then((linked) => setNotice({ tone: 'success', text: summarise(linked) }))\n .catch((error: unknown) => setNotice({ tone: 'error', text: errorText(error, tr) }))\n .finally(() => setLinking(false));\n // Runs once on mount: the redirect result is in the URL only then.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Update mode (BOFF-10810): the customer signs in to the bank again for an\n // existing connection, then a sync moves it back to ACTIVE with its history.\n const reconnect = async (connection: SubBankConnection) => {\n setNotice(null);\n setLinking(true);\n try {\n const session = await createLink.mutateAsync({\n aggregator: 'PLAID',\n connectionId: connection.id,\n });\n const linked = await openPlaidLink(session.linkToken, tr);\n if (!linked) return;\n setNotice({\n tone: 'success',\n text: summarise(await sync.mutateAsync({ id: connection.id })),\n });\n } catch (error) {\n setNotice({ tone: 'error', text: errorText(error, tr) });\n } finally {\n setLinking(false);\n }\n };\n\n const runSync = async (connection: SubBankConnection) => {\n setNotice(null);\n try {\n setNotice({\n tone: 'success',\n text: summarise(await sync.mutateAsync({ id: connection.id })),\n });\n } catch (error) {\n setNotice({ tone: 'error', text: errorText(error, tr) });\n }\n };\n\n const disconnect = async (connection: SubBankConnection) => {\n const confirmed = window.confirm(\n tr(\n 'banking.disconnect.confirm',\n 'Disconnect {{institution}}? Its accounts and transactions are deleted from Subscriber Bot. Subscriptions you already track stay.',\n { institution: connection.institutionName }\n )\n );\n if (!confirmed) return;\n setNotice(null);\n try {\n await remove.mutateAsync({ id: connection.id });\n setNotice({\n tone: 'success',\n text: tr('banking.notice.disconnected', '{{institution}} was disconnected.', {\n institution: connection.institutionName,\n }),\n });\n } catch (error) {\n setNotice({ tone: 'error', text: errorText(error, tr) });\n }\n };\n\n const decide = async (action: 'track' | 'dismiss' | 'restore', charge: SubRecurringCharge) => {\n setNotice(null);\n try {\n const mutation = { track, dismiss, restore }[action];\n const updated = await mutation.mutateAsync({ id: charge.id });\n if (action === 'track') {\n setNotice({\n tone: 'success',\n text: tr('banking.notice.tracked', '{{name}} is now tracked as a subscription.', {\n name: updated.displayName,\n }),\n });\n }\n } catch (error) {\n setNotice({ tone: 'error', text: errorText(error, tr) });\n }\n };\n\n const actions = (\n <div className=\"flex flex-wrap gap-2\" data-tour=\"subscriberbot-banking-connect\">\n <button type=\"button\" className={secondaryBtn} onClick={() => setImportOpen(true)}>\n <FileUp className=\"h-4 w-4\" aria-hidden /> {tr('banking.import.open', 'Import a statement')}\n </button>\n <button\n type=\"button\"\n className={primaryBtn}\n onClick={() => setConnectFor({ connection: null })}\n disabled={!anyLinkable || linking}\n data-testid=\"connect-bank\"\n title={\n anyLinkable\n ? undefined\n : tr(\n 'banking.plaid.unavailable',\n 'Bank linking is not switched on yet. Import a statement instead.'\n )\n }\n >\n <Link2 className=\"h-4 w-4\" aria-hidden />\n {linking\n ? tr('banking.plaid.linking', 'Connecting…')\n : tr('banking.plaid.connect', 'Connect a bank')}\n </button>\n </div>\n );\n\n return (\n <PageLayout\n dataTour=\"subscriberbot-banking\"\n title={tr('banking.title', 'Bank & card connections')}\n description={tr(\n 'banking.description',\n 'Find every subscription in your bank and card transactions.'\n )}\n actions={actions}\n >\n <PagePurpose className=\"mb-6\">\n {tr(\n 'banking.purpose',\n 'Connect a bank or card (US through Plaid, UK and Europe through open banking, India through an Account Aggregator), or import the CSV export any bank lets you download. Subscriber Bot spots the charges that repeat every week, month, quarter or year so you can track them or wave them off. Your bank password is never shared with Subscriber Bot, and only you can see these accounts.'\n )}\n </PagePurpose>\n\n {aggregators.data && !anyLinkable && (\n <p\n className=\"mb-4 flex items-start gap-2 rounded-lg border border-border-subtle bg-bg-sunken px-3 py-2 text-sm text-text-secondary\"\n data-testid=\"plaid-unavailable\"\n >\n <ShieldCheck className=\"mt-0.5 h-4 w-4 shrink-0\" aria-hidden />\n {tr(\n 'banking.plaid.unavailableLong',\n 'Direct bank linking is being switched on. Until then, import a statement export: it finds the same recurring charges.'\n )}\n </p>\n )}\n\n {notice && (\n <p\n role={notice.tone === 'error' ? 'alert' : 'status'}\n className={cn(\n 'mb-4 rounded-lg px-3 py-2 text-sm',\n notice.tone === 'error'\n ? 'bg-status-error-bg-subtle text-status-error-text'\n : 'bg-status-success-bg-subtle text-status-success-text'\n )}\n data-testid=\"banking-notice\"\n >\n {notice.text}\n </p>\n )}\n\n <div\n className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\"\n data-tour=\"subscriberbot-banking-metrics\"\n >\n <MetricsCard\n icon={<Landmark className=\"h-5 w-5\" />}\n value={connections.isLoading ? '—' : connectionItems.length}\n label={tr('banking.metrics.connections', 'Connected accounts')}\n />\n <MetricsCard\n icon={<Repeat className=\"h-5 w-5\" />}\n value={detected.isLoading ? '—' : (detected.data?.items.length ?? 0)}\n label={tr('banking.metrics.detected', 'Charges to review')}\n />\n <MetricsCard\n icon={<CalendarClock className=\"h-5 w-5\" />}\n value={detected.isLoading ? '—' : detectedYearly || formatCurrency(0, 'USD')}\n label={tr('banking.metrics.yearly', 'Yearly cost to review')}\n />\n <MetricsCard\n icon={<ShieldCheck className=\"h-5 w-5\" />}\n value={tracked.isLoading ? '—' : (tracked.data?.items.length ?? 0)}\n label={tr('banking.metrics.tracked', 'Tracked from your bank')}\n />\n </div>\n\n <Section\n dataTour=\"subscriberbot-banking-charges\"\n title={tr('banking.charges.title', 'Recurring charges found')}\n description={tr(\n 'banking.charges.description',\n 'Charges from the same merchant at a steady amount and rhythm.'\n )}\n >\n <div\n role=\"tablist\"\n aria-label={tr('banking.charges.filter', 'Charge status')}\n className=\"mb-3 flex gap-1.5\"\n >\n {CHARGE_FILTERS.map((f) => (\n <button\n key={f}\n type=\"button\"\n role=\"tab\"\n aria-selected={filter === f}\n onClick={() => setFilter(f)}\n className={cn(\n 'rounded-lg px-3 py-1.5 text-xs font-medium',\n filter === f\n ? 'bg-action-primary-bg text-action-primary-text'\n : 'border border-border-subtle text-text-primary hover:bg-bg-sunken'\n )}\n >\n {tr(CHARGE_FILTER_LABEL[f].key, CHARGE_FILTER_LABEL[f].fallback)}\n </button>\n ))}\n </div>\n\n {charges.isLoading ? (\n <LoadingView label={tr('banking.charges.loading', 'Loading recurring charges…')} />\n ) : charges.isError ? (\n <ErrorView\n message={errorText(charges.error, tr)}\n onRetry={() => void charges.refetch()}\n />\n ) : chargeItems.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('banking.charges.empty.title', 'Nothing here yet')}\n description={tr(\n 'banking.charges.empty.description',\n 'Import a statement with at least two months of transactions, or connect a bank, and repeating charges show up here.'\n )}\n />\n ) : (\n <ul className=\"grid grid-cols-1 gap-3 lg:grid-cols-2\" data-testid=\"recurring-charge-list\">\n {chargeItems.map((charge) => (\n <li\n key={charge.id}\n className=\"rounded-xl border border-border-subtle bg-bg-surface p-4\"\n data-testid=\"recurring-charge\"\n >\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-semibold text-text-primary\">\n {charge.displayName}\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {tr(\n 'banking.charges.meta',\n '{{count}} charges since {{first}} · {{confidence}}% sure',\n {\n count: charge.occurrences,\n first: formatDate(charge.firstChargedOn),\n confidence: charge.confidence,\n }\n )}\n </p>\n </div>\n <span className=\"shrink-0 text-sm font-semibold text-text-primary\">\n {formatCurrency(charge.lastAmount, charge.currency)}\n {formatIntervalSuffix(charge.interval)}\n </span>\n </div>\n <p className=\"mt-2 text-xs text-text-secondary\">\n {tr('banking.charges.dates', 'Last charged {{last}}', {\n last: formatDate(charge.lastChargedOn),\n })}\n {charge.nextExpectedOn &&\n ` · ${tr('banking.charges.next', 'next expected {{next}}', {\n next: formatDate(charge.nextExpectedOn),\n })}`}\n {` · ${tr('banking.charges.yearly', '{{amount}} a year', {\n amount: formatCurrency(charge.annualCost, charge.currency),\n })}`}\n </p>\n <div className=\"mt-3 flex flex-wrap gap-2\">\n {charge.status === 'DETECTED' && (\n <>\n <button\n type=\"button\"\n className={primaryBtn}\n onClick={() => void decide('track', charge)}\n disabled={track.isPending}\n >\n {tr('banking.charges.track', 'Track as subscription')}\n </button>\n <button\n type=\"button\"\n className={secondaryBtn}\n onClick={() => void decide('dismiss', charge)}\n disabled={dismiss.isPending}\n >\n {tr('banking.charges.dismiss', 'Not a subscription')}\n </button>\n </>\n )}\n {charge.status === 'TRACKED' && charge.relationshipId && (\n <button\n type=\"button\"\n className={secondaryBtn}\n onClick={() => navigateTo(`/relationships/${charge.relationshipId}`)}\n >\n {tr('banking.charges.view', 'View subscription')}\n </button>\n )}\n {charge.status === 'DISMISSED' && (\n <button\n type=\"button\"\n className={secondaryBtn}\n onClick={() => void decide('restore', charge)}\n disabled={restore.isPending}\n >\n {tr('banking.charges.restore', 'Review again')}\n </button>\n )}\n </div>\n </li>\n ))}\n </ul>\n )}\n </Section>\n\n <Section\n dataTour=\"subscriberbot-banking-connections\"\n title={tr('banking.connections.title', 'Your connections')}\n description={tr(\n 'banking.connections.description',\n 'Disconnecting deletes the accounts and transactions from Subscriber Bot.'\n )}\n >\n {connections.isLoading ? (\n <LoadingView label={tr('banking.connections.loading', 'Loading connections…')} />\n ) : connections.isError ? (\n <ErrorView\n message={errorText(connections.error, tr)}\n onRetry={() => void connections.refetch()}\n />\n ) : connectionItems.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('banking.connections.empty.title', 'No bank or card connected')}\n description={tr(\n 'banking.connections.empty.description',\n 'Download a CSV of your transactions from your bank or card website and import it, or connect a bank.'\n )}\n action={\n <button type=\"button\" className={primaryBtn} onClick={() => setImportOpen(true)}>\n <FileUp className=\"h-4 w-4\" aria-hidden />{' '}\n {tr('banking.import.open', 'Import a statement')}\n </button>\n }\n />\n ) : (\n <ul className=\"space-y-3\" data-testid=\"bank-connection-list\">\n {connectionItems.map((connection) => (\n <li\n key={connection.id}\n className=\"flex flex-col gap-3 rounded-xl border border-border-subtle bg-bg-surface p-4 sm:flex-row sm:items-center sm:justify-between\"\n data-testid=\"bank-connection\"\n >\n <div className=\"min-w-0\">\n <div className=\"flex items-center gap-2\">\n <p className=\"truncate text-sm font-semibold text-text-primary\">\n {connection.institutionName}\n </p>\n <StatusBadge status={connection.status} />\n </div>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {tr(\n VIA_LABEL[connection.aggregator].key,\n VIA_LABEL[connection.aggregator].fallback\n )}\n {' · '}\n {connection.accounts\n .map((a) => (a.mask ? `${a.name} ••${a.mask}` : a.name))\n .join(', ') || tr('banking.connections.noAccounts', 'no accounts yet')}\n {' · '}\n {tr('banking.connections.count', '{{count}} transactions', {\n count: connection.transactionCount,\n })}\n {connection.lastSyncedAt &&\n ` · ${tr('banking.connections.synced', 'updated {{date}}', {\n date: formatDate(connection.lastSyncedAt),\n })}`}\n </p>\n {connection.consentExpiresAt && connection.status !== 'REVOKED' && (\n <p\n className=\"mt-0.5 text-xs text-text-secondary\"\n data-testid=\"bank-connection-consent\"\n >\n {tr('banking.connections.consentUntil', 'Consent valid until {{date}}', {\n date: formatDate(connection.consentExpiresAt),\n })}\n </p>\n )}\n {connection.lastSyncError && (\n <p className=\"mt-1 text-xs text-status-error-text\">\n {connection.lastSyncError}\n </p>\n )}\n {connection.status === 'NEEDS_REAUTH' && (\n <p\n className=\"mt-1 text-xs text-status-warning-text\"\n data-testid=\"bank-connection-hint\"\n >\n {tr(\n 'banking.connections.needsReauth',\n 'The bank needs you to sign in again. Reconnect to keep syncing; your history is kept.'\n )}\n </p>\n )}\n {connection.status === 'REVOKED' && (\n <p\n className=\"mt-1 text-xs text-text-secondary\"\n data-testid=\"bank-connection-hint\"\n >\n {tr(\n 'banking.connections.revoked',\n 'Access was revoked at the bank. Disconnect this connection and link the bank again to keep tracking it.'\n )}\n </p>\n )}\n </div>\n <div className=\"flex shrink-0 gap-2\">\n {LINKED.has(connection.aggregator) && connection.status === 'NEEDS_REAUTH' && (\n <button\n type=\"button\"\n className={smallBtn}\n onClick={() =>\n connection.aggregator === 'PLAID'\n ? void reconnect(connection)\n : setConnectFor({ connection })\n }\n disabled={linking || !isAvailable(connection.aggregator)}\n >\n <Link2 className=\"h-3.5 w-3.5\" aria-hidden />{' '}\n {tr('banking.connections.reconnect', 'Reconnect')}\n </button>\n )}\n {LINKED.has(connection.aggregator) &&\n connection.status !== 'REVOKED' &&\n connection.status !== 'NEEDS_REAUTH' && (\n <button\n type=\"button\"\n className={smallBtn}\n onClick={() => void runSync(connection)}\n disabled={sync.isPending || !isAvailable(connection.aggregator)}\n >\n <RefreshCw className=\"h-3.5 w-3.5\" aria-hidden />{' '}\n {tr('banking.connections.sync', 'Sync')}\n </button>\n )}\n <button\n type=\"button\"\n className={smallBtn}\n onClick={() => void disconnect(connection)}\n disabled={remove.isPending}\n >\n <Trash2 className=\"h-3.5 w-3.5\" aria-hidden />{' '}\n {tr('banking.connections.disconnect', 'Disconnect')}\n </button>\n </div>\n </li>\n ))}\n </ul>\n )}\n </Section>\n\n {connectFor && (\n <ConnectBankModal\n aggregators={linkable}\n connection={connectFor.connection}\n busy={linking}\n onClose={() => setConnectFor(null)}\n onConnect={onConnectChoice}\n />\n )}\n\n {importOpen && (\n <ImportStatementModal\n connections={connectionItems.filter((c) => c.aggregator === 'STATEMENT_IMPORT')}\n onClose={() => setImportOpen(false)}\n onImported={(result) => {\n setImportOpen(false);\n setFilter('DETECTED');\n setNotice({ tone: 'success', text: summarise(result) });\n }}\n />\n )}\n </PageLayout>\n );\n}\n\ninterface ImportStatementModalProps {\n connections: SubBankConnection[];\n onClose: () => void;\n onImported: (result: SubBankSyncResult) => void;\n}\n\nfunction ImportStatementModal({ connections, onClose, onImported }: ImportStatementModalProps) {\n const tr = useTr();\n const importStatement = useImportBankStatement();\n const [connectionId, setConnectionId] = useState('');\n const [institutionName, setInstitutionName] = useState('');\n const [accountName, setAccountName] = useState('');\n const [accountMask, setAccountMask] = useState('');\n const [currency, setCurrency] = useState('USD');\n const [convention, setConvention] = useState<SubStatementAmountConvention>('OUTFLOW_NEGATIVE');\n const [dateFormat, setDateFormat] = useState<SubStatementDateFormat>('MDY');\n const [csv, setCsv] = useState('');\n const [error, setError, fieldErrorProps, formErrorId] = useFormError();\n\n const onFile = async (file: File | undefined) => {\n setError(null);\n // A new selection always replaces the previous statement, so a rejected\n // replacement can never leave the earlier file's rows ready to import.\n setCsv('');\n if (!file) return;\n if (file.size > MAX_FILE_BYTES) {\n setError(\n tr(\n 'banking.import.tooLarge',\n 'That file is larger than 2 MB. Export a shorter date range.'\n ),\n 'statement-file'\n );\n return;\n }\n setCsv(await file.text());\n };\n\n const submit = async (event: FormEvent) => {\n event.preventDefault();\n setError(null);\n if (!csv.trim()) {\n setError(tr('banking.import.required', 'Choose a CSV file or paste the statement.'), [\n 'statement-csv',\n 'statement-file',\n ]);\n return;\n }\n try {\n const result = await importStatement.mutateAsync({\n input: {\n connectionId: connectionId || null,\n institutionName: connectionId ? null : institutionName || null,\n accountName: accountName || null,\n accountMask: accountMask || null,\n currency: currency || 'USD',\n csv,\n amountConvention: convention,\n dateFormat,\n },\n });\n onImported(result);\n } catch (err) {\n setError(errorText(err, tr));\n }\n };\n\n return (\n <Modal\n title={tr('banking.import.title', 'Import a bank or card statement')}\n description={tr(\n 'banking.import.description',\n 'Download your transactions as CSV from your bank or card website (two months or more works best).'\n )}\n onClose={onClose}\n maxWidthClassName=\"max-w-xl\"\n >\n <form\n onSubmit={(e) => void submit(e)}\n className=\"space-y-3\"\n data-testid=\"import-statement-form\"\n >\n {connections.length > 0 && (\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.target', 'Add to')}\n <select\n className={cn(inputCls, 'mt-1')}\n value={connectionId}\n onChange={(e) => setConnectionId(e.target.value)}\n >\n <option value=\"\">{tr('banking.import.newConnection', 'A new connection')}</option>\n {connections.map((c) => (\n <option key={c.id} value={c.id}>\n {c.institutionName}\n </option>\n ))}\n </select>\n </label>\n )}\n {!connectionId && (\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.institution', 'Bank or card issuer')}\n <input\n className={cn(inputCls, 'mt-1')}\n value={institutionName}\n onChange={(e) => setInstitutionName(e.target.value)}\n placeholder={tr('banking.import.institutionPlaceholder', 'e.g. Chase')}\n maxLength={255}\n />\n </label>\n )}\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <label className=\"block text-sm text-text-primary sm:col-span-2\">\n {tr('banking.import.account', 'Account name')}\n <input\n className={cn(inputCls, 'mt-1')}\n value={accountName}\n onChange={(e) => setAccountName(e.target.value)}\n placeholder={tr('banking.import.accountPlaceholder', 'e.g. Sapphire card')}\n maxLength={255}\n />\n </label>\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.mask', 'Last 4 digits')}\n <input\n className={cn(inputCls, 'mt-1')}\n value={accountMask}\n onChange={(e) => setAccountMask(e.target.value.replace(/\\D/g, '').slice(-4))}\n inputMode=\"numeric\"\n maxLength={4}\n />\n </label>\n </div>\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.currency', 'Currency')}\n <input\n className={cn(inputCls, 'mt-1 uppercase')}\n value={currency}\n onChange={(e) => setCurrency(e.target.value.toUpperCase().slice(0, 3))}\n maxLength={3}\n />\n </label>\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.convention', 'Money out is')}\n <select\n className={cn(inputCls, 'mt-1')}\n value={convention}\n onChange={(e) => setConvention(e.target.value as SubStatementAmountConvention)}\n >\n <option value=\"OUTFLOW_NEGATIVE\">\n {tr('banking.import.negative', 'Negative (bank)')}\n </option>\n <option value=\"OUTFLOW_POSITIVE\">\n {tr('banking.import.positive', 'Positive (card)')}\n </option>\n </select>\n </label>\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.dateFormat', 'Date format')}\n <select\n className={cn(inputCls, 'mt-1')}\n value={dateFormat}\n onChange={(e) => setDateFormat(e.target.value as SubStatementDateFormat)}\n >\n <option value=\"MDY\">MM/DD/YYYY</option>\n <option value=\"DMY\">DD/MM/YYYY</option>\n <option value=\"YMD\">YYYY-MM-DD</option>\n </select>\n </label>\n </div>\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.file', 'CSV file')}\n <input\n type=\"file\"\n accept=\".csv,text/csv,text/plain\"\n className={cn(inputCls, 'mt-1')}\n onChange={(e) => void onFile(e.target.files?.[0])}\n id=\"statement-file\"\n {...fieldErrorProps('statement-file')}\n data-testid=\"import-statement-file\"\n />\n </label>\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.import.paste', 'Or paste the statement')}\n <textarea\n className={cn(inputCls, 'mt-1 h-32 font-mono text-xs')}\n value={csv}\n onChange={(e) => setCsv(e.target.value)}\n placeholder={'Date,Description,Amount\\n10/05/2026,NETFLIX.COM,-15.49'}\n id=\"statement-csv\"\n {...fieldErrorProps('statement-csv')}\n data-testid=\"import-statement-csv\"\n />\n </label>\n {error && (\n <p id={formErrorId} tabIndex={-1} role=\"alert\" className=\"text-sm text-status-error-text\">\n {error}\n </p>\n )}\n <div className=\"flex justify-end gap-2 pt-1\">\n <button type=\"button\" className={secondaryBtn} onClick={onClose}>\n {tr('common.cancel', 'Cancel')}\n </button>\n <button type=\"submit\" className={primaryBtn} disabled={importStatement.isPending}>\n {importStatement.isPending\n ? tr('banking.import.submitting', 'Importing…')\n : tr('banking.import.submit', 'Import and find subscriptions')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsEA,I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,EAAG,GAAU,6BAA6B;MACrD,OAAO;MACP,WAAW,MAAM,EAAO,EAAE,OAAO,KAAK;MACtC,aAAa;MACb,IAAG;MACH,GAAI,EAAgB,eAAe;MACnC,eAAY;KACb,CAAA,CACI;;IACN,KACC,kBAAC,KAAD;KAAG,IAAI;KAAa,UAAU;KAAI,MAAK;KAAQ,WAAU;eACtD;IACA,CAAA;IAEL,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,UAAD;MAAQ,MAAK;MAAS,WAAW;MAAc,SAAS;gBACrD,EAAG,iBAAiB,QAAQ;KACvB,CAAA,GACR,kBAAC,UAAD;MAAQ,MAAK;MAAS,WAAW;MAAY,UAAU,EAAgB;gBACpE,EAAgB,YACb,EAAG,6BAA6B,YAAY,IAC5C,EAAG,yBAAyB,+BAA+B;KACzD,CAAA,CACL;;GACD;;CACD,CAAA;AAEX"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SubBankAggregator, SubBankAggregatorInfo, SubBankConnection } from '../../types/banking';
|
|
2
|
+
|
|
3
|
+
export declare const AGGREGATOR_REGION: Record<SubBankAggregator, {
|
|
4
|
+
key: string;
|
|
5
|
+
fallback: string;
|
|
6
|
+
}>;
|
|
7
|
+
interface ConnectBankModalProps {
|
|
8
|
+
aggregators: SubBankAggregatorInfo[];
|
|
9
|
+
/** Reconnect this connection instead of linking a new one. */
|
|
10
|
+
connection?: SubBankConnection | null;
|
|
11
|
+
busy: boolean;
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
onConnect: (aggregator: SubBankAggregator, customerIdentifier: string | null) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function ConnectBankModal({ aggregators, connection, busy, onClose, onConnect, }: ConnectBankModalProps): import("react").JSX.Element;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=ConnectBankModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectBankModal.d.ts","sourceRoot":"","sources":["../../../../src/subscriberbot/pages/banking/ConnectBankModal.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAa7B,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAK1F,CAAC;AAoBF,UAAU,qBAAqB;IAC7B,WAAW,EAAE,qBAAqB,EAAE,CAAC;IACrC,8DAA8D;IAC9D,UAAU,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACtC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,CAAC,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CACvF;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,WAAW,EACX,UAAiB,EACjB,IAAI,EACJ,OAAO,EACP,SAAS,GACV,EAAE,qBAAqB,+BAiJvB"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { useTr as e } from "../../hooks/useTr.js";
|
|
2
|
+
import { cn as t } from "../../utils/cn.js";
|
|
3
|
+
import { Modal as n } from "../../components/Modal.js";
|
|
4
|
+
import "../../components/index.js";
|
|
5
|
+
import { useFormError as r } from "../../hooks/useFormError.js";
|
|
6
|
+
import { useState as i } from "react";
|
|
7
|
+
import { Landmark as a } from "lucide-react";
|
|
8
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
9
|
+
//#region src/subscriberbot/pages/banking/ConnectBankModal.tsx
|
|
10
|
+
var c = "w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]", l = "inline-flex items-center gap-2 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50", u = "inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50", d = /^(\+?91)?[6-9]\d{9}(@[a-z0-9][a-z0-9.-]{1,40})?$/i, f = {
|
|
11
|
+
PLAID: {
|
|
12
|
+
key: "banking.connect.region.plaid",
|
|
13
|
+
fallback: "United States"
|
|
14
|
+
},
|
|
15
|
+
TRUELAYER: {
|
|
16
|
+
key: "banking.connect.region.truelayer",
|
|
17
|
+
fallback: "United Kingdom and Europe"
|
|
18
|
+
},
|
|
19
|
+
ACCOUNT_AGGREGATOR: {
|
|
20
|
+
key: "banking.connect.region.aa",
|
|
21
|
+
fallback: "India"
|
|
22
|
+
},
|
|
23
|
+
STATEMENT_IMPORT: {
|
|
24
|
+
key: "banking.connect.region.import",
|
|
25
|
+
fallback: "Any bank"
|
|
26
|
+
}
|
|
27
|
+
}, p = {
|
|
28
|
+
PLAID: {
|
|
29
|
+
key: "banking.connect.hint.plaid",
|
|
30
|
+
fallback: "Sign in to your bank in Plaid’s secure window."
|
|
31
|
+
},
|
|
32
|
+
TRUELAYER: {
|
|
33
|
+
key: "banking.connect.hint.truelayer",
|
|
34
|
+
fallback: "You continue to your bank to approve read-only access (open banking). Banks ask you to reconfirm every 90 days."
|
|
35
|
+
},
|
|
36
|
+
ACCOUNT_AGGREGATOR: {
|
|
37
|
+
key: "banking.connect.hint.aa",
|
|
38
|
+
fallback: "You approve a consent in your Account Aggregator app (Finvu, OneMoney and others). Your data stays in India."
|
|
39
|
+
},
|
|
40
|
+
STATEMENT_IMPORT: {
|
|
41
|
+
key: "banking.connect.hint.import",
|
|
42
|
+
fallback: ""
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
function m({ aggregators: m, connection: h = null, busy: g, onClose: _, onConnect: v }) {
|
|
46
|
+
let y = e(), b = h ? m.filter((e) => e.aggregator === h.aggregator) : m, [x, S] = i(b.find((e) => e.available)?.aggregator ?? null), [C, w] = i(""), [T, E, D, O] = r(), k = b.find((e) => e.aggregator === x) ?? null;
|
|
47
|
+
return /* @__PURE__ */ o(n, {
|
|
48
|
+
title: h ? y("banking.connect.reconnectTitle", "Reconnect {{institution}}", { institution: h.institutionName }) : y("banking.connect.title", "Connect a bank or card"),
|
|
49
|
+
description: y("banking.connect.description", "Choose where your bank is. Your bank password is never shared with Subscriber Bot."),
|
|
50
|
+
onClose: _,
|
|
51
|
+
maxWidthClassName: "max-w-lg",
|
|
52
|
+
children: /* @__PURE__ */ s("form", {
|
|
53
|
+
onSubmit: (e) => {
|
|
54
|
+
if (e.preventDefault(), E(null), !k || !k.available) return;
|
|
55
|
+
let t = null;
|
|
56
|
+
if (k.requiresCustomerIdentifier && (t = C.replace(/[\s-]/g, ""), !d.test(t))) {
|
|
57
|
+
E(y("banking.connect.handleInvalid", "Enter the 10-digit mobile number registered with your Account Aggregator, for example 9876543210 or 9876543210@onemoney."), "aa-handle");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
v(k.aggregator, t);
|
|
61
|
+
},
|
|
62
|
+
className: "space-y-3",
|
|
63
|
+
"data-testid": "connect-bank-form",
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ s("fieldset", {
|
|
66
|
+
className: "space-y-2",
|
|
67
|
+
children: [/* @__PURE__ */ o("legend", {
|
|
68
|
+
className: "sr-only",
|
|
69
|
+
children: y("banking.connect.choose", "Where is your bank?")
|
|
70
|
+
}), b.map((e) => /* @__PURE__ */ s("label", {
|
|
71
|
+
className: t("flex cursor-pointer items-start gap-3 rounded-xl border p-3", x === e.aggregator ? "border-action-primary-bg" : "border-border-subtle", !e.available && "cursor-not-allowed opacity-60"),
|
|
72
|
+
"data-testid": `connect-option-${e.aggregator}`,
|
|
73
|
+
children: [/* @__PURE__ */ o("input", {
|
|
74
|
+
type: "radio",
|
|
75
|
+
name: "aggregator",
|
|
76
|
+
className: "mt-1",
|
|
77
|
+
value: e.aggregator,
|
|
78
|
+
checked: x === e.aggregator,
|
|
79
|
+
disabled: !e.available,
|
|
80
|
+
onChange: () => {
|
|
81
|
+
S(e.aggregator), E(null);
|
|
82
|
+
}
|
|
83
|
+
}), /* @__PURE__ */ s("span", {
|
|
84
|
+
className: "min-w-0",
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ s("span", {
|
|
87
|
+
className: "flex items-center gap-2 text-sm font-semibold text-text-primary",
|
|
88
|
+
children: [/* @__PURE__ */ o(a, {
|
|
89
|
+
className: "h-4 w-4",
|
|
90
|
+
"aria-hidden": !0
|
|
91
|
+
}), y(f[e.aggregator].key, f[e.aggregator].fallback)]
|
|
92
|
+
}),
|
|
93
|
+
/* @__PURE__ */ s("span", {
|
|
94
|
+
className: "mt-0.5 block text-xs text-text-secondary",
|
|
95
|
+
children: [e.displayName, e.countries.length > 0 && ` · ${e.countries.join(", ")}`]
|
|
96
|
+
}),
|
|
97
|
+
/* @__PURE__ */ o("span", {
|
|
98
|
+
className: "mt-1 block text-xs text-text-secondary",
|
|
99
|
+
children: e.available ? y(p[e.aggregator].key, p[e.aggregator].fallback) : y("banking.connect.unavailable", "Not switched on yet. Import a statement instead.")
|
|
100
|
+
})
|
|
101
|
+
]
|
|
102
|
+
})]
|
|
103
|
+
}, e.aggregator))]
|
|
104
|
+
}),
|
|
105
|
+
k?.requiresCustomerIdentifier && k.available && /* @__PURE__ */ s("label", {
|
|
106
|
+
className: "block text-sm text-text-primary",
|
|
107
|
+
children: [
|
|
108
|
+
y("banking.connect.handle", "Mobile number registered with your Account Aggregator"),
|
|
109
|
+
/* @__PURE__ */ o("input", {
|
|
110
|
+
id: "aa-handle",
|
|
111
|
+
className: t(c, "mt-1"),
|
|
112
|
+
value: C,
|
|
113
|
+
onChange: (e) => w(e.target.value),
|
|
114
|
+
placeholder: "9876543210@onemoney",
|
|
115
|
+
autoComplete: "tel",
|
|
116
|
+
inputMode: "tel",
|
|
117
|
+
maxLength: 64,
|
|
118
|
+
...D("aa-handle"),
|
|
119
|
+
"data-testid": "connect-aa-handle"
|
|
120
|
+
}),
|
|
121
|
+
/* @__PURE__ */ o("span", {
|
|
122
|
+
className: "mt-1 block text-xs text-text-secondary",
|
|
123
|
+
children: y("banking.connect.handleHelp", "Used only to send the consent request to your Account Aggregator; Subscriber Bot does not store it.")
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
}),
|
|
127
|
+
T && /* @__PURE__ */ o("p", {
|
|
128
|
+
id: O,
|
|
129
|
+
tabIndex: -1,
|
|
130
|
+
role: "alert",
|
|
131
|
+
className: "text-sm text-status-error-text",
|
|
132
|
+
children: T
|
|
133
|
+
}),
|
|
134
|
+
/* @__PURE__ */ s("div", {
|
|
135
|
+
className: "flex justify-end gap-2 pt-1",
|
|
136
|
+
children: [/* @__PURE__ */ o("button", {
|
|
137
|
+
type: "button",
|
|
138
|
+
className: u,
|
|
139
|
+
onClick: _,
|
|
140
|
+
children: y("common.cancel", "Cancel")
|
|
141
|
+
}), /* @__PURE__ */ o("button", {
|
|
142
|
+
type: "submit",
|
|
143
|
+
className: l,
|
|
144
|
+
disabled: g || !k?.available,
|
|
145
|
+
"data-testid": "connect-bank-continue",
|
|
146
|
+
children: g ? y("banking.plaid.linking", "Connecting…") : y("banking.connect.continue", "Continue")
|
|
147
|
+
})]
|
|
148
|
+
})
|
|
149
|
+
]
|
|
150
|
+
})
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
export { m as ConnectBankModal };
|
|
155
|
+
|
|
156
|
+
//# sourceMappingURL=ConnectBankModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectBankModal.js","names":[],"sources":["../../../../src/subscriberbot/pages/banking/ConnectBankModal.tsx"],"sourcesContent":["/**\n * Choose how to connect a bank (BOFF-10811)\n * @module subscriberbot/pages/banking\n *\n * Lists the aggregators the service offers for linking: Plaid (US),\n * TrueLayer (UK / EU open banking) and an RBI Account Aggregator (India).\n * The Account Aggregator needs the customer's registered mobile number (or\n * full AA handle) to address the consent; it is passed straight to the\n * service and never kept in the browser.\n */\n\nimport { useState, type FormEvent } from 'react';\nimport { Landmark } from 'lucide-react';\n\nimport { Modal } from '../../components';\nimport { useFormError } from '../../hooks/useFormError';\nimport { useTr } from '../../hooks/useTr';\nimport type {\n SubBankAggregator,\n SubBankAggregatorInfo,\n SubBankConnection,\n} from '../../types/banking';\nimport { cn } from '../../utils/cn';\n\nconst inputCls =\n 'w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\nconst primaryBtn =\n 'inline-flex items-center gap-2 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50';\nconst secondaryBtn =\n 'inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50';\n\n/** A 10-digit Indian mobile number, optionally +91 / 91 prefixed, optionally with @handle. */\nconst AA_HANDLE = /^(\\+?91)?[6-9]\\d{9}(@[a-z0-9][a-z0-9.-]{1,40})?$/i;\n\nexport const AGGREGATOR_REGION: Record<SubBankAggregator, { key: string; fallback: string }> = {\n PLAID: { key: 'banking.connect.region.plaid', fallback: 'United States' },\n TRUELAYER: { key: 'banking.connect.region.truelayer', fallback: 'United Kingdom and Europe' },\n ACCOUNT_AGGREGATOR: { key: 'banking.connect.region.aa', fallback: 'India' },\n STATEMENT_IMPORT: { key: 'banking.connect.region.import', fallback: 'Any bank' },\n};\n\nconst AGGREGATOR_HINT: Record<SubBankAggregator, { key: string; fallback: string }> = {\n PLAID: {\n key: 'banking.connect.hint.plaid',\n fallback: 'Sign in to your bank in Plaid’s secure window.',\n },\n TRUELAYER: {\n key: 'banking.connect.hint.truelayer',\n fallback:\n 'You continue to your bank to approve read-only access (open banking). Banks ask you to reconfirm every 90 days.',\n },\n ACCOUNT_AGGREGATOR: {\n key: 'banking.connect.hint.aa',\n fallback:\n 'You approve a consent in your Account Aggregator app (Finvu, OneMoney and others). Your data stays in India.',\n },\n STATEMENT_IMPORT: { key: 'banking.connect.hint.import', fallback: '' },\n};\n\ninterface ConnectBankModalProps {\n aggregators: SubBankAggregatorInfo[];\n /** Reconnect this connection instead of linking a new one. */\n connection?: SubBankConnection | null;\n busy: boolean;\n onClose: () => void;\n onConnect: (aggregator: SubBankAggregator, customerIdentifier: string | null) => void;\n}\n\nexport function ConnectBankModal({\n aggregators,\n connection = null,\n busy,\n onClose,\n onConnect,\n}: ConnectBankModalProps) {\n const tr = useTr();\n const choices = connection\n ? aggregators.filter((a) => a.aggregator === connection.aggregator)\n : aggregators;\n const firstAvailable = choices.find((a) => a.available)?.aggregator ?? null;\n const [selected, setSelected] = useState<SubBankAggregator | null>(firstAvailable);\n const [handle, setHandle] = useState('');\n const [error, setError, fieldErrorProps, formErrorId] = useFormError();\n const info = choices.find((a) => a.aggregator === selected) ?? null;\n\n const submit = (event: FormEvent) => {\n event.preventDefault();\n setError(null);\n if (!info || !info.available) return;\n let identifier: string | null = null;\n if (info.requiresCustomerIdentifier) {\n identifier = handle.replace(/[\\s-]/g, '');\n if (!AA_HANDLE.test(identifier)) {\n setError(\n tr(\n 'banking.connect.handleInvalid',\n 'Enter the 10-digit mobile number registered with your Account Aggregator, for example 9876543210 or 9876543210@onemoney.'\n ),\n 'aa-handle'\n );\n return;\n }\n }\n onConnect(info.aggregator, identifier);\n };\n\n return (\n <Modal\n title={\n connection\n ? tr('banking.connect.reconnectTitle', 'Reconnect {{institution}}', {\n institution: connection.institutionName,\n })\n : tr('banking.connect.title', 'Connect a bank or card')\n }\n description={tr(\n 'banking.connect.description',\n 'Choose where your bank is. Your bank password is never shared with Subscriber Bot.'\n )}\n onClose={onClose}\n maxWidthClassName=\"max-w-lg\"\n >\n <form onSubmit={submit} className=\"space-y-3\" data-testid=\"connect-bank-form\">\n <fieldset className=\"space-y-2\">\n <legend className=\"sr-only\">{tr('banking.connect.choose', 'Where is your bank?')}</legend>\n {choices.map((a) => (\n <label\n key={a.aggregator}\n className={cn(\n 'flex cursor-pointer items-start gap-3 rounded-xl border p-3',\n selected === a.aggregator ? 'border-action-primary-bg' : 'border-border-subtle',\n !a.available && 'cursor-not-allowed opacity-60'\n )}\n data-testid={`connect-option-${a.aggregator}`}\n >\n <input\n type=\"radio\"\n name=\"aggregator\"\n className=\"mt-1\"\n value={a.aggregator}\n checked={selected === a.aggregator}\n disabled={!a.available}\n onChange={() => {\n setSelected(a.aggregator);\n setError(null);\n }}\n />\n <span className=\"min-w-0\">\n <span className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <Landmark className=\"h-4 w-4\" aria-hidden />\n {tr(\n AGGREGATOR_REGION[a.aggregator].key,\n AGGREGATOR_REGION[a.aggregator].fallback\n )}\n </span>\n <span className=\"mt-0.5 block text-xs text-text-secondary\">\n {a.displayName}\n {a.countries.length > 0 && ` · ${a.countries.join(', ')}`}\n </span>\n <span className=\"mt-1 block text-xs text-text-secondary\">\n {a.available\n ? tr(AGGREGATOR_HINT[a.aggregator].key, AGGREGATOR_HINT[a.aggregator].fallback)\n : tr(\n 'banking.connect.unavailable',\n 'Not switched on yet. Import a statement instead.'\n )}\n </span>\n </span>\n </label>\n ))}\n </fieldset>\n\n {info?.requiresCustomerIdentifier && info.available && (\n <label className=\"block text-sm text-text-primary\">\n {tr('banking.connect.handle', 'Mobile number registered with your Account Aggregator')}\n <input\n id=\"aa-handle\"\n className={cn(inputCls, 'mt-1')}\n value={handle}\n onChange={(e) => setHandle(e.target.value)}\n placeholder=\"9876543210@onemoney\"\n autoComplete=\"tel\"\n inputMode=\"tel\"\n maxLength={64}\n {...fieldErrorProps('aa-handle')}\n data-testid=\"connect-aa-handle\"\n />\n <span className=\"mt-1 block text-xs text-text-secondary\">\n {tr(\n 'banking.connect.handleHelp',\n 'Used only to send the consent request to your Account Aggregator; Subscriber Bot does not store it.'\n )}\n </span>\n </label>\n )}\n\n {error && (\n <p id={formErrorId} tabIndex={-1} role=\"alert\" className=\"text-sm text-status-error-text\">\n {error}\n </p>\n )}\n <div className=\"flex justify-end gap-2 pt-1\">\n <button type=\"button\" className={secondaryBtn} onClick={onClose}>\n {tr('common.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n className={primaryBtn}\n disabled={busy || !info?.available}\n data-testid=\"connect-bank-continue\"\n >\n {busy\n ? tr('banking.plaid.linking', 'Connecting…')\n : tr('banking.connect.continue', 'Continue')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n"],"mappings":";;;;;;;;;AAwBA,IAAM,IACJ,wMACI,IACJ,8JACI,IACJ,gKAGI,IAAY,qDAEL,IAAkF;CAC7F,OAAO;EAAE,KAAK;EAAgC,UAAU;CAAgB;CACxE,WAAW;EAAE,KAAK;EAAoC,UAAU;CAA4B;CAC5F,oBAAoB;EAAE,KAAK;EAA6B,UAAU;CAAQ;CAC1E,kBAAkB;EAAE,KAAK;EAAiC,UAAU;CAAW;AACjF,GAEM,IAAgF;CACpF,OAAO;EACL,KAAK;EACL,UAAU;CACZ;CACA,WAAW;EACT,KAAK;EACL,UACE;CACJ;CACA,oBAAoB;EAClB,KAAK;EACL,UACE;CACJ;CACA,kBAAkB;EAAE,KAAK;EAA+B,UAAU;CAAG;AACvE;AAWA,SAAgB,EAAiB,EAC/B,gBACA,gBAAa,MACb,SACA,YACA,gBACwB;CACxB,IAAM,IAAK,EAAM,GACX,IAAU,IACZ,EAAY,QAAQ,MAAM,EAAE,eAAe,EAAW,UAAU,IAChE,GAEE,CAAC,GAAU,KAAe,EADT,EAAQ,MAAM,MAAM,EAAE,SAAS,GAAG,cAAc,IACU,GAC3E,CAAC,GAAQ,KAAa,EAAS,EAAE,GACjC,CAAC,GAAO,GAAU,GAAiB,KAAe,EAAa,GAC/D,IAAO,EAAQ,MAAM,MAAM,EAAE,eAAe,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AE,aACF,EAAE,UAAU,SAAS,KAAK,MAAM,EAAE,UAAU,KAAK,IAAI,GAClD;;QACN,kBAAC,QAAD;SAAM,WAAU;mBACb,EAAE,YACC,EAAG,EAAgB,EAAE,YAAY,KAAK,EAAgB,EAAE,YAAY,QAAQ,IAC5E,EACE,+BACA,kDACF;QACA,CAAA;OACF;QACD;QAzCA,EAAE,UAyCF,CACR,CACO;;IAET,GAAM,8BAA8B,EAAK,aACxC,kBAAC,SAAD;KAAO,WAAU;eAAjB;MACG,EAAG,0BAA0B,uDAAuD;MACrF,kBAAC,SAAD;OACE,IAAG;OACH,WAAW,EAAG,GAAU,MAAM;OAC9B,OAAO;OACP,WAAW,MAAM,EAAU,EAAE,OAAO,KAAK;OACzC,aAAY;OACZ,cAAa;OACb,WAAU;OACV,WAAW;OACX,GAAI,EAAgB,WAAW;OAC/B,eAAY;MACb,CAAA;MACD,kBAAC,QAAD;OAAM,WAAU;iBACb,EACC,8BACA,qGACF;MACI,CAAA;KACD;;IAGR,KACC,kBAAC,KAAD;KAAG,IAAI;KAAa,UAAU;KAAI,MAAK;KAAQ,WAAU;eACtD;IACA,CAAA;IAEL,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,UAAD;MAAQ,MAAK;MAAS,WAAW;MAAc,SAAS;gBACrD,EAAG,iBAAiB,QAAQ;KACvB,CAAA,GACR,kBAAC,UAAD;MACE,MAAK;MACL,WAAW;MACX,UAAU,KAAQ,CAAC,GAAM;MACzB,eAAY;gBAEX,IACG,EAAG,yBAAyB,aAAa,IACzC,EAAG,4BAA4B,UAAU;KACvC,CAAA,CACL;;GACD;;CACD,CAAA;AAEX"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SubBillingInterval } from './index';
|
|
2
2
|
|
|
3
|
-
export type SubBankAggregator = 'PLAID' | 'STATEMENT_IMPORT';
|
|
3
|
+
export type SubBankAggregator = 'PLAID' | 'TRUELAYER' | 'ACCOUNT_AGGREGATOR' | 'STATEMENT_IMPORT';
|
|
4
|
+
/** How the browser runs an aggregator's flow (BOFF-10811). */
|
|
5
|
+
export type SubBankLinkMode = 'PLAID_LINK' | 'REDIRECT';
|
|
4
6
|
export type SubBankConnectionStatus = 'ACTIVE' | 'NEEDS_REAUTH' | 'ERROR' | 'DISCONNECTED' | 'REVOKED';
|
|
5
7
|
export type SubRecurringChargeStatus = 'DETECTED' | 'TRACKED' | 'DISMISSED';
|
|
6
8
|
export type SubStatementAmountConvention = 'OUTFLOW_NEGATIVE' | 'OUTFLOW_POSITIVE';
|
|
@@ -12,6 +14,9 @@ export interface SubBankAggregatorInfo {
|
|
|
12
14
|
environment: string | null;
|
|
13
15
|
countries: string[];
|
|
14
16
|
requiresLink: boolean;
|
|
17
|
+
linkMode: SubBankLinkMode | null;
|
|
18
|
+
/** The Account Aggregator needs the customer's mobile number / VUA up front. */
|
|
19
|
+
requiresCustomerIdentifier: boolean;
|
|
15
20
|
}
|
|
16
21
|
export interface SubBankAccount {
|
|
17
22
|
id: string;
|
|
@@ -31,6 +36,8 @@ export interface SubBankConnection {
|
|
|
31
36
|
lastSyncedAt: string | null;
|
|
32
37
|
lastSyncError: string | null;
|
|
33
38
|
transactionCount: number;
|
|
39
|
+
/** When the consent has to be reconfirmed (PSD2 90 days, AA consent expiry). */
|
|
40
|
+
consentExpiresAt: string | null;
|
|
34
41
|
createdAt: string;
|
|
35
42
|
updatedAt: string;
|
|
36
43
|
accounts: SubBankAccount[];
|
|
@@ -65,6 +72,8 @@ export interface SubBankSyncResult {
|
|
|
65
72
|
export interface SubBankLinkSession {
|
|
66
73
|
aggregator: SubBankAggregator;
|
|
67
74
|
linkToken: string;
|
|
75
|
+
/** REDIRECT aggregators: where the browser goes to authorise. */
|
|
76
|
+
linkUrl: string | null;
|
|
68
77
|
expiresAt: string | null;
|
|
69
78
|
}
|
|
70
79
|
export interface SubImportBankStatementInput {
|
|
@@ -80,6 +89,8 @@ export interface SubImportBankStatementInput {
|
|
|
80
89
|
export interface SubCompleteBankLinkInput {
|
|
81
90
|
aggregator: SubBankAggregator;
|
|
82
91
|
publicToken: string;
|
|
92
|
+
/** REDIRECT aggregators: the session's linkToken. */
|
|
93
|
+
state?: string | null;
|
|
83
94
|
institutionId?: string | null;
|
|
84
95
|
institutionName?: string | null;
|
|
85
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banking.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/types/banking.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"banking.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/types/banking.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,WAAW,GAAG,oBAAoB,GAAG,kBAAkB,CAAC;AAClG,8DAA8D;AAC9D,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,UAAU,CAAC;AACxD,MAAM,MAAM,uBAAuB,GACjC,QAAQ,GAAG,cAAc,GAAG,OAAO,GAAG,cAAc,GAAG,SAAS,CAAC;AACnE,MAAM,MAAM,wBAAwB,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC;AAC5E,MAAM,MAAM,4BAA4B,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AACnF,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAE3D,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAA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AK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SubBankAggregator } from '../types/banking';
|
|
2
|
+
|
|
3
|
+
export interface PendingBankLink {
|
|
4
|
+
aggregator: SubBankAggregator;
|
|
5
|
+
linkToken: string;
|
|
6
|
+
connectionId: string | null;
|
|
7
|
+
startedAt: number;
|
|
8
|
+
}
|
|
9
|
+
export type BankRedirectResult = {
|
|
10
|
+
kind: 'complete';
|
|
11
|
+
aggregator: SubBankAggregator;
|
|
12
|
+
publicToken: string;
|
|
13
|
+
state: string;
|
|
14
|
+
connectionId: string | null;
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'declined';
|
|
17
|
+
aggregator: SubBankAggregator;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'expired';
|
|
20
|
+
};
|
|
21
|
+
export declare function savePendingBankLink(pending: Omit<PendingBankLink, 'startedAt'>): void;
|
|
22
|
+
/**
|
|
23
|
+
* Read (and remove from the address bar) the result of a redirect flow, if
|
|
24
|
+
* the page was opened by one. Returns null when the URL carries no result.
|
|
25
|
+
*/
|
|
26
|
+
export declare function consumeBankRedirect(): BankRedirectResult | null;
|
|
27
|
+
//# sourceMappingURL=bankRedirectLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bankRedirectLink.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/utils/bankRedirectLink.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAM1D,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,kBAAkB,GAC1B;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,GACD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,iBAAiB,CAAA;CAAE,GACnD;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAUxB,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,GAAG,IAAI,CAErF;AA8BD;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,kBAAkB,GAAG,IAAI,CAyC/D"}
|