@burdenoff/microfe-subscriberbot 2026.1107.6 → 2026.1107.8
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/subscriberbot/components/EmptyState.d.ts +7 -6
- package/dist/subscriberbot/components/EmptyState.d.ts.map +1 -1
- package/dist/subscriberbot/components/EmptyState.js.map +1 -1
- package/dist/subscriberbot/components/index.d.ts +1 -0
- package/dist/subscriberbot/components/index.d.ts.map +1 -1
- package/dist/subscriberbot/pages/DashboardPage.js +1 -1
- package/dist/subscriberbot/pages/DashboardPage.js.map +1 -1
- package/dist/subscriberbot/pages/InboxPage.js +1 -1
- package/dist/subscriberbot/pages/InboxPage.js.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js.map +1 -1
- package/dist/subscriberbot/utils/portfolio.d.ts +4 -3
- package/dist/subscriberbot/utils/portfolio.d.ts.map +1 -1
- package/dist/subscriberbot/utils/portfolio.js +5 -5
- package/dist/subscriberbot/utils/portfolio.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Illustration names the host shells serve at `/illustrations/<name>.webp`.
|
|
5
|
+
* Closed, because any other name has no file and renders as a broken image.
|
|
6
|
+
*/
|
|
7
|
+
export type EmptyStateIllustration = 'empty-data' | 'empty-search' | 'empty-files' | 'empty-people' | 'empty-notifications' | 'onboarding' | 'empty-generic';
|
|
3
8
|
interface EmptyStateProps {
|
|
4
9
|
icon?: ReactNode;
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
* empty-data, empty-search, empty-files, empty-people, empty-notifications,
|
|
8
|
-
* onboarding, empty-generic.
|
|
9
|
-
*/
|
|
10
|
-
illustration?: string;
|
|
10
|
+
/** On-brand illustration, served by the host shell (see {@link EmptyStateIllustration}). */
|
|
11
|
+
illustration?: EmptyStateIllustration;
|
|
11
12
|
title: string;
|
|
12
13
|
description?: string;
|
|
13
14
|
action?: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyState.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/components/EmptyState.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI3C,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB
|
|
1
|
+
{"version":3,"file":"EmptyState.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/components/EmptyState.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI3C;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAC9B,YAAY,GACZ,cAAc,GACd,aAAa,GACb,cAAc,GACd,qBAAqB,GACrB,YAAY,GACZ,eAAe,CAAC;AAEpB,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,4FAA4F;IAC5F,YAAY,CAAC,EAAE,sBAAsB,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA8B1C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyState.js","names":[],"sources":["../../../src/subscriberbot/components/EmptyState.tsx"],"sourcesContent":["/**\n * Empty State Component\n * @module subscriberbot/components\n *\n * Boff UI 2.0 zero-state. When an `illustration` name is provided it renders the\n * fe-libs {@link IllustratedEmptyState} (on-brand glass illustration); otherwise\n * it falls back to the icon-based layout. Host shell serves illustrations from\n * `/illustrations/<name>.webp`.\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\n\
|
|
1
|
+
{"version":3,"file":"EmptyState.js","names":[],"sources":["../../../src/subscriberbot/components/EmptyState.tsx"],"sourcesContent":["/**\n * Empty State Component\n * @module subscriberbot/components\n *\n * Boff UI 2.0 zero-state. When an `illustration` name is provided it renders the\n * fe-libs {@link IllustratedEmptyState} (on-brand glass illustration); otherwise\n * it falls back to the icon-based layout. Host shell serves illustrations from\n * `/illustrations/<name>.webp`.\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\n\n/**\n * Illustration names the host shells serve at `/illustrations/<name>.webp`.\n * Closed, because any other name has no file and renders as a broken image.\n */\nexport type EmptyStateIllustration =\n | 'empty-data'\n | 'empty-search'\n | 'empty-files'\n | 'empty-people'\n | 'empty-notifications'\n | 'onboarding'\n | 'empty-generic';\n\ninterface EmptyStateProps {\n icon?: ReactNode;\n /** On-brand illustration, served by the host shell (see {@link EmptyStateIllustration}). */\n illustration?: EmptyStateIllustration;\n title: string;\n description?: string;\n action?: ReactNode;\n className?: string;\n}\n\nexport const EmptyState: FC<EmptyStateProps> = ({\n icon,\n illustration,\n title,\n description,\n action,\n className,\n}) => {\n if (illustration) {\n return (\n <IllustratedEmptyState\n illustration={illustration}\n title={title}\n description={description}\n action={action}\n className={className}\n />\n );\n }\n\n return (\n <div\n className={cn('flex flex-col items-center justify-center py-12 px-4 text-center', className)}\n >\n {icon && <div className=\"mb-4 text-text-secondary opacity-50\">{icon}</div>}\n <h3 className=\"text-lg font-medium text-text-primary\">{title}</h3>\n {description && <p className=\"mt-2 text-sm text-text-secondary max-w-sm\">{description}</p>}\n {action && <div className=\"mt-6\">{action}</div>}\n </div>\n );\n};\n"],"mappings":";;;;AAqCA,IAAa,KAAmC,EAC9C,SACA,iBACA,UACA,gBACA,WACA,mBAEI,IAEA,kBAAC,GAAD;CACgB;CACP;CACM;CACL;CACG;AACZ,CAAA,IAKH,kBAAC,OAAD;CACE,WAAW,EAAG,oEAAoE,CAAS;WAD7F;EAGG,KAAQ,kBAAC,OAAD;GAAK,WAAU;aAAuC;EAAU,CAAA;EACzE,kBAAC,MAAD;GAAI,WAAU;aAAyC;EAAU,CAAA;EAChE,KAAe,kBAAC,KAAD;GAAG,WAAU;aAA6C;EAAe,CAAA;EACxF,KAAU,kBAAC,OAAD;GAAK,WAAU;aAAQ;EAAY,CAAA;CAC3C"}
|
|
@@ -6,6 +6,7 @@ export { PageLayout } from './PageLayout';
|
|
|
6
6
|
export { MetricsCard } from './MetricsCard';
|
|
7
7
|
export { StatusBadge } from './StatusBadge';
|
|
8
8
|
export { EmptyState } from './EmptyState';
|
|
9
|
+
export type { EmptyStateIllustration } from './EmptyState';
|
|
9
10
|
export { Modal } from './Modal';
|
|
10
11
|
export { PostureOptions } from './PostureOptions';
|
|
11
12
|
export type { PostureOptionsProps } from './PostureOptions';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/components/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EACL,KAAK,EACL,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,YAAY,GACb,MAAM,OAAO,CAAC;AACf,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/components/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EACL,KAAK,EACL,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,YAAY,GACb,MAAM,OAAO,CAAC;AACf,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC"}
|
|
@@ -195,7 +195,7 @@ function j() {
|
|
|
195
195
|
treatment: "plain",
|
|
196
196
|
className: "p-5",
|
|
197
197
|
children: Z.length === 0 ? /* @__PURE__ */ D(o, {
|
|
198
|
-
illustration: "empty-
|
|
198
|
+
illustration: "empty-data",
|
|
199
199
|
title: I("dashboard.renewals.emptyTitle", "No upcoming renewals"),
|
|
200
200
|
description: I("dashboard.renewals.emptyDescription", "Renewals you track will appear here ahead of time.")
|
|
201
201
|
}) : /* @__PURE__ */ D(u, { items: Z })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardPage.js","names":[],"sources":["../../../src/subscriberbot/pages/DashboardPage.tsx"],"sourcesContent":["import { useFormatters } from '../hooks/useFormatters';\n/**\n * Dashboard / Overview\n * @module subscriberbot/pages\n *\n * The Subscriber Bot landing page: a premium fintech console over every\n * recurring digital relationship — total recurring spend, portfolio-by-status,\n * upcoming renewals, the action-required inbox, and outstanding invoices. Every\n * number and chart is COMPUTED from real data returned by\n * `wspace-subscriberbot-svc` — nothing is mocked.\n */\n\nimport { useMemo } from 'react';\nimport {\n Repeat2,\n Wallet,\n CalendarClock,\n Inbox,\n AlertTriangle,\n ArrowRight,\n ArrowUpRight,\n Sparkles,\n Bot,\n ShieldCheck,\n} from 'lucide-react';\nimport { PagePurpose, GlassCard } from '@burdenoff/fe-libs/ui';\nimport {\n PageLayout,\n MetricsCard,\n StatusBadge,\n EmptyState,\n LoadingView,\n ErrorView,\n Section,\n Donut,\n Legend,\n Timeline,\n type Segment,\n type TimelineItem,\n} from '../components';\nimport { useSubscriberBot } from '../context/SubscriberBotContext';\nimport {\n useRelationships,\n useInvoices,\n useInboxMessages,\n useRenewalEvents,\n useDecisions,\n} from '../hooks/useSubscriberBotApi';\nimport { useTr } from '../hooks/useTr';\n\nimport { buildUpcomingRenewals, recurringSpend } from '../utils/portfolio';\nimport { useCompactViewport } from '../hooks/useCompactViewport';\nimport { MobileDashboard } from '../components/mobile';\nimport type { SubRelationship } from '../types';\n\nexport function DashboardPage() {\n const { formatCurrency, formatEnumLabel, formatRelativeTime } = useFormatters();\n\n const { navigateTo, currentUser } = useSubscriberBot();\n const tr = useTr();\n\n const relationshipsQ = useRelationships({ pagination: { limit: 100, offset: 0 } });\n const invoicesQ = useInvoices({ pagination: { limit: 50, offset: 0 } });\n const inboxQ = useInboxMessages({ pagination: { limit: 50, offset: 0 } });\n const renewalsQ = useRenewalEvents({ upcomingOnly: true });\n // Phone layout (BOFF-4010) also surfaces open AI recommendations; the\n // desktop console keeps them on the dedicated decisions page, so only\n // fetch them when the mobile overview will render them.\n const compact = useCompactViewport();\n const decisionsQ = useDecisions({ status: 'PROPOSED' }, { enabled: compact });\n\n const relationships = useMemo(() => relationshipsQ.data?.items ?? [], [relationshipsQ.data]);\n const invoices = useMemo(() => invoicesQ.data?.items ?? [], [invoicesQ.data]);\n const messages = useMemo(() => inboxQ.data?.items ?? [], [inboxQ.data]);\n const renewals = useMemo(() => renewalsQ.data ?? [], [renewalsQ.data]);\n\n // Fast label lookup so mobile AI-recommendation rows can name their relationship.\n const relationshipById = useMemo(() => {\n const map = new Map<string, SubRelationship>();\n relationships.forEach((r) => map.set(r.id, r));\n return map;\n }, [relationships]);\n\n const stats = useMemo(() => {\n const spend = recurringSpend(relationships);\n // BOFF-8660 — KPI must match the Universal Inbox \"need action\" counter\n // and the on-page Needs-attention list, both of which count by\n // `actionRequired` alone (read state is irrelevant). The previous\n // `&& !m.isRead` clause made the tile show 0 the moment the user read\n // the only action-required message, contradicting the surfaces below.\n const actionRequired = messages.filter((m) => m.actionRequired).length;\n const openInvoices = invoices.filter(\n (i) => i.status === 'ISSUED' || i.status === 'OVERDUE' || i.status === 'FAILED'\n );\n const openInvoiceTotal = openInvoices.reduce((sum, i) => sum + i.total, 0);\n const atRisk = relationships.filter(\n (r) => r.status === 'PAST_DUE' || r.status === 'LAPSED'\n ).length;\n\n return {\n activeCount: spend.activeCount,\n totalCount: relationships.length,\n monthlySpend: spend.monthly,\n primaryCurrency: spend.currency,\n actionRequired,\n openInvoiceCount: openInvoices.length,\n openInvoiceTotal,\n atRisk,\n };\n }, [relationships, messages, invoices]);\n\n // Portfolio-by-status → donut segments (grouped from real relationships).\n const statusSegments = useMemo<Segment[]>(() => {\n const counts = new Map<string, number>();\n relationships.forEach((r) => counts.set(r.status, (counts.get(r.status) ?? 0) + 1));\n return Array.from(counts.entries())\n .sort((a, b) => b[1] - a[1])\n .map(([status, value]) => ({ label: formatEnumLabel(status), value }));\n }, [relationships, formatEnumLabel]);\n\n // Upcoming renewals, soonest first: real renewal events when present,\n // otherwise each relationship's own future `renewsAt` (shared with mobile).\n const upcoming = useMemo(\n () => buildUpcomingRenewals(relationships, renewals, (eventType) => formatEnumLabel(eventType)),\n [relationships, renewals, formatEnumLabel]\n );\n\n const timelineItems = useMemo<TimelineItem[]>(\n () =>\n upcoming.slice(0, 6).map((u) => ({\n title: u.title,\n sub: formatRelativeTime(u.when),\n tone: u.soon ? 'warning' : 'default',\n meta:\n u.amount != null\n ? formatCurrency(u.amount, u.currency ?? stats.primaryCurrency, {\n maximumFractionDigits: 0,\n })\n : undefined,\n })),\n [upcoming, stats.primaryCurrency, formatCurrency, formatRelativeTime]\n );\n\n const actionMessages = useMemo(() => messages.filter((m) => m.actionRequired), [messages]);\n\n const isLoading =\n relationshipsQ.isLoading || invoicesQ.isLoading || inboxQ.isLoading || renewalsQ.isLoading;\n const isError =\n relationshipsQ.isError && invoicesQ.isError && inboxQ.isError && renewalsQ.isError;\n\n if (isLoading) {\n return (\n <PageLayout\n dataTour=\"subscriberbot-home\"\n title={tr('dashboard.title', 'Overview')}\n description={tr(\n 'dashboard.description',\n 'Your recurring digital relationships at a glance'\n )}\n >\n <LoadingView label={tr('dashboard.loading', 'Loading your subscription portfolio…')} />\n </PageLayout>\n );\n }\n\n if (isError) {\n return (\n <PageLayout\n dataTour=\"subscriberbot-home\"\n title={tr('dashboard.title', 'Overview')}\n description={tr(\n 'dashboard.description',\n 'Your recurring digital relationships at a glance'\n )}\n >\n <ErrorView\n message={tr(\n 'dashboard.error',\n \"We couldn't reach the Subscriber Bot service. Please try again.\"\n )}\n onRetry={() => {\n void relationshipsQ.refetch();\n void invoicesQ.refetch();\n void inboxQ.refetch();\n void renewalsQ.refetch();\n }}\n />\n </PageLayout>\n );\n }\n\n const greetingName = currentUser?.firstName || currentUser?.name?.split(' ')[0];\n\n if (compact) {\n return (\n <MobileDashboard\n greetingName={greetingName || undefined}\n spend={{\n monthly: stats.monthlySpend,\n currency: stats.primaryCurrency,\n activeCount: stats.activeCount,\n }}\n upcoming={upcoming}\n actionMessages={actionMessages}\n decisions={decisionsQ.data?.items ?? []}\n relationshipLabel={(id) => relationshipById.get(id)?.label}\n openInvoiceCount={stats.openInvoiceCount}\n openInvoiceTotal={stats.openInvoiceTotal}\n navigateTo={navigateTo}\n />\n );\n }\n\n const quickActions = [\n {\n labelKey: 'dashboard.quickActions.addRelationship.label',\n descriptionKey: 'dashboard.quickActions.addRelationship.description',\n fallbackLabel: 'Add a relationship',\n fallbackDescription: 'Track a new subscription',\n icon: <Repeat2 className=\"h-5 w-5\" />,\n path: '/relationships/new',\n },\n {\n labelKey: 'dashboard.quickActions.discoverProviders.label',\n descriptionKey: 'dashboard.quickActions.discoverProviders.description',\n fallbackLabel: 'Discover providers',\n fallbackDescription: 'Browse the registry',\n icon: <Sparkles className=\"h-5 w-5\" />,\n path: '/providers',\n },\n {\n labelKey: 'dashboard.quickActions.openInbox.label',\n descriptionKey: 'dashboard.quickActions.openInbox.description',\n fallbackLabel: 'Open inbox',\n fallbackDescription: 'Merged communications',\n icon: <Inbox className=\"h-5 w-5\" />,\n path: '/inbox',\n },\n {\n labelKey: 'dashboard.quickActions.configureAgents.label',\n descriptionKey: 'dashboard.quickActions.configureAgents.description',\n fallbackLabel: 'Configure agents',\n fallbackDescription: 'Automate your portfolio',\n icon: <Bot className=\"h-5 w-5\" />,\n path: '/agents',\n },\n ];\n\n return (\n <PageLayout\n dataTour=\"subscriberbot-home\"\n title={\n greetingName\n ? tr('dashboard.welcomeBack', 'Welcome back, {{name}}', { name: greetingName })\n : tr('dashboard.title', 'Overview')\n }\n description={tr(\n 'dashboard.description',\n 'Everything you pay for on repeat — in one intelligent console.'\n )}\n >\n <PagePurpose className=\"mb-6\">\n {tr(\n 'dashboard.purpose',\n 'Subscriber Bot is your system of record for every recurring digital relationship. See total recurring spend, what renews next, what needs action, and what to optimize — all from real data across your providers.'\n )}\n </PagePurpose>\n\n {/* KPI tiles */}\n <div\n className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\"\n data-tour=\"subscriberbot-home-metrics\"\n >\n <MetricsCard\n featured\n icon={<Wallet />}\n value={formatCurrency(stats.monthlySpend, stats.primaryCurrency, {\n maximumFractionDigits: 0,\n })}\n label={tr('dashboard.metrics.recurringSpend', 'Recurring spend / month')}\n />\n <MetricsCard\n icon={<Repeat2 />}\n value={stats.activeCount}\n label={tr('dashboard.metrics.activeRelationships', 'Active relationships')}\n />\n <MetricsCard\n icon={<CalendarClock />}\n value={upcoming.length}\n label={tr('dashboard.metrics.upcomingRenewals', 'Upcoming renewals')}\n />\n <MetricsCard\n icon={<AlertTriangle />}\n value={stats.actionRequired}\n label={tr('dashboard.metrics.needsAction', 'Need your action')}\n trend={stats.actionRequired > 0 ? 'down' : undefined}\n />\n </div>\n\n {/* Main console: renewals (left) + portfolio donut & needs-attention (right) */}\n <div className=\"mt-8 grid grid-cols-1 gap-6 lg:grid-cols-3\">\n {/* Upcoming renewals timeline — spans two columns on desktop */}\n <div className=\"lg:col-span-2\">\n <Section\n title={tr('dashboard.renewals.title', 'Upcoming renewals')}\n description={tr(\n 'dashboard.renewals.description',\n \"What's charging next across your portfolio\"\n )}\n className=\"mt-0\"\n dataTour=\"subscriberbot-home-renewals\"\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships')}\n className=\"inline-flex items-center gap-1 text-sm font-medium text-text-link hover:underline\"\n >\n {tr('common.viewAll', 'View all')} <ArrowUpRight className=\"h-3.5 w-3.5\" />\n </button>\n }\n >\n <GlassCard treatment=\"plain\" className=\"p-5\">\n {timelineItems.length === 0 ? (\n <EmptyState\n illustration=\"empty-calendar\"\n title={tr('dashboard.renewals.emptyTitle', 'No upcoming renewals')}\n description={tr(\n 'dashboard.renewals.emptyDescription',\n 'Renewals you track will appear here ahead of time.'\n )}\n />\n ) : (\n <Timeline items={timelineItems} />\n )}\n </GlassCard>\n </Section>\n </div>\n\n {/* Right rail: portfolio-by-status donut + needs-attention panel */}\n <div className=\"flex flex-col gap-6\">\n <Section\n title={tr('dashboard.portfolio.title', 'Portfolio by status')}\n description={tr('dashboard.portfolio.description', 'Where your relationships stand')}\n className=\"mt-0\"\n dataTour=\"subscriberbot-home-portfolio\"\n >\n <GlassCard treatment=\"glass\" className=\"p-5\">\n {statusSegments.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('dashboard.portfolio.emptyTitle', 'No relationships yet')}\n description={tr(\n 'dashboard.portfolio.emptyDescription',\n 'Add your first subscription to see the breakdown.'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships/new')}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90\"\n >\n {tr('dashboard.portfolio.addRelationship', 'Add relationship')}\n </button>\n }\n />\n ) : (\n <div className=\"flex flex-col items-center gap-5 sm:flex-row sm:items-center lg:flex-col xl:flex-row\">\n <Donut\n data={statusSegments}\n size={148}\n thickness={20}\n centerLabel={String(stats.totalCount)}\n centerSub={tr(\n stats.totalCount === 1\n ? 'dashboard.portfolio.relationshipSingular'\n : 'dashboard.portfolio.relationshipPlural',\n stats.totalCount === 1 ? 'relationship' : 'relationships'\n )}\n className=\"shrink-0\"\n />\n <Legend data={statusSegments} className=\"w-full min-w-0 flex-1\" />\n </div>\n )}\n </GlassCard>\n </Section>\n\n <Section\n title={tr('dashboard.needsAttention.title', 'Needs attention')}\n description={tr(\n 'dashboard.needsAttention.description',\n 'Required actions from the Universal Inbox'\n )}\n className=\"mt-0\"\n dataTour=\"subscriberbot-home-needs-attention\"\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/inbox')}\n className=\"text-sm font-medium text-text-link hover:underline\"\n >\n {tr('dashboard.needsAttention.openInbox', 'Open inbox')}\n </button>\n }\n >\n <GlassCard treatment=\"plain\" className=\"p-3\">\n {actionMessages.length === 0 ? (\n <div className=\"flex items-center gap-3 px-2 py-4\">\n <span className=\"flex size-10 shrink-0 items-center justify-center rounded-lg bg-status-success-bg-subtle text-status-success-text\">\n <ShieldCheck className=\"h-5 w-5\" />\n </span>\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-text-primary\">\n {tr('dashboard.needsAttention.allCaughtUp', \"You're all caught up\")}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {tr(\n 'dashboard.needsAttention.allCaughtUpDescription',\n 'Required actions across your channels will surface here.'\n )}\n </p>\n </div>\n </div>\n ) : (\n <ul className=\"space-y-1\">\n {actionMessages.slice(0, 5).map((message) => (\n <li key={message.id}>\n <button\n type=\"button\"\n onClick={() => navigateTo('/inbox')}\n className=\"flex w-full items-center gap-3 rounded-lg border-l-2 border-status-warning-text/60 bg-status-warning-bg-subtle/50 p-3 text-start transition-colors hover:bg-status-warning-bg-subtle\"\n >\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {message.subject ||\n tr('dashboard.needsAttention.noSubject', '(no subject)')}\n </p>\n {message.preview && (\n <p className=\"truncate text-xs text-text-secondary\">\n {message.preview}\n </p>\n )}\n </div>\n <StatusBadge status={message.category} className=\"shrink-0\" />\n </button>\n </li>\n ))}\n </ul>\n )}\n </GlassCard>\n </Section>\n </div>\n </div>\n\n {/* Open-invoice call-out (only when there is real outstanding balance) */}\n {stats.openInvoiceCount > 0 && (\n <button\n type=\"button\"\n onClick={() => navigateTo('/invoices')}\n className=\"mt-6 flex w-full items-center justify-between gap-3 rounded-xl border border-status-warning-text/30 bg-status-warning-bg-subtle px-5 py-4 text-start transition-shadow hover:shadow-md\"\n >\n <div className=\"flex items-center gap-3\">\n <AlertTriangle className=\"h-5 w-5 shrink-0 text-status-warning-text\" />\n <span className=\"text-sm font-medium text-status-warning-text\">\n {tr(\n 'dashboard.openInvoices.label',\n '{{count}} open invoice · {{amount}} outstanding',\n {\n count: stats.openInvoiceCount,\n amount: formatCurrency(stats.openInvoiceTotal, stats.primaryCurrency),\n }\n )}\n </span>\n </div>\n <ArrowRight className=\"rtl:rotate-180 h-4 w-4 shrink-0 text-status-warning-text\" />\n </button>\n )}\n\n {/* Quick actions */}\n <Section\n title={tr('dashboard.quickActions.title', 'Quick actions')}\n description={tr('dashboard.quickActions.description', 'Jump straight into your workflow')}\n dataTour=\"subscriberbot-home-quick-actions\"\n >\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4\">\n {quickActions.map((qa) => (\n <button\n key={qa.path}\n type=\"button\"\n onClick={() => navigateTo(qa.path)}\n className=\"group flex items-center gap-3 rounded-xl border border-border-subtle bg-bg-surface p-4 text-start transition-all hover:-translate-y-0.5 hover:border-border-seam hover:shadow-md\"\n >\n <span className=\"flex size-10 shrink-0 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-primary\">\n {qa.icon}\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block text-sm font-medium text-text-primary\">\n {tr(qa.labelKey, qa.fallbackLabel)}\n </span>\n <span className=\"block text-xs text-text-secondary\">\n {tr(qa.descriptionKey, qa.fallbackDescription)}\n </span>\n </span>\n <ArrowRight className=\"rtl:rotate-180 h-4 w-4 shrink-0 text-text-secondary transition-transform group-hover:translate-x-0.5\" />\n </button>\n ))}\n </div>\n </Section>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuDA,SAAgB,IAAgB;CAC9B,IAAM,EAAE,mBAAgB,oBAAiB,0BAAuB,EAAc,GAExE,EAAE,eAAY,mBAAgB,EAAiB,GAC/C,IAAK,EAAM,GAEX,IAAiB,EAAiB,EAAE,YAAY;EAAE,OAAO;EAAK,QAAQ;CAAE,EAAE,CAAC,GAC3E,IAAY,EAAY,EAAE,YAAY;EAAE,OAAO;EAAI,QAAQ;CAAE,EAAE,CAAC,GAChE,IAAS,EA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AD;SAAM,WAAU;mBACb,EAAG,EAAG,UAAU,EAAG,aAAa;QAC7B,CAAA,GACN,kBAAC,QAAD;SAAM,WAAU;mBACb,EAAG,EAAG,gBAAgB,EAAG,mBAAmB;QACzC,CAAA,CACF;;OACN,kBAAC,GAAD,EAAY,WAAU,uGAAwG,CAAA;MACxH;QAjBD,EAAG,IAiBF,CACT;IACE,CAAA;GACE,CAAA;EACC;;AAEhB"}
|
|
1
|
+
{"version":3,"file":"DashboardPage.js","names":[],"sources":["../../../src/subscriberbot/pages/DashboardPage.tsx"],"sourcesContent":["import { useFormatters } from '../hooks/useFormatters';\n/**\n * Dashboard / Overview\n * @module subscriberbot/pages\n *\n * The Subscriber Bot landing page: a premium fintech console over every\n * recurring digital relationship — total recurring spend, portfolio-by-status,\n * upcoming renewals, the action-required inbox, and outstanding invoices. Every\n * number and chart is COMPUTED from real data returned by\n * `wspace-subscriberbot-svc` — nothing is mocked.\n */\n\nimport { useMemo } from 'react';\nimport {\n Repeat2,\n Wallet,\n CalendarClock,\n Inbox,\n AlertTriangle,\n ArrowRight,\n ArrowUpRight,\n Sparkles,\n Bot,\n ShieldCheck,\n} from 'lucide-react';\nimport { PagePurpose, GlassCard } from '@burdenoff/fe-libs/ui';\nimport {\n PageLayout,\n MetricsCard,\n StatusBadge,\n EmptyState,\n LoadingView,\n ErrorView,\n Section,\n Donut,\n Legend,\n Timeline,\n type Segment,\n type TimelineItem,\n} from '../components';\nimport { useSubscriberBot } from '../context/SubscriberBotContext';\nimport {\n useRelationships,\n useInvoices,\n useInboxMessages,\n useRenewalEvents,\n useDecisions,\n} from '../hooks/useSubscriberBotApi';\nimport { useTr } from '../hooks/useTr';\n\nimport { buildUpcomingRenewals, recurringSpend } from '../utils/portfolio';\nimport { useCompactViewport } from '../hooks/useCompactViewport';\nimport { MobileDashboard } from '../components/mobile';\nimport type { SubRelationship } from '../types';\n\nexport function DashboardPage() {\n const { formatCurrency, formatEnumLabel, formatRelativeTime } = useFormatters();\n\n const { navigateTo, currentUser } = useSubscriberBot();\n const tr = useTr();\n\n const relationshipsQ = useRelationships({ pagination: { limit: 100, offset: 0 } });\n const invoicesQ = useInvoices({ pagination: { limit: 50, offset: 0 } });\n const inboxQ = useInboxMessages({ pagination: { limit: 50, offset: 0 } });\n const renewalsQ = useRenewalEvents({ upcomingOnly: true });\n // Phone layout (BOFF-4010) also surfaces open AI recommendations; the\n // desktop console keeps them on the dedicated decisions page, so only\n // fetch them when the mobile overview will render them.\n const compact = useCompactViewport();\n const decisionsQ = useDecisions({ status: 'PROPOSED' }, { enabled: compact });\n\n const relationships = useMemo(() => relationshipsQ.data?.items ?? [], [relationshipsQ.data]);\n const invoices = useMemo(() => invoicesQ.data?.items ?? [], [invoicesQ.data]);\n const messages = useMemo(() => inboxQ.data?.items ?? [], [inboxQ.data]);\n const renewals = useMemo(() => renewalsQ.data ?? [], [renewalsQ.data]);\n\n // Fast label lookup so mobile AI-recommendation rows can name their relationship.\n const relationshipById = useMemo(() => {\n const map = new Map<string, SubRelationship>();\n relationships.forEach((r) => map.set(r.id, r));\n return map;\n }, [relationships]);\n\n const stats = useMemo(() => {\n const spend = recurringSpend(relationships);\n // BOFF-8660 — KPI must match the Universal Inbox \"need action\" counter\n // and the on-page Needs-attention list, both of which count by\n // `actionRequired` alone (read state is irrelevant). The previous\n // `&& !m.isRead` clause made the tile show 0 the moment the user read\n // the only action-required message, contradicting the surfaces below.\n const actionRequired = messages.filter((m) => m.actionRequired).length;\n const openInvoices = invoices.filter(\n (i) => i.status === 'ISSUED' || i.status === 'OVERDUE' || i.status === 'FAILED'\n );\n const openInvoiceTotal = openInvoices.reduce((sum, i) => sum + i.total, 0);\n const atRisk = relationships.filter(\n (r) => r.status === 'PAST_DUE' || r.status === 'LAPSED'\n ).length;\n\n return {\n activeCount: spend.activeCount,\n totalCount: relationships.length,\n monthlySpend: spend.monthly,\n primaryCurrency: spend.currency,\n actionRequired,\n openInvoiceCount: openInvoices.length,\n openInvoiceTotal,\n atRisk,\n };\n }, [relationships, messages, invoices]);\n\n // Portfolio-by-status → donut segments (grouped from real relationships).\n const statusSegments = useMemo<Segment[]>(() => {\n const counts = new Map<string, number>();\n relationships.forEach((r) => counts.set(r.status, (counts.get(r.status) ?? 0) + 1));\n return Array.from(counts.entries())\n .sort((a, b) => b[1] - a[1])\n .map(([status, value]) => ({ label: formatEnumLabel(status), value }));\n }, [relationships, formatEnumLabel]);\n\n // Upcoming renewals, soonest first: real renewal events when present,\n // otherwise each relationship's own future `renewsAt` (shared with mobile).\n const upcoming = useMemo(\n () => buildUpcomingRenewals(relationships, renewals, (eventType) => formatEnumLabel(eventType)),\n [relationships, renewals, formatEnumLabel]\n );\n\n const timelineItems = useMemo<TimelineItem[]>(\n () =>\n upcoming.slice(0, 6).map((u) => ({\n title: u.title,\n sub: formatRelativeTime(u.when),\n tone: u.soon ? 'warning' : 'default',\n meta:\n u.amount != null\n ? formatCurrency(u.amount, u.currency ?? stats.primaryCurrency, {\n maximumFractionDigits: 0,\n })\n : undefined,\n })),\n [upcoming, stats.primaryCurrency, formatCurrency, formatRelativeTime]\n );\n\n const actionMessages = useMemo(() => messages.filter((m) => m.actionRequired), [messages]);\n\n const isLoading =\n relationshipsQ.isLoading || invoicesQ.isLoading || inboxQ.isLoading || renewalsQ.isLoading;\n const isError =\n relationshipsQ.isError && invoicesQ.isError && inboxQ.isError && renewalsQ.isError;\n\n if (isLoading) {\n return (\n <PageLayout\n dataTour=\"subscriberbot-home\"\n title={tr('dashboard.title', 'Overview')}\n description={tr(\n 'dashboard.description',\n 'Your recurring digital relationships at a glance'\n )}\n >\n <LoadingView label={tr('dashboard.loading', 'Loading your subscription portfolio…')} />\n </PageLayout>\n );\n }\n\n if (isError) {\n return (\n <PageLayout\n dataTour=\"subscriberbot-home\"\n title={tr('dashboard.title', 'Overview')}\n description={tr(\n 'dashboard.description',\n 'Your recurring digital relationships at a glance'\n )}\n >\n <ErrorView\n message={tr(\n 'dashboard.error',\n \"We couldn't reach the Subscriber Bot service. Please try again.\"\n )}\n onRetry={() => {\n void relationshipsQ.refetch();\n void invoicesQ.refetch();\n void inboxQ.refetch();\n void renewalsQ.refetch();\n }}\n />\n </PageLayout>\n );\n }\n\n const greetingName = currentUser?.firstName || currentUser?.name?.split(' ')[0];\n\n if (compact) {\n return (\n <MobileDashboard\n greetingName={greetingName || undefined}\n spend={{\n monthly: stats.monthlySpend,\n currency: stats.primaryCurrency,\n activeCount: stats.activeCount,\n }}\n upcoming={upcoming}\n actionMessages={actionMessages}\n decisions={decisionsQ.data?.items ?? []}\n relationshipLabel={(id) => relationshipById.get(id)?.label}\n openInvoiceCount={stats.openInvoiceCount}\n openInvoiceTotal={stats.openInvoiceTotal}\n navigateTo={navigateTo}\n />\n );\n }\n\n const quickActions = [\n {\n labelKey: 'dashboard.quickActions.addRelationship.label',\n descriptionKey: 'dashboard.quickActions.addRelationship.description',\n fallbackLabel: 'Add a relationship',\n fallbackDescription: 'Track a new subscription',\n icon: <Repeat2 className=\"h-5 w-5\" />,\n path: '/relationships/new',\n },\n {\n labelKey: 'dashboard.quickActions.discoverProviders.label',\n descriptionKey: 'dashboard.quickActions.discoverProviders.description',\n fallbackLabel: 'Discover providers',\n fallbackDescription: 'Browse the registry',\n icon: <Sparkles className=\"h-5 w-5\" />,\n path: '/providers',\n },\n {\n labelKey: 'dashboard.quickActions.openInbox.label',\n descriptionKey: 'dashboard.quickActions.openInbox.description',\n fallbackLabel: 'Open inbox',\n fallbackDescription: 'Merged communications',\n icon: <Inbox className=\"h-5 w-5\" />,\n path: '/inbox',\n },\n {\n labelKey: 'dashboard.quickActions.configureAgents.label',\n descriptionKey: 'dashboard.quickActions.configureAgents.description',\n fallbackLabel: 'Configure agents',\n fallbackDescription: 'Automate your portfolio',\n icon: <Bot className=\"h-5 w-5\" />,\n path: '/agents',\n },\n ];\n\n return (\n <PageLayout\n dataTour=\"subscriberbot-home\"\n title={\n greetingName\n ? tr('dashboard.welcomeBack', 'Welcome back, {{name}}', { name: greetingName })\n : tr('dashboard.title', 'Overview')\n }\n description={tr(\n 'dashboard.description',\n 'Everything you pay for on repeat — in one intelligent console.'\n )}\n >\n <PagePurpose className=\"mb-6\">\n {tr(\n 'dashboard.purpose',\n 'Subscriber Bot is your system of record for every recurring digital relationship. See total recurring spend, what renews next, what needs action, and what to optimize — all from real data across your providers.'\n )}\n </PagePurpose>\n\n {/* KPI tiles */}\n <div\n className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\"\n data-tour=\"subscriberbot-home-metrics\"\n >\n <MetricsCard\n featured\n icon={<Wallet />}\n value={formatCurrency(stats.monthlySpend, stats.primaryCurrency, {\n maximumFractionDigits: 0,\n })}\n label={tr('dashboard.metrics.recurringSpend', 'Recurring spend / month')}\n />\n <MetricsCard\n icon={<Repeat2 />}\n value={stats.activeCount}\n label={tr('dashboard.metrics.activeRelationships', 'Active relationships')}\n />\n <MetricsCard\n icon={<CalendarClock />}\n value={upcoming.length}\n label={tr('dashboard.metrics.upcomingRenewals', 'Upcoming renewals')}\n />\n <MetricsCard\n icon={<AlertTriangle />}\n value={stats.actionRequired}\n label={tr('dashboard.metrics.needsAction', 'Need your action')}\n trend={stats.actionRequired > 0 ? 'down' : undefined}\n />\n </div>\n\n {/* Main console: renewals (left) + portfolio donut & needs-attention (right) */}\n <div className=\"mt-8 grid grid-cols-1 gap-6 lg:grid-cols-3\">\n {/* Upcoming renewals timeline — spans two columns on desktop */}\n <div className=\"lg:col-span-2\">\n <Section\n title={tr('dashboard.renewals.title', 'Upcoming renewals')}\n description={tr(\n 'dashboard.renewals.description',\n \"What's charging next across your portfolio\"\n )}\n className=\"mt-0\"\n dataTour=\"subscriberbot-home-renewals\"\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships')}\n className=\"inline-flex items-center gap-1 text-sm font-medium text-text-link hover:underline\"\n >\n {tr('common.viewAll', 'View all')} <ArrowUpRight className=\"h-3.5 w-3.5\" />\n </button>\n }\n >\n <GlassCard treatment=\"plain\" className=\"p-5\">\n {timelineItems.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('dashboard.renewals.emptyTitle', 'No upcoming renewals')}\n description={tr(\n 'dashboard.renewals.emptyDescription',\n 'Renewals you track will appear here ahead of time.'\n )}\n />\n ) : (\n <Timeline items={timelineItems} />\n )}\n </GlassCard>\n </Section>\n </div>\n\n {/* Right rail: portfolio-by-status donut + needs-attention panel */}\n <div className=\"flex flex-col gap-6\">\n <Section\n title={tr('dashboard.portfolio.title', 'Portfolio by status')}\n description={tr('dashboard.portfolio.description', 'Where your relationships stand')}\n className=\"mt-0\"\n dataTour=\"subscriberbot-home-portfolio\"\n >\n <GlassCard treatment=\"glass\" className=\"p-5\">\n {statusSegments.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('dashboard.portfolio.emptyTitle', 'No relationships yet')}\n description={tr(\n 'dashboard.portfolio.emptyDescription',\n 'Add your first subscription to see the breakdown.'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships/new')}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90\"\n >\n {tr('dashboard.portfolio.addRelationship', 'Add relationship')}\n </button>\n }\n />\n ) : (\n <div className=\"flex flex-col items-center gap-5 sm:flex-row sm:items-center lg:flex-col xl:flex-row\">\n <Donut\n data={statusSegments}\n size={148}\n thickness={20}\n centerLabel={String(stats.totalCount)}\n centerSub={tr(\n stats.totalCount === 1\n ? 'dashboard.portfolio.relationshipSingular'\n : 'dashboard.portfolio.relationshipPlural',\n stats.totalCount === 1 ? 'relationship' : 'relationships'\n )}\n className=\"shrink-0\"\n />\n <Legend data={statusSegments} className=\"w-full min-w-0 flex-1\" />\n </div>\n )}\n </GlassCard>\n </Section>\n\n <Section\n title={tr('dashboard.needsAttention.title', 'Needs attention')}\n description={tr(\n 'dashboard.needsAttention.description',\n 'Required actions from the Universal Inbox'\n )}\n className=\"mt-0\"\n dataTour=\"subscriberbot-home-needs-attention\"\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/inbox')}\n className=\"text-sm font-medium text-text-link hover:underline\"\n >\n {tr('dashboard.needsAttention.openInbox', 'Open inbox')}\n </button>\n }\n >\n <GlassCard treatment=\"plain\" className=\"p-3\">\n {actionMessages.length === 0 ? (\n <div className=\"flex items-center gap-3 px-2 py-4\">\n <span className=\"flex size-10 shrink-0 items-center justify-center rounded-lg bg-status-success-bg-subtle text-status-success-text\">\n <ShieldCheck className=\"h-5 w-5\" />\n </span>\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-text-primary\">\n {tr('dashboard.needsAttention.allCaughtUp', \"You're all caught up\")}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {tr(\n 'dashboard.needsAttention.allCaughtUpDescription',\n 'Required actions across your channels will surface here.'\n )}\n </p>\n </div>\n </div>\n ) : (\n <ul className=\"space-y-1\">\n {actionMessages.slice(0, 5).map((message) => (\n <li key={message.id}>\n <button\n type=\"button\"\n onClick={() => navigateTo('/inbox')}\n className=\"flex w-full items-center gap-3 rounded-lg border-l-2 border-status-warning-text/60 bg-status-warning-bg-subtle/50 p-3 text-start transition-colors hover:bg-status-warning-bg-subtle\"\n >\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {message.subject ||\n tr('dashboard.needsAttention.noSubject', '(no subject)')}\n </p>\n {message.preview && (\n <p className=\"truncate text-xs text-text-secondary\">\n {message.preview}\n </p>\n )}\n </div>\n <StatusBadge status={message.category} className=\"shrink-0\" />\n </button>\n </li>\n ))}\n </ul>\n )}\n </GlassCard>\n </Section>\n </div>\n </div>\n\n {/* Open-invoice call-out (only when there is real outstanding balance) */}\n {stats.openInvoiceCount > 0 && (\n <button\n type=\"button\"\n onClick={() => navigateTo('/invoices')}\n className=\"mt-6 flex w-full items-center justify-between gap-3 rounded-xl border border-status-warning-text/30 bg-status-warning-bg-subtle px-5 py-4 text-start transition-shadow hover:shadow-md\"\n >\n <div className=\"flex items-center gap-3\">\n <AlertTriangle className=\"h-5 w-5 shrink-0 text-status-warning-text\" />\n <span className=\"text-sm font-medium text-status-warning-text\">\n {tr(\n 'dashboard.openInvoices.label',\n '{{count}} open invoice · {{amount}} outstanding',\n {\n count: stats.openInvoiceCount,\n amount: formatCurrency(stats.openInvoiceTotal, stats.primaryCurrency),\n }\n )}\n </span>\n </div>\n <ArrowRight className=\"rtl:rotate-180 h-4 w-4 shrink-0 text-status-warning-text\" />\n </button>\n )}\n\n {/* Quick actions */}\n <Section\n title={tr('dashboard.quickActions.title', 'Quick actions')}\n description={tr('dashboard.quickActions.description', 'Jump straight into your workflow')}\n dataTour=\"subscriberbot-home-quick-actions\"\n >\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4\">\n {quickActions.map((qa) => (\n <button\n key={qa.path}\n type=\"button\"\n onClick={() => navigateTo(qa.path)}\n className=\"group flex items-center gap-3 rounded-xl border border-border-subtle bg-bg-surface p-4 text-start transition-all hover:-translate-y-0.5 hover:border-border-seam hover:shadow-md\"\n >\n <span className=\"flex size-10 shrink-0 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-primary\">\n {qa.icon}\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block text-sm font-medium text-text-primary\">\n {tr(qa.labelKey, qa.fallbackLabel)}\n </span>\n <span className=\"block text-xs text-text-secondary\">\n {tr(qa.descriptionKey, qa.fallbackDescription)}\n </span>\n </span>\n <ArrowRight className=\"rtl:rotate-180 h-4 w-4 shrink-0 text-text-secondary transition-transform group-hover:translate-x-0.5\" />\n </button>\n ))}\n </div>\n </Section>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuDA,SAAgB,IAAgB;CAC9B,IAAM,EAAE,mBAAgB,oBAAiB,0BAAuB,EAAc,GAExE,EAAE,eAAY,mBAAgB,EAAiB,GAC/C,IAAK,EAAM,GAEX,IAAiB,EAAiB,EAAE,YAAY;EAA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I;MACjC,WAAU;gBAJZ;OAME,kBAAC,QAAD;QAAM,WAAU;kBACb,EAAG;OACA,CAAA;OACN,kBAAC,QAAD;QAAM,WAAU;kBAAhB,CACE,kBAAC,QAAD;SAAM,WAAU;mBACb,EAAG,EAAG,UAAU,EAAG,aAAa;QAC7B,CAAA,GACN,kBAAC,QAAD;SAAM,WAAU;mBACb,EAAG,EAAG,gBAAgB,EAAG,mBAAmB;QACzC,CAAA,CACF;;OACN,kBAAC,GAAD,EAAY,WAAU,uGAAwG,CAAA;MACxH;QAjBD,EAAG,IAiBF,CACT;IACE,CAAA;GACE,CAAA;EACC;;AAEhB"}
|
|
@@ -751,7 +751,7 @@ function he() {
|
|
|
751
751
|
}) : B.length === 0 ? /* @__PURE__ */ V("div", {
|
|
752
752
|
className: "mt-6",
|
|
753
753
|
children: /* @__PURE__ */ V(o, {
|
|
754
|
-
illustration: "empty-
|
|
754
|
+
illustration: "empty-notifications",
|
|
755
755
|
icon: /* @__PURE__ */ V(ee, { className: "h-12 w-12" }),
|
|
756
756
|
title: n("inbox.emptyTitle", "Inbox is empty"),
|
|
757
757
|
description: h || d ? n("inbox.emptyDescriptionFiltered", "No messages match these filters.") : n("inbox.emptyDescription", "Merged subscription communications will appear here once channels start ingesting.")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InboxPage.js","names":[],"sources":["../../../src/subscriberbot/pages/InboxPage.tsx"],"sourcesContent":["import { useFormatters } from '../hooks/useFormatters';\nimport { useFormError } from '../hooks/useFormError';\n/**\n * Universal Inbox\n * @module subscriberbot/pages\n *\n * Every merged subscription communication in one timeline, AI-categorized,\n * plus management of the ingest channels that feed it. Filter by category /\n * unread, mark messages read or unread, add & verify channels, and log a test message.\n * Reads `subListInboxMessages` / `subListChannels`; writes `subMarkMessageRead`, `subMarkMessageUnread`,\n * `subCreateChannel`, `subVerifyChannel`, `subIngestMessage`.\n */\n\nimport { useRef, useState } from 'react';\nimport {\n Mail,\n MailOpen,\n AlertTriangle,\n Inbox as InboxIcon,\n Plus,\n Radio,\n BadgeCheck,\n Send,\n MessageSquare,\n MessagesSquare,\n Bell,\n Webhook,\n Phone,\n Hash,\n ShieldAlert,\n Sparkles,\n ChevronRight,\n MousePointerClick,\n MoreHorizontal,\n type LucideIcon,\n} from 'lucide-react';\nimport {\n PagePurpose,\n GlassCard,\n DropdownMenu,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n} from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../components/PageLayout';\nimport { StatusBadge } from '../components/StatusBadge';\nimport { EmptyState } from '../components/EmptyState';\nimport { Modal } from '../components/Modal';\nimport { LoadingView, ErrorView, Section } from '../components/StateViews';\nimport { MiniProgress } from '../components/viz';\nimport { useSubscriberBot } from '../context/SubscriberBotContext';\nimport {\n useInboxMessages,\n useMarkMessageRead,\n useMarkMessageUnread,\n useChannels,\n useCreateChannel,\n useVerifyChannel,\n useIngestMessage,\n} from '../hooks/useSubscriberBotApi';\nimport { useTr } from '../hooks/useTr';\nimport { useRouteSelection } from '../hooks/useRouteSelection';\nimport { cn } from '../utils/cn';\n\nimport type {\n SubChannelType,\n SubCommunicationChannel,\n SubInboxMessage,\n SubMessageCategory,\n} from '../types';\n\nconst PAGE_SIZE = 25;\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 labelCls = 'mb-1 block text-xs font-medium text-text-secondary';\n\nconst MESSAGE_CATEGORIES: SubMessageCategory[] = [\n 'BILLING',\n 'RENEWAL',\n 'REQUIRED_ACTION',\n 'SECURITY_ALERT',\n 'PRODUCT_UPDATE',\n 'MARKETING',\n 'OTHER',\n];\n\nconst CHANNEL_TYPES: SubChannelType[] = [\n 'EMAIL',\n 'SMS',\n 'SLACK',\n 'DISCORD',\n 'WHATSAPP',\n 'PUSH',\n 'WEBHOOK',\n];\n\nconst CATEGORY_KEY: Record<SubMessageCategory, string> = {\n BILLING: 'inbox.categories.billing',\n RENEWAL: 'inbox.categories.renewal',\n REQUIRED_ACTION: 'inbox.categories.requiredAction',\n SECURITY_ALERT: 'inbox.categories.securityAlert',\n PRODUCT_UPDATE: 'inbox.categories.productUpdate',\n MARKETING: 'inbox.categories.marketing',\n OTHER: 'inbox.categories.other',\n};\n\n// Category filter tabs (chips) — the \"All\" pseudo-value plus the real enum.\n// Labels are resolved via useTr inside the page component.\nconst CATEGORY_TAB_VALUES: Array<{\n value: '' | SubMessageCategory;\n key: string;\n fallback: string;\n}> = [\n { value: '', key: 'inbox.categories.all', fallback: 'All' },\n { value: 'BILLING', key: CATEGORY_KEY.BILLING, fallback: 'Billing' },\n { value: 'RENEWAL', key: CATEGORY_KEY.RENEWAL, fallback: 'Renewals' },\n { value: 'REQUIRED_ACTION', key: CATEGORY_KEY.REQUIRED_ACTION, fallback: 'Required actions' },\n { value: 'SECURITY_ALERT', key: CATEGORY_KEY.SECURITY_ALERT, fallback: 'Security' },\n { value: 'PRODUCT_UPDATE', key: CATEGORY_KEY.PRODUCT_UPDATE, fallback: 'Product updates' },\n { value: 'MARKETING', key: CATEGORY_KEY.MARKETING, fallback: 'Marketing' },\n { value: 'OTHER', key: CATEGORY_KEY.OTHER, fallback: 'Other' },\n];\n\n// Per-category tag tone — semantic tokens only.\nconst CATEGORY_TONE: Record<SubMessageCategory, string> = {\n BILLING: 'bg-[var(--color-accent-soft)] text-text-primary',\n RENEWAL: 'bg-status-success-bg-subtle text-status-success-text',\n REQUIRED_ACTION: 'bg-status-warning-bg-subtle text-status-warning-text',\n SECURITY_ALERT: 'bg-status-error-bg-subtle text-status-error-text',\n PRODUCT_UPDATE: 'bg-[var(--color-accent-soft)] text-text-primary',\n MARKETING: 'bg-bg-sunken text-text-secondary',\n OTHER: 'bg-bg-sunken text-text-secondary',\n};\n\nconst CHANNEL_ICON: Record<SubChannelType, LucideIcon> = {\n EMAIL: Mail,\n SMS: MessageSquare,\n SLACK: Hash,\n DISCORD: MessagesSquare,\n WHATSAPP: Phone,\n PUSH: Bell,\n WEBHOOK: Webhook,\n};\n\nfunction CategoryTag({ category }: { category: SubMessageCategory }) {\n const { formatEnumLabel } = useFormatters();\n\n return (\n <span\n className={cn(\n 'inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium',\n CATEGORY_TONE[category]\n )}\n >\n {formatEnumLabel(category)}\n </span>\n );\n}\n\nfunction ActionFlag({ className }: { className?: string }) {\n const tr = useTr();\n return (\n <span\n title={tr('inbox.message.actionRequiredTitle', 'Action required')}\n className={cn(\n 'inline-flex items-center gap-1 rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-[10px] font-medium text-status-warning-text',\n className\n )}\n >\n <AlertTriangle className=\"h-3 w-3\" /> {tr('inbox.message.actionFlag', 'Action')}\n </span>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Add channel modal → subCreateChannel\n// ---------------------------------------------------------------------------\n\nfunction AddChannelModal({ onClose }: { onClose: () => void }) {\n const { formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n const create = useCreateChannel();\n const [type, setType] = useState<SubChannelType>('EMAIL');\n const [address, setAddress] = useState('');\n const [label, setLabel] = useState('');\n const [ingestEnabled, setIngestEnabled] = useState(true);\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n if (!address.trim()) {\n setFormError(\n tr('inbox.addChannelModal.addressRequired', 'An address is required.'),\n 'ch-address'\n );\n return;\n }\n create.mutate(\n {\n type,\n address: address.trim(),\n ingestEnabled,\n ...(label.trim() ? { label: label.trim() } : {}),\n },\n {\n onSuccess: () => onClose(),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('inbox.addChannelModal.error', 'Could not add channel.')\n ),\n }\n );\n };\n\n return (\n <Modal\n title={tr('inbox.addChannelModal.title', 'Add channel')}\n onClose={onClose}\n maxWidthClassName=\"max-w-xl\"\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"ch-type\" className={labelCls}>\n {tr('inbox.addChannelModal.typeLabel', 'Type')}\n </label>\n <select\n {...fieldErrorProps('ch-type')}\n id=\"ch-type\"\n value={type}\n onChange={(e) => setType(e.target.value as SubChannelType)}\n className={inputCls}\n >\n {CHANNEL_TYPES.map((t) => (\n <option key={t} value={t}>\n {formatEnumLabel(t)}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"ch-label\" className={labelCls}>\n {tr('inbox.addChannelModal.labelLabel', 'Label')}\n </label>\n <input\n {...fieldErrorProps('ch-label')}\n id=\"ch-label\"\n type=\"text\"\n value={label}\n onChange={(e) => setLabel(e.target.value)}\n placeholder={tr('inbox.addChannelModal.labelPlaceholder', 'e.g. Billing inbox')}\n className={inputCls}\n />\n </div>\n </div>\n <div>\n <label htmlFor=\"ch-address\" className={labelCls}>\n {tr('inbox.addChannelModal.addressLabel', 'Address')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('ch-address')}\n id=\"ch-address\"\n type=\"text\"\n value={address}\n onChange={(e) => setAddress(e.target.value)}\n placeholder={tr(\n 'inbox.addChannelModal.addressPlaceholder',\n 'e.g. billing@acme.com, +1…, a webhook URL'\n )}\n className={inputCls}\n required\n />\n </div>\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={ingestEnabled}\n onChange={(e) => setIngestEnabled(e.target.checked)}\n className=\"size-4 rounded border-border-subtle\"\n />\n {tr('inbox.addChannelModal.ingestLabel', 'Ingest messages from this channel')}\n </label>\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('inbox.addChannelModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={create.isPending}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {create.isPending\n ? tr('inbox.addChannelModal.adding', 'Adding…')\n : tr('inbox.addChannelModal.submit', 'Add channel')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Log test message modal → subIngestMessage\n// ---------------------------------------------------------------------------\n\nfunction LogMessageModal({\n channel,\n onClose,\n}: {\n channel: SubCommunicationChannel;\n onClose: () => void;\n}) {\n const { formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n const ingest = useIngestMessage();\n const [subject, setSubject] = useState('');\n const [preview, setPreview] = useState('');\n const [category, setCategory] = useState<SubMessageCategory>('OTHER');\n const [actionRequired, setActionRequired] = useState(false);\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n ingest.mutate(\n {\n channelId: channel.id,\n receivedAt: new Date().toISOString(),\n category,\n actionRequired,\n ...(subject.trim() ? { subject: subject.trim() } : {}),\n ...(preview.trim() ? { preview: preview.trim() } : {}),\n },\n {\n onSuccess: () => onClose(),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('inbox.logMessageModal.error', 'Could not log the message.')\n ),\n }\n );\n };\n\n return (\n <Modal\n title={tr('inbox.logMessageModal.title', 'Log test message')}\n description={tr(\n 'inbox.logMessageModal.description',\n 'Simulate an ingested message from {channel}.',\n { channel: channel.label || channel.address }\n )}\n onClose={onClose}\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n <div>\n <label htmlFor=\"msg-subject\" className={labelCls}>\n {tr('inbox.logMessageModal.subjectLabel', 'Subject')}\n </label>\n <input\n {...fieldErrorProps('msg-subject')}\n id=\"msg-subject\"\n type=\"text\"\n value={subject}\n onChange={(e) => setSubject(e.target.value)}\n placeholder={tr(\n 'inbox.logMessageModal.subjectPlaceholder',\n 'e.g. Your plan renews in 3 days'\n )}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"msg-preview\" className={labelCls}>\n {tr('inbox.logMessageModal.previewLabel', 'Preview')}\n </label>\n <textarea\n {...fieldErrorProps('msg-preview')}\n id=\"msg-preview\"\n value={preview}\n onChange={(e) => setPreview(e.target.value)}\n rows={2}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"msg-category\" className={labelCls}>\n {tr('inbox.logMessageModal.categoryLabel', 'Category')}\n </label>\n <select\n {...fieldErrorProps('msg-category')}\n id=\"msg-category\"\n value={category}\n onChange={(e) => setCategory(e.target.value as SubMessageCategory)}\n className={inputCls}\n >\n {MESSAGE_CATEGORIES.map((c) => (\n <option key={c} value={c}>\n {tr(CATEGORY_KEY[c], formatEnumLabel(c))}\n </option>\n ))}\n </select>\n </div>\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={actionRequired}\n onChange={(e) => setActionRequired(e.target.checked)}\n className=\"size-4 rounded border-border-subtle\"\n />\n {tr('inbox.logMessageModal.actionRequired', 'Requires action')}\n </label>\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('inbox.logMessageModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={ingest.isPending}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {ingest.isPending\n ? tr('inbox.logMessageModal.logging', 'Logging…')\n : tr('inbox.logMessageModal.submit', 'Log message')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Channel card → one per ingest source\n// ---------------------------------------------------------------------------\n\nfunction ChannelCard({\n channel,\n onVerify,\n verifying,\n onLog,\n}: {\n channel: SubCommunicationChannel;\n onVerify: (id: string) => void;\n verifying: boolean;\n onLog: (ch: SubCommunicationChannel) => void;\n}) {\n const { formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n const Icon = CHANNEL_ICON[channel.type] ?? Radio;\n const verified = channel.status === 'VERIFIED';\n return (\n <GlassCard treatment=\"metric\" className=\"flex flex-col p-4\">\n <div className=\"flex items-start justify-between gap-2\">\n <div className=\"flex min-w-0 items-center gap-2.5\">\n <span className=\"flex size-9 shrink-0 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-primary\">\n <Icon className=\"h-4 w-4\" />\n </span>\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-semibold text-text-primary\">\n {formatEnumLabel(channel.type)}\n </p>\n {channel.label && (\n <p className=\"truncate text-xs text-text-secondary\">{channel.label}</p>\n )}\n </div>\n </div>\n <StatusBadge status={channel.status} />\n </div>\n\n <div className=\"mt-3 border-t border-border-subtle pt-3\">\n <p className=\"text-[11px] uppercase tracking-wide text-text-secondary\">\n {channel.ingestEnabled\n ? tr('inbox.channels.ingestingFrom', 'Ingesting from')\n : tr('inbox.channels.ingestPaused', 'Ingest paused')}\n </p>\n <p className=\"mt-0.5 truncate text-sm text-text-primary\" title={channel.address}>\n {channel.address}\n </p>\n </div>\n\n <div className=\"mt-auto flex flex-wrap items-center gap-2 pt-3\">\n {channel.status === 'PENDING' && (\n <button\n type=\"button\"\n disabled={verifying}\n onClick={() => onVerify(channel.id)}\n className=\"inline-flex items-center gap-1 rounded-lg bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n <BadgeCheck className=\"h-3.5 w-3.5\" /> {tr('inbox.channels.verify', 'Verify')}\n </button>\n )}\n {verified && channel.ingestEnabled && (\n <button\n type=\"button\"\n onClick={() => onLog(channel)}\n className=\"inline-flex items-center gap-1 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Send className=\"h-3.5 w-3.5\" />{' '}\n {tr('inbox.channels.logTestMessage', 'Log test message')}\n </button>\n )}\n {channel.status === 'DISABLED' && (\n <span className=\"text-xs text-text-secondary\">\n {tr('inbox.channels.disabled', 'Channel disabled')}\n </span>\n )}\n </div>\n </GlassCard>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Channels management panel\n// ---------------------------------------------------------------------------\n\nfunction ChannelsSection() {\n const tr = useTr();\n const { data, isLoading, isError, refetch } = useChannels();\n const verify = useVerifyChannel();\n const [showAdd, setShowAdd] = useState(false);\n const [logChannel, setLogChannel] = useState<SubCommunicationChannel | null>(null);\n\n const channels = data ?? [];\n const verifiedCount = channels.filter((c) => c.status === 'VERIFIED').length;\n const pendingCount = channels.filter((c) => c.status === 'PENDING').length;\n\n return (\n <Section\n title={tr('inbox.channels.title', 'Ingest channels')}\n description={tr(\n 'inbox.channels.description',\n 'The sources the Universal Inbox pulls subscription communication from'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => setShowAdd(true)}\n className=\"inline-flex items-center gap-1.5 rounded-lg bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text hover:opacity-90\"\n >\n <Plus className=\"h-3.5 w-3.5\" /> {tr('inbox.channels.add', 'Add channel')}\n </button>\n }\n >\n {isLoading ? (\n <LoadingView label={tr('inbox.channels.loading', 'Loading channels…')} />\n ) : isError ? (\n <ErrorView\n message={tr('inbox.channels.error', 'Could not load channels.')}\n onRetry={() => void refetch()}\n />\n ) : channels.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n icon={<Radio className=\"h-12 w-12\" />}\n title={tr('inbox.channels.emptyTitle', 'No channels yet')}\n description={tr(\n 'inbox.channels.emptyDescription',\n 'Add an email, SMS, Slack or webhook channel to start ingesting subscription communication.'\n )}\n />\n ) : (\n <>\n {(verifiedCount > 0 || pendingCount > 0) && (\n <div className=\"mb-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-text-secondary\">\n <span className=\"inline-flex items-center gap-1.5\">\n <span className=\"size-1.5 rounded-full bg-status-success-text\" aria-hidden />\n {tr('inbox.channels.verified', '{{count}} verified', { count: verifiedCount })}\n </span>\n {pendingCount > 0 && (\n <span className=\"inline-flex items-center gap-1.5\">\n <span className=\"size-1.5 rounded-full bg-status-warning-text\" aria-hidden />\n {tr('inbox.channels.pending', '{{count}} pending verification', {\n count: pendingCount,\n })}\n </span>\n )}\n </div>\n )}\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3\">\n {channels.map((ch) => (\n <ChannelCard\n key={ch.id}\n channel={ch}\n verifying={verify.isPending}\n onVerify={(id) => verify.mutate(id)}\n onLog={(c) => setLogChannel(c)}\n />\n ))}\n </div>\n </>\n )}\n\n {showAdd && <AddChannelModal onClose={() => setShowAdd(false)} />}\n {logChannel && <LogMessageModal channel={logChannel} onClose={() => setLogChannel(null)} />}\n </Section>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Message row (list)\n// ---------------------------------------------------------------------------\n\nfunction MessageRow({\n message,\n active,\n onSelect,\n onChangeReadState,\n markPending,\n onViewRelationship,\n}: {\n message: SubInboxMessage;\n active: boolean;\n onSelect: () => void;\n onChangeReadState: () => void;\n markPending: boolean;\n onViewRelationship: (() => void) | null;\n}) {\n const { formatRelativeTime } = useFormatters();\n\n const tr = useTr();\n const unread = !message.isRead;\n return (\n <div\n data-inbox-row\n className={cn(\n 'relative flex cursor-pointer items-start gap-3 p-4 transition-colors',\n 'focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] focus-visible:ring-inset',\n active ? 'bg-bg-sunken' : unread ? 'bg-accent-wash' : 'hover:bg-bg-sunken/60'\n )}\n >\n <button\n type=\"button\"\n aria-pressed={active}\n aria-label={tr('inbox.message.open', 'Open message: {{subject}}', {\n subject: message.subject || tr('inbox.message.noSubject', '(no subject)'),\n })}\n onClick={onSelect}\n className=\"absolute inset-0 rounded-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] focus-visible:ring-inset\"\n />\n {/* unread accent rail */}\n {unread && (\n <span\n aria-hidden\n className=\"absolute inset-y-0 start-0 pointer-events-none w-0.5 bg-text-link\"\n />\n )}\n <span className=\"relative pointer-events-none mt-0.5 shrink-0 text-text-secondary\">\n {unread ? <Mail className=\"h-4 w-4 text-text-link\" /> : <MailOpen className=\"h-4 w-4\" />}\n </span>\n <div className=\"relative pointer-events-none min-w-0 flex-1\">\n <div className=\"flex items-center gap-2\">\n {unread && (\n <span\n role=\"img\"\n aria-label={tr('inbox.message.unreadAria', 'Unread')}\n className=\"size-1.5 shrink-0 rounded-full bg-text-link\"\n />\n )}\n <p\n className={cn(\n 'min-w-0 flex-1 truncate text-sm',\n unread ? 'font-semibold text-text-primary' : 'font-normal text-text-primary'\n )}\n >\n {message.subject || tr('inbox.message.noSubject', '(no subject)')}\n </p>\n <span className=\"shrink-0 text-xs tabular-nums text-text-secondary\">\n {formatRelativeTime(message.receivedAt)}\n </span>\n </div>\n {message.preview && (\n <p className=\"mt-0.5 line-clamp-2 text-xs text-text-secondary\">{message.preview}</p>\n )}\n <div className=\"mt-1.5 flex flex-wrap items-center gap-2\">\n <CategoryTag category={message.category} />\n {message.actionRequired && <ActionFlag />}\n {onViewRelationship && (\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n onViewRelationship();\n }}\n className=\"pointer-events-auto text-xs font-medium text-text-link hover:underline\"\n >\n {tr('inbox.message.viewRelationship', 'View relationship')}\n </button>\n )}\n <DropdownMenu modal={false}>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n disabled={markPending}\n aria-label={tr('inbox.message.actions', 'Message actions for {{subject}}', {\n subject: message.subject || tr('inbox.message.noSubject', '(no subject)'),\n })}\n onClick={(event) => event.stopPropagation()}\n className=\"pointer-events-auto ms-auto shrink-0 rounded-lg border border-border-subtle px-2.5 py-1 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n <MoreHorizontal className=\"h-4 w-4\" aria-hidden />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"end\"\n onClick={(event) => event.stopPropagation()}\n onKeyDown={(event) => event.stopPropagation()}\n >\n <DropdownMenuItem disabled={markPending} onSelect={onChangeReadState}>\n {unread\n ? tr('inbox.message.markRead', 'Mark read')\n : tr('inbox.message.markUnread', 'Mark unread')}\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n </div>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Reading pane (wide screens)\n// ---------------------------------------------------------------------------\n\nfunction ReadingPane({\n message,\n channel,\n onChangeReadState,\n markPending,\n onViewRelationship,\n}: {\n message: SubInboxMessage | null;\n channel: SubCommunicationChannel | undefined;\n onChangeReadState: () => void;\n markPending: boolean;\n onViewRelationship: (() => void) | null;\n}) {\n const { formatDateTime } = useFormatters();\n\n const tr = useTr();\n if (!message) {\n return (\n <GlassCard\n treatment=\"metric\"\n className=\"flex min-h-[20rem] flex-col items-center justify-center p-8 text-center\"\n >\n <MousePointerClick className=\"h-10 w-10 text-text-secondary\" />\n <p className=\"mt-3 text-sm font-medium text-text-primary\">\n {tr('inbox.readingPane.selectTitle', 'Select a message')}\n </p>\n <p className=\"mt-1 max-w-[16rem] text-xs text-text-secondary\">\n {tr(\n 'inbox.readingPane.selectDescription',\n 'Pick any message from the list to read the full details here.'\n )}\n </p>\n </GlassCard>\n );\n }\n\n const Icon = channel ? (CHANNEL_ICON[channel.type] ?? Radio) : Radio;\n const confidencePct =\n message.categoryConfidence != null\n ? Math.round(Math.max(0, Math.min(1, message.categoryConfidence)) * 100)\n : null;\n\n return (\n <GlassCard treatment=\"metric\" className=\"flex flex-col p-5\">\n <div className=\"flex items-start justify-between gap-3\">\n <h3 className=\"text-base font-semibold text-text-primary\">\n {message.subject || tr('inbox.message.noSubject', '(no subject)')}\n </h3>\n <button\n type=\"button\"\n disabled={markPending}\n onClick={onChangeReadState}\n className=\"shrink-0 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n {markPending\n ? tr('inbox.message.saving', 'Saving…')\n : message.isRead\n ? tr('inbox.message.markUnread', 'Mark unread')\n : tr('inbox.message.markRead', 'Mark read')}\n </button>\n </div>\n\n {channel && (\n <div className=\"mt-2 flex items-center gap-2 text-sm\">\n <Icon className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n <span className=\"truncate text-text-secondary\" title={channel.address}>\n {channel.address}\n </span>\n </div>\n )}\n\n <div className=\"mt-3 flex flex-wrap items-center gap-2\">\n <CategoryTag category={message.category} />\n {message.actionRequired && <ActionFlag />}\n <span className=\"text-xs text-text-secondary\">{formatDateTime(message.receivedAt)}</span>\n </div>\n\n {confidencePct != null && (\n <div className=\"mt-4 rounded-lg border border-border-subtle bg-bg-surface p-3\">\n <div className=\"flex items-center justify-between text-xs\">\n <span className=\"inline-flex items-center gap-1.5 font-medium text-text-primary\">\n <Sparkles className=\"h-3.5 w-3.5 text-text-link\" />{' '}\n {tr('inbox.readingPane.aiCategorization', 'AI categorization')}\n </span>\n <span className=\"tabular-nums text-text-secondary\">\n {tr('inbox.readingPane.confidence', '{{pct}}% confidence', { pct: confidencePct })}\n </span>\n </div>\n <MiniProgress\n label={tr('inbox.message.confidence', 'Classification confidence')}\n value={confidencePct}\n max={100}\n tone={confidencePct >= 66 ? 'positive' : confidencePct >= 33 ? 'accent' : 'warning'}\n className=\"mt-2\"\n />\n </div>\n )}\n\n <div className=\"mt-4 border-t border-border-subtle pt-4\">\n {message.preview ? (\n <p className=\"whitespace-pre-wrap text-sm leading-relaxed text-text-primary\">\n {message.preview}\n </p>\n ) : (\n <p className=\"text-sm italic text-text-secondary\">\n {tr('inbox.readingPane.noPreview', 'No preview available for this message.')}\n </p>\n )}\n </div>\n\n {message.actionRequired && (\n <div className=\"mt-4 flex items-start gap-2 rounded-lg border border-status-warning-text/30 bg-status-warning-bg-subtle p-3\">\n <ShieldAlert className=\"mt-0.5 h-4 w-4 shrink-0 text-status-warning-text\" />\n <p className=\"text-xs text-status-warning-text\">\n {tr(\n 'inbox.readingPane.attention',\n 'This message needs your attention — review it before its provider deadline.'\n )}\n </p>\n </div>\n )}\n\n {onViewRelationship && (\n <button\n type=\"button\"\n onClick={onViewRelationship}\n className=\"mt-4 inline-flex items-center gap-1 self-start text-sm font-medium text-text-link hover:underline\"\n >\n {tr('inbox.message.viewRelationship', 'View relationship')}{' '}\n <ChevronRight className=\"rtl:rotate-180 h-4 w-4\" />\n </button>\n )}\n </GlassCard>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Filter chip\n// ---------------------------------------------------------------------------\n\nfunction Chip({\n active,\n onClick,\n children,\n tone = 'default',\n}: {\n active: boolean;\n onClick: () => void;\n children: React.ReactNode;\n tone?: 'default' | 'warning';\n}) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n aria-pressed={active}\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-xs font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]',\n active\n ? tone === 'warning'\n ? 'border-transparent bg-status-warning-bg-subtle text-status-warning-text'\n : 'border-transparent bg-action-primary-bg text-action-primary-text'\n : 'border-border-subtle text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n )}\n >\n {children}\n </button>\n );\n}\n\nexport function InboxPage() {\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const [page, setPage] = useState(0);\n const [category, setCategory] = useState<'' | SubMessageCategory>('');\n const [unreadOnly, setUnreadOnly] = useState(false);\n const [actionOnly, setActionOnly] = useState(false);\n // The selected message lives in the URL (/inbox/:selectedId) so it can be\n // deep-linked and the assistant can resolve \"this message\".\n const [selectedId, setSelectedId] = useRouteSelection('inbox');\n\n const { data, isLoading, isError, refetch, isFetching } = useInboxMessages({\n category: category || undefined,\n unreadOnly: unreadOnly || undefined,\n pagination: { limit: PAGE_SIZE, offset: page * PAGE_SIZE },\n });\n const { data: channelsData } = useChannels();\n const markRead = useMarkMessageRead();\n const markUnread = useMarkMessageUnread();\n const readStatePending = useRef(false);\n const [readStateError, setReadStateError] = useState(false);\n const markPending = markRead.isPending || markUnread.isPending;\n const changeReadState = async (message: SubInboxMessage) => {\n // Guard same-frame clicks from row and detail before React renders pending state.\n if (readStatePending.current) return;\n readStatePending.current = true;\n setReadStateError(false);\n try {\n await (message.isRead ? markUnread : markRead).mutateAsync(message.id);\n } catch {\n setReadStateError(true);\n } finally {\n readStatePending.current = false;\n }\n };\n\n const items = data?.items ?? [];\n const hasMore = data?.pageInfo.hasMore ?? false;\n\n // \"Action required\" is a client-side lens over the current page.\n const displayed = actionOnly ? items.filter((m) => m.actionRequired) : items;\n\n // Real, computed page stats.\n const unreadCount = items.filter((m) => !m.isRead).length;\n const actionCount = items.filter((m) => m.actionRequired).length;\n\n const channelMap = new Map((channelsData ?? []).map((c) => [c.id, c]));\n const selected = displayed.find((m) => m.id === selectedId) ?? null;\n const selectedChannel = selected ? channelMap.get(selected.channelId) : undefined;\n\n const resetToFirst = () => {\n setPage(0);\n setSelectedId(null);\n };\n\n return (\n <PageLayout\n title={tr('inbox.title', 'Universal Inbox')}\n description={tr(\n 'inbox.description',\n 'Every subscription communication, merged and categorized'\n )}\n >\n <PagePurpose className=\"mb-4\">\n {tr(\n 'inbox.purpose',\n 'Subscription communication is noisy and scattered. The Universal Inbox merges every channel a provider uses and uses AI to categorize each message so you never miss a renewal, required action or security notice.'\n )}\n </PagePurpose>\n\n {/* Category tabs */}\n <div className=\"-mx-1 flex gap-2 overflow-x-auto px-1 pb-1\">\n {CATEGORY_TAB_VALUES.map((t) => (\n <span key={t.value} className=\"shrink-0\">\n <Chip\n active={category === t.value}\n onClick={() => {\n setCategory(t.value);\n resetToFirst();\n }}\n >\n {tr(t.key, t.fallback)}\n </Chip>\n </span>\n ))}\n </div>\n\n {/* Lenses + stats */}\n <div className=\"mt-3 flex flex-wrap items-center gap-2\">\n <Chip\n active={actionOnly}\n tone=\"warning\"\n onClick={() => {\n setActionOnly((v) => !v);\n setSelectedId(null);\n }}\n >\n <AlertTriangle className=\"h-3.5 w-3.5\" />{' '}\n {tr('inbox.filters.actionRequired', 'Action required')}\n </Chip>\n <Chip\n active={unreadOnly}\n onClick={() => {\n setUnreadOnly((v) => !v);\n resetToFirst();\n }}\n >\n <Mail className=\"h-3.5 w-3.5\" /> {tr('inbox.filters.unreadOnly', 'Unread only')}\n </Chip>\n {!isLoading && !isError && items.length > 0 && (\n <p className=\"ms-auto text-xs text-text-secondary\">\n {tr('inbox.filters.unreadCount', '{{count}} unread', { count: unreadCount })}\n {' · '}\n {tr('inbox.filters.actionCount', '{{count}} need action', { count: actionCount })}\n {isFetching ? ` · ${tr('inbox.filters.refreshing', 'refreshing…')}` : ''}\n </p>\n )}\n </div>\n\n {markPending && (\n <p role=\"status\" className=\"mt-3 text-sm text-text-secondary\">\n {tr('inbox.message.saving', 'Saving…')}\n </p>\n )}\n {readStateError && (\n <p role=\"alert\" className=\"mt-3 text-sm text-status-error-text\">\n {tr('inbox.message.updateError', 'Could not update the message. Please try again.')}\n </p>\n )}\n\n {isLoading ? (\n <LoadingView label={tr('inbox.loading', 'Loading inbox…')} />\n ) : isError ? (\n <ErrorView\n message={tr('inbox.error', 'Could not load the inbox.')}\n onRetry={() => void refetch()}\n />\n ) : items.length === 0 ? (\n <div className=\"mt-6\">\n <EmptyState\n illustration=\"empty-inbox\"\n icon={<InboxIcon className=\"h-12 w-12\" />}\n title={tr('inbox.emptyTitle', 'Inbox is empty')}\n description={\n unreadOnly || category\n ? tr('inbox.emptyDescriptionFiltered', 'No messages match these filters.')\n : tr(\n 'inbox.emptyDescription',\n 'Merged subscription communications will appear here once channels start ingesting.'\n )\n }\n />\n </div>\n ) : (\n <div className=\"mt-5 grid grid-cols-1 gap-5 lg:grid-cols-[minmax(0,1fr)_380px]\">\n {/* List */}\n <div className=\"min-w-0\">\n {displayed.length === 0 ? (\n <div className=\"rounded-xl border border-border-subtle bg-bg-surface p-8 text-center\">\n <AlertTriangle className=\"mx-auto h-8 w-8 text-text-secondary\" />\n <p className=\"mt-2 text-sm font-medium text-text-primary\">\n {tr('inbox.noActionTitle', 'No action-required messages on this page')}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr(\n 'inbox.noActionDescription',\n 'Turn off the “Action required” lens or move to another page.'\n )}\n </p>\n </div>\n ) : (\n <div className=\"divide-y divide-border-subtle overflow-hidden rounded-xl border border-border-subtle bg-bg-surface\">\n {displayed.map((m) => (\n <MessageRow\n key={m.id}\n message={m}\n active={m.id === selectedId}\n onSelect={() => setSelectedId(m.id)}\n onChangeReadState={() => void changeReadState(m)}\n markPending={markPending}\n onViewRelationship={\n m.relationshipId\n ? () => navigateTo(`/relationships/${m.relationshipId}`)\n : null\n }\n />\n ))}\n </div>\n )}\n\n <div className=\"mt-4 flex items-center justify-between\">\n <p className=\"text-xs text-text-secondary\">\n {tr('inbox.pagination.page', 'Page {{page}}', { page: page + 1 })}\n {isFetching ? ` · ${tr('inbox.filters.refreshing', 'refreshing…')}` : ''}\n </p>\n <div className=\"flex gap-2\">\n <button\n type=\"button\"\n disabled={page === 0}\n onClick={() => {\n setPage((p) => Math.max(0, p - 1));\n setSelectedId(null);\n }}\n className={cn(\n 'rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium',\n page === 0\n ? 'cursor-not-allowed text-text-secondary opacity-50'\n : 'text-text-primary hover:bg-bg-sunken'\n )}\n >\n {tr('inbox.pagination.previous', 'Previous')}\n </button>\n <button\n type=\"button\"\n disabled={!hasMore}\n onClick={() => {\n setPage((p) => p + 1);\n setSelectedId(null);\n }}\n className={cn(\n 'rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium',\n !hasMore\n ? 'cursor-not-allowed text-text-secondary opacity-50'\n : 'text-text-primary hover:bg-bg-sunken'\n )}\n >\n {tr('inbox.pagination.next', 'Next')}\n </button>\n </div>\n </div>\n </div>\n\n {/* Reading pane — wide screens only */}\n <aside className=\"hidden lg:block\">\n <div className=\"lg:sticky lg:top-4\">\n <ReadingPane\n message={selected}\n channel={selectedChannel}\n onChangeReadState={() => {\n if (selected) void changeReadState(selected);\n }}\n markPending={markPending}\n onViewRelationship={\n selected?.relationshipId\n ? () => navigateTo(`/relationships/${selected.relationshipId}`)\n : null\n }\n />\n </div>\n </aside>\n </div>\n )}\n\n <ChannelsSection />\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuEA,IAAM,IAAY,IAEZ,IACJ,wMACI,IAAW,sDAEX,IAA2C;CAC/C;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,KAAkC;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,IAAmD;CACvD,SAAS;CACT,SAAS;CACT,iBAAiB;CACjB,gBAAgB;CAChB,gBAAgB;CAChB,WAAW;CACX,OAAO;AACT,GAIM,KAID;CACH;EAAE,OAAO;EAAI,KAAK;EAAwB,UAAU;CAAM;CAC1D;EAAE,OAAO;EAAW,KAAK,EAAa;EAAS,UAAU;CAAU;CACnE;EAAE,OAAO;EAAW,KAAK,EAAa;EAAS,UAAU;CAAW;CACpE;EAAE,OAAO;EAAmB,KAAK,EAAa;EAAiB,UAAU;CAAmB;CAC5F;EAAE,OAAO;EAAkB,KAAK,EAAa;EAAgB,UAAU;CAAW;CAClF;EAAE,OAAO;EAAkB,KAAK,EAAa;EAAgB,UAAU;CAAkB;CACzF;EAAE,OAAO;EAAa,KAAK,EAAa;E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;OACT,yBAAyB;QACvB,AAAI,KAAU,EAAqB,CAAQ;OAC7C;OACa;OACb,oBACE,GAAU,uBACA,EAAW,kBAAkB,EAAS,gBAAgB,IAC5D;MAEP,CAAA;KACE,CAAA;IACA,CAAA,CACJ;;GAGP,kBAAC,IAAD,CAAkB,CAAA;EACR;;AAEhB"}
|
|
1
|
+
{"version":3,"file":"InboxPage.js","names":[],"sources":["../../../src/subscriberbot/pages/InboxPage.tsx"],"sourcesContent":["import { useFormatters } from '../hooks/useFormatters';\nimport { useFormError } from '../hooks/useFormError';\n/**\n * Universal Inbox\n * @module subscriberbot/pages\n *\n * Every merged subscription communication in one timeline, AI-categorized,\n * plus management of the ingest channels that feed it. Filter by category /\n * unread, mark messages read or unread, add & verify channels, and log a test message.\n * Reads `subListInboxMessages` / `subListChannels`; writes `subMarkMessageRead`, `subMarkMessageUnread`,\n * `subCreateChannel`, `subVerifyChannel`, `subIngestMessage`.\n */\n\nimport { useRef, useState } from 'react';\nimport {\n Mail,\n MailOpen,\n AlertTriangle,\n Inbox as InboxIcon,\n Plus,\n Radio,\n BadgeCheck,\n Send,\n MessageSquare,\n MessagesSquare,\n Bell,\n Webhook,\n Phone,\n Hash,\n ShieldAlert,\n Sparkles,\n ChevronRight,\n MousePointerClick,\n MoreHorizontal,\n type LucideIcon,\n} from 'lucide-react';\nimport {\n PagePurpose,\n GlassCard,\n DropdownMenu,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n} from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../components/PageLayout';\nimport { StatusBadge } from '../components/StatusBadge';\nimport { EmptyState } from '../components/EmptyState';\nimport { Modal } from '../components/Modal';\nimport { LoadingView, ErrorView, Section } from '../components/StateViews';\nimport { MiniProgress } from '../components/viz';\nimport { useSubscriberBot } from '../context/SubscriberBotContext';\nimport {\n useInboxMessages,\n useMarkMessageRead,\n useMarkMessageUnread,\n useChannels,\n useCreateChannel,\n useVerifyChannel,\n useIngestMessage,\n} from '../hooks/useSubscriberBotApi';\nimport { useTr } from '../hooks/useTr';\nimport { useRouteSelection } from '../hooks/useRouteSelection';\nimport { cn } from '../utils/cn';\n\nimport type {\n SubChannelType,\n SubCommunicationChannel,\n SubInboxMessage,\n SubMessageCategory,\n} from '../types';\n\nconst PAGE_SIZE = 25;\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 labelCls = 'mb-1 block text-xs font-medium text-text-secondary';\n\nconst MESSAGE_CATEGORIES: SubMessageCategory[] = [\n 'BILLING',\n 'RENEWAL',\n 'REQUIRED_ACTION',\n 'SECURITY_ALERT',\n 'PRODUCT_UPDATE',\n 'MARKETING',\n 'OTHER',\n];\n\nconst CHANNEL_TYPES: SubChannelType[] = [\n 'EMAIL',\n 'SMS',\n 'SLACK',\n 'DISCORD',\n 'WHATSAPP',\n 'PUSH',\n 'WEBHOOK',\n];\n\nconst CATEGORY_KEY: Record<SubMessageCategory, string> = {\n BILLING: 'inbox.categories.billing',\n RENEWAL: 'inbox.categories.renewal',\n REQUIRED_ACTION: 'inbox.categories.requiredAction',\n SECURITY_ALERT: 'inbox.categories.securityAlert',\n PRODUCT_UPDATE: 'inbox.categories.productUpdate',\n MARKETING: 'inbox.categories.marketing',\n OTHER: 'inbox.categories.other',\n};\n\n// Category filter tabs (chips) — the \"All\" pseudo-value plus the real enum.\n// Labels are resolved via useTr inside the page component.\nconst CATEGORY_TAB_VALUES: Array<{\n value: '' | SubMessageCategory;\n key: string;\n fallback: string;\n}> = [\n { value: '', key: 'inbox.categories.all', fallback: 'All' },\n { value: 'BILLING', key: CATEGORY_KEY.BILLING, fallback: 'Billing' },\n { value: 'RENEWAL', key: CATEGORY_KEY.RENEWAL, fallback: 'Renewals' },\n { value: 'REQUIRED_ACTION', key: CATEGORY_KEY.REQUIRED_ACTION, fallback: 'Required actions' },\n { value: 'SECURITY_ALERT', key: CATEGORY_KEY.SECURITY_ALERT, fallback: 'Security' },\n { value: 'PRODUCT_UPDATE', key: CATEGORY_KEY.PRODUCT_UPDATE, fallback: 'Product updates' },\n { value: 'MARKETING', key: CATEGORY_KEY.MARKETING, fallback: 'Marketing' },\n { value: 'OTHER', key: CATEGORY_KEY.OTHER, fallback: 'Other' },\n];\n\n// Per-category tag tone — semantic tokens only.\nconst CATEGORY_TONE: Record<SubMessageCategory, string> = {\n BILLING: 'bg-[var(--color-accent-soft)] text-text-primary',\n RENEWAL: 'bg-status-success-bg-subtle text-status-success-text',\n REQUIRED_ACTION: 'bg-status-warning-bg-subtle text-status-warning-text',\n SECURITY_ALERT: 'bg-status-error-bg-subtle text-status-error-text',\n PRODUCT_UPDATE: 'bg-[var(--color-accent-soft)] text-text-primary',\n MARKETING: 'bg-bg-sunken text-text-secondary',\n OTHER: 'bg-bg-sunken text-text-secondary',\n};\n\nconst CHANNEL_ICON: Record<SubChannelType, LucideIcon> = {\n EMAIL: Mail,\n SMS: MessageSquare,\n SLACK: Hash,\n DISCORD: MessagesSquare,\n WHATSAPP: Phone,\n PUSH: Bell,\n WEBHOOK: Webhook,\n};\n\nfunction CategoryTag({ category }: { category: SubMessageCategory }) {\n const { formatEnumLabel } = useFormatters();\n\n return (\n <span\n className={cn(\n 'inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium',\n CATEGORY_TONE[category]\n )}\n >\n {formatEnumLabel(category)}\n </span>\n );\n}\n\nfunction ActionFlag({ className }: { className?: string }) {\n const tr = useTr();\n return (\n <span\n title={tr('inbox.message.actionRequiredTitle', 'Action required')}\n className={cn(\n 'inline-flex items-center gap-1 rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-[10px] font-medium text-status-warning-text',\n className\n )}\n >\n <AlertTriangle className=\"h-3 w-3\" /> {tr('inbox.message.actionFlag', 'Action')}\n </span>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Add channel modal → subCreateChannel\n// ---------------------------------------------------------------------------\n\nfunction AddChannelModal({ onClose }: { onClose: () => void }) {\n const { formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n const create = useCreateChannel();\n const [type, setType] = useState<SubChannelType>('EMAIL');\n const [address, setAddress] = useState('');\n const [label, setLabel] = useState('');\n const [ingestEnabled, setIngestEnabled] = useState(true);\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n if (!address.trim()) {\n setFormError(\n tr('inbox.addChannelModal.addressRequired', 'An address is required.'),\n 'ch-address'\n );\n return;\n }\n create.mutate(\n {\n type,\n address: address.trim(),\n ingestEnabled,\n ...(label.trim() ? { label: label.trim() } : {}),\n },\n {\n onSuccess: () => onClose(),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('inbox.addChannelModal.error', 'Could not add channel.')\n ),\n }\n );\n };\n\n return (\n <Modal\n title={tr('inbox.addChannelModal.title', 'Add channel')}\n onClose={onClose}\n maxWidthClassName=\"max-w-xl\"\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"ch-type\" className={labelCls}>\n {tr('inbox.addChannelModal.typeLabel', 'Type')}\n </label>\n <select\n {...fieldErrorProps('ch-type')}\n id=\"ch-type\"\n value={type}\n onChange={(e) => setType(e.target.value as SubChannelType)}\n className={inputCls}\n >\n {CHANNEL_TYPES.map((t) => (\n <option key={t} value={t}>\n {formatEnumLabel(t)}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"ch-label\" className={labelCls}>\n {tr('inbox.addChannelModal.labelLabel', 'Label')}\n </label>\n <input\n {...fieldErrorProps('ch-label')}\n id=\"ch-label\"\n type=\"text\"\n value={label}\n onChange={(e) => setLabel(e.target.value)}\n placeholder={tr('inbox.addChannelModal.labelPlaceholder', 'e.g. Billing inbox')}\n className={inputCls}\n />\n </div>\n </div>\n <div>\n <label htmlFor=\"ch-address\" className={labelCls}>\n {tr('inbox.addChannelModal.addressLabel', 'Address')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('ch-address')}\n id=\"ch-address\"\n type=\"text\"\n value={address}\n onChange={(e) => setAddress(e.target.value)}\n placeholder={tr(\n 'inbox.addChannelModal.addressPlaceholder',\n 'e.g. billing@acme.com, +1…, a webhook URL'\n )}\n className={inputCls}\n required\n />\n </div>\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={ingestEnabled}\n onChange={(e) => setIngestEnabled(e.target.checked)}\n className=\"size-4 rounded border-border-subtle\"\n />\n {tr('inbox.addChannelModal.ingestLabel', 'Ingest messages from this channel')}\n </label>\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('inbox.addChannelModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={create.isPending}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {create.isPending\n ? tr('inbox.addChannelModal.adding', 'Adding…')\n : tr('inbox.addChannelModal.submit', 'Add channel')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Log test message modal → subIngestMessage\n// ---------------------------------------------------------------------------\n\nfunction LogMessageModal({\n channel,\n onClose,\n}: {\n channel: SubCommunicationChannel;\n onClose: () => void;\n}) {\n const { formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n const ingest = useIngestMessage();\n const [subject, setSubject] = useState('');\n const [preview, setPreview] = useState('');\n const [category, setCategory] = useState<SubMessageCategory>('OTHER');\n const [actionRequired, setActionRequired] = useState(false);\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n ingest.mutate(\n {\n channelId: channel.id,\n receivedAt: new Date().toISOString(),\n category,\n actionRequired,\n ...(subject.trim() ? { subject: subject.trim() } : {}),\n ...(preview.trim() ? { preview: preview.trim() } : {}),\n },\n {\n onSuccess: () => onClose(),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('inbox.logMessageModal.error', 'Could not log the message.')\n ),\n }\n );\n };\n\n return (\n <Modal\n title={tr('inbox.logMessageModal.title', 'Log test message')}\n description={tr(\n 'inbox.logMessageModal.description',\n 'Simulate an ingested message from {channel}.',\n { channel: channel.label || channel.address }\n )}\n onClose={onClose}\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n <div>\n <label htmlFor=\"msg-subject\" className={labelCls}>\n {tr('inbox.logMessageModal.subjectLabel', 'Subject')}\n </label>\n <input\n {...fieldErrorProps('msg-subject')}\n id=\"msg-subject\"\n type=\"text\"\n value={subject}\n onChange={(e) => setSubject(e.target.value)}\n placeholder={tr(\n 'inbox.logMessageModal.subjectPlaceholder',\n 'e.g. Your plan renews in 3 days'\n )}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"msg-preview\" className={labelCls}>\n {tr('inbox.logMessageModal.previewLabel', 'Preview')}\n </label>\n <textarea\n {...fieldErrorProps('msg-preview')}\n id=\"msg-preview\"\n value={preview}\n onChange={(e) => setPreview(e.target.value)}\n rows={2}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"msg-category\" className={labelCls}>\n {tr('inbox.logMessageModal.categoryLabel', 'Category')}\n </label>\n <select\n {...fieldErrorProps('msg-category')}\n id=\"msg-category\"\n value={category}\n onChange={(e) => setCategory(e.target.value as SubMessageCategory)}\n className={inputCls}\n >\n {MESSAGE_CATEGORIES.map((c) => (\n <option key={c} value={c}>\n {tr(CATEGORY_KEY[c], formatEnumLabel(c))}\n </option>\n ))}\n </select>\n </div>\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={actionRequired}\n onChange={(e) => setActionRequired(e.target.checked)}\n className=\"size-4 rounded border-border-subtle\"\n />\n {tr('inbox.logMessageModal.actionRequired', 'Requires action')}\n </label>\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('inbox.logMessageModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={ingest.isPending}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {ingest.isPending\n ? tr('inbox.logMessageModal.logging', 'Logging…')\n : tr('inbox.logMessageModal.submit', 'Log message')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Channel card → one per ingest source\n// ---------------------------------------------------------------------------\n\nfunction ChannelCard({\n channel,\n onVerify,\n verifying,\n onLog,\n}: {\n channel: SubCommunicationChannel;\n onVerify: (id: string) => void;\n verifying: boolean;\n onLog: (ch: SubCommunicationChannel) => void;\n}) {\n const { formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n const Icon = CHANNEL_ICON[channel.type] ?? Radio;\n const verified = channel.status === 'VERIFIED';\n return (\n <GlassCard treatment=\"metric\" className=\"flex flex-col p-4\">\n <div className=\"flex items-start justify-between gap-2\">\n <div className=\"flex min-w-0 items-center gap-2.5\">\n <span className=\"flex size-9 shrink-0 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-primary\">\n <Icon className=\"h-4 w-4\" />\n </span>\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-semibold text-text-primary\">\n {formatEnumLabel(channel.type)}\n </p>\n {channel.label && (\n <p className=\"truncate text-xs text-text-secondary\">{channel.label}</p>\n )}\n </div>\n </div>\n <StatusBadge status={channel.status} />\n </div>\n\n <div className=\"mt-3 border-t border-border-subtle pt-3\">\n <p className=\"text-[11px] uppercase tracking-wide text-text-secondary\">\n {channel.ingestEnabled\n ? tr('inbox.channels.ingestingFrom', 'Ingesting from')\n : tr('inbox.channels.ingestPaused', 'Ingest paused')}\n </p>\n <p className=\"mt-0.5 truncate text-sm text-text-primary\" title={channel.address}>\n {channel.address}\n </p>\n </div>\n\n <div className=\"mt-auto flex flex-wrap items-center gap-2 pt-3\">\n {channel.status === 'PENDING' && (\n <button\n type=\"button\"\n disabled={verifying}\n onClick={() => onVerify(channel.id)}\n className=\"inline-flex items-center gap-1 rounded-lg bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n <BadgeCheck className=\"h-3.5 w-3.5\" /> {tr('inbox.channels.verify', 'Verify')}\n </button>\n )}\n {verified && channel.ingestEnabled && (\n <button\n type=\"button\"\n onClick={() => onLog(channel)}\n className=\"inline-flex items-center gap-1 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Send className=\"h-3.5 w-3.5\" />{' '}\n {tr('inbox.channels.logTestMessage', 'Log test message')}\n </button>\n )}\n {channel.status === 'DISABLED' && (\n <span className=\"text-xs text-text-secondary\">\n {tr('inbox.channels.disabled', 'Channel disabled')}\n </span>\n )}\n </div>\n </GlassCard>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Channels management panel\n// ---------------------------------------------------------------------------\n\nfunction ChannelsSection() {\n const tr = useTr();\n const { data, isLoading, isError, refetch } = useChannels();\n const verify = useVerifyChannel();\n const [showAdd, setShowAdd] = useState(false);\n const [logChannel, setLogChannel] = useState<SubCommunicationChannel | null>(null);\n\n const channels = data ?? [];\n const verifiedCount = channels.filter((c) => c.status === 'VERIFIED').length;\n const pendingCount = channels.filter((c) => c.status === 'PENDING').length;\n\n return (\n <Section\n title={tr('inbox.channels.title', 'Ingest channels')}\n description={tr(\n 'inbox.channels.description',\n 'The sources the Universal Inbox pulls subscription communication from'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => setShowAdd(true)}\n className=\"inline-flex items-center gap-1.5 rounded-lg bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text hover:opacity-90\"\n >\n <Plus className=\"h-3.5 w-3.5\" /> {tr('inbox.channels.add', 'Add channel')}\n </button>\n }\n >\n {isLoading ? (\n <LoadingView label={tr('inbox.channels.loading', 'Loading channels…')} />\n ) : isError ? (\n <ErrorView\n message={tr('inbox.channels.error', 'Could not load channels.')}\n onRetry={() => void refetch()}\n />\n ) : channels.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n icon={<Radio className=\"h-12 w-12\" />}\n title={tr('inbox.channels.emptyTitle', 'No channels yet')}\n description={tr(\n 'inbox.channels.emptyDescription',\n 'Add an email, SMS, Slack or webhook channel to start ingesting subscription communication.'\n )}\n />\n ) : (\n <>\n {(verifiedCount > 0 || pendingCount > 0) && (\n <div className=\"mb-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-text-secondary\">\n <span className=\"inline-flex items-center gap-1.5\">\n <span className=\"size-1.5 rounded-full bg-status-success-text\" aria-hidden />\n {tr('inbox.channels.verified', '{{count}} verified', { count: verifiedCount })}\n </span>\n {pendingCount > 0 && (\n <span className=\"inline-flex items-center gap-1.5\">\n <span className=\"size-1.5 rounded-full bg-status-warning-text\" aria-hidden />\n {tr('inbox.channels.pending', '{{count}} pending verification', {\n count: pendingCount,\n })}\n </span>\n )}\n </div>\n )}\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3\">\n {channels.map((ch) => (\n <ChannelCard\n key={ch.id}\n channel={ch}\n verifying={verify.isPending}\n onVerify={(id) => verify.mutate(id)}\n onLog={(c) => setLogChannel(c)}\n />\n ))}\n </div>\n </>\n )}\n\n {showAdd && <AddChannelModal onClose={() => setShowAdd(false)} />}\n {logChannel && <LogMessageModal channel={logChannel} onClose={() => setLogChannel(null)} />}\n </Section>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Message row (list)\n// ---------------------------------------------------------------------------\n\nfunction MessageRow({\n message,\n active,\n onSelect,\n onChangeReadState,\n markPending,\n onViewRelationship,\n}: {\n message: SubInboxMessage;\n active: boolean;\n onSelect: () => void;\n onChangeReadState: () => void;\n markPending: boolean;\n onViewRelationship: (() => void) | null;\n}) {\n const { formatRelativeTime } = useFormatters();\n\n const tr = useTr();\n const unread = !message.isRead;\n return (\n <div\n data-inbox-row\n className={cn(\n 'relative flex cursor-pointer items-start gap-3 p-4 transition-colors',\n 'focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] focus-visible:ring-inset',\n active ? 'bg-bg-sunken' : unread ? 'bg-accent-wash' : 'hover:bg-bg-sunken/60'\n )}\n >\n <button\n type=\"button\"\n aria-pressed={active}\n aria-label={tr('inbox.message.open', 'Open message: {{subject}}', {\n subject: message.subject || tr('inbox.message.noSubject', '(no subject)'),\n })}\n onClick={onSelect}\n className=\"absolute inset-0 rounded-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] focus-visible:ring-inset\"\n />\n {/* unread accent rail */}\n {unread && (\n <span\n aria-hidden\n className=\"absolute inset-y-0 start-0 pointer-events-none w-0.5 bg-text-link\"\n />\n )}\n <span className=\"relative pointer-events-none mt-0.5 shrink-0 text-text-secondary\">\n {unread ? <Mail className=\"h-4 w-4 text-text-link\" /> : <MailOpen className=\"h-4 w-4\" />}\n </span>\n <div className=\"relative pointer-events-none min-w-0 flex-1\">\n <div className=\"flex items-center gap-2\">\n {unread && (\n <span\n role=\"img\"\n aria-label={tr('inbox.message.unreadAria', 'Unread')}\n className=\"size-1.5 shrink-0 rounded-full bg-text-link\"\n />\n )}\n <p\n className={cn(\n 'min-w-0 flex-1 truncate text-sm',\n unread ? 'font-semibold text-text-primary' : 'font-normal text-text-primary'\n )}\n >\n {message.subject || tr('inbox.message.noSubject', '(no subject)')}\n </p>\n <span className=\"shrink-0 text-xs tabular-nums text-text-secondary\">\n {formatRelativeTime(message.receivedAt)}\n </span>\n </div>\n {message.preview && (\n <p className=\"mt-0.5 line-clamp-2 text-xs text-text-secondary\">{message.preview}</p>\n )}\n <div className=\"mt-1.5 flex flex-wrap items-center gap-2\">\n <CategoryTag category={message.category} />\n {message.actionRequired && <ActionFlag />}\n {onViewRelationship && (\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n onViewRelationship();\n }}\n className=\"pointer-events-auto text-xs font-medium text-text-link hover:underline\"\n >\n {tr('inbox.message.viewRelationship', 'View relationship')}\n </button>\n )}\n <DropdownMenu modal={false}>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n disabled={markPending}\n aria-label={tr('inbox.message.actions', 'Message actions for {{subject}}', {\n subject: message.subject || tr('inbox.message.noSubject', '(no subject)'),\n })}\n onClick={(event) => event.stopPropagation()}\n className=\"pointer-events-auto ms-auto shrink-0 rounded-lg border border-border-subtle px-2.5 py-1 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n <MoreHorizontal className=\"h-4 w-4\" aria-hidden />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"end\"\n onClick={(event) => event.stopPropagation()}\n onKeyDown={(event) => event.stopPropagation()}\n >\n <DropdownMenuItem disabled={markPending} onSelect={onChangeReadState}>\n {unread\n ? tr('inbox.message.markRead', 'Mark read')\n : tr('inbox.message.markUnread', 'Mark unread')}\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n </div>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Reading pane (wide screens)\n// ---------------------------------------------------------------------------\n\nfunction ReadingPane({\n message,\n channel,\n onChangeReadState,\n markPending,\n onViewRelationship,\n}: {\n message: SubInboxMessage | null;\n channel: SubCommunicationChannel | undefined;\n onChangeReadState: () => void;\n markPending: boolean;\n onViewRelationship: (() => void) | null;\n}) {\n const { formatDateTime } = useFormatters();\n\n const tr = useTr();\n if (!message) {\n return (\n <GlassCard\n treatment=\"metric\"\n className=\"flex min-h-[20rem] flex-col items-center justify-center p-8 text-center\"\n >\n <MousePointerClick className=\"h-10 w-10 text-text-secondary\" />\n <p className=\"mt-3 text-sm font-medium text-text-primary\">\n {tr('inbox.readingPane.selectTitle', 'Select a message')}\n </p>\n <p className=\"mt-1 max-w-[16rem] text-xs text-text-secondary\">\n {tr(\n 'inbox.readingPane.selectDescription',\n 'Pick any message from the list to read the full details here.'\n )}\n </p>\n </GlassCard>\n );\n }\n\n const Icon = channel ? (CHANNEL_ICON[channel.type] ?? Radio) : Radio;\n const confidencePct =\n message.categoryConfidence != null\n ? Math.round(Math.max(0, Math.min(1, message.categoryConfidence)) * 100)\n : null;\n\n return (\n <GlassCard treatment=\"metric\" className=\"flex flex-col p-5\">\n <div className=\"flex items-start justify-between gap-3\">\n <h3 className=\"text-base font-semibold text-text-primary\">\n {message.subject || tr('inbox.message.noSubject', '(no subject)')}\n </h3>\n <button\n type=\"button\"\n disabled={markPending}\n onClick={onChangeReadState}\n className=\"shrink-0 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n {markPending\n ? tr('inbox.message.saving', 'Saving…')\n : message.isRead\n ? tr('inbox.message.markUnread', 'Mark unread')\n : tr('inbox.message.markRead', 'Mark read')}\n </button>\n </div>\n\n {channel && (\n <div className=\"mt-2 flex items-center gap-2 text-sm\">\n <Icon className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n <span className=\"truncate text-text-secondary\" title={channel.address}>\n {channel.address}\n </span>\n </div>\n )}\n\n <div className=\"mt-3 flex flex-wrap items-center gap-2\">\n <CategoryTag category={message.category} />\n {message.actionRequired && <ActionFlag />}\n <span className=\"text-xs text-text-secondary\">{formatDateTime(message.receivedAt)}</span>\n </div>\n\n {confidencePct != null && (\n <div className=\"mt-4 rounded-lg border border-border-subtle bg-bg-surface p-3\">\n <div className=\"flex items-center justify-between text-xs\">\n <span className=\"inline-flex items-center gap-1.5 font-medium text-text-primary\">\n <Sparkles className=\"h-3.5 w-3.5 text-text-link\" />{' '}\n {tr('inbox.readingPane.aiCategorization', 'AI categorization')}\n </span>\n <span className=\"tabular-nums text-text-secondary\">\n {tr('inbox.readingPane.confidence', '{{pct}}% confidence', { pct: confidencePct })}\n </span>\n </div>\n <MiniProgress\n label={tr('inbox.message.confidence', 'Classification confidence')}\n value={confidencePct}\n max={100}\n tone={confidencePct >= 66 ? 'positive' : confidencePct >= 33 ? 'accent' : 'warning'}\n className=\"mt-2\"\n />\n </div>\n )}\n\n <div className=\"mt-4 border-t border-border-subtle pt-4\">\n {message.preview ? (\n <p className=\"whitespace-pre-wrap text-sm leading-relaxed text-text-primary\">\n {message.preview}\n </p>\n ) : (\n <p className=\"text-sm italic text-text-secondary\">\n {tr('inbox.readingPane.noPreview', 'No preview available for this message.')}\n </p>\n )}\n </div>\n\n {message.actionRequired && (\n <div className=\"mt-4 flex items-start gap-2 rounded-lg border border-status-warning-text/30 bg-status-warning-bg-subtle p-3\">\n <ShieldAlert className=\"mt-0.5 h-4 w-4 shrink-0 text-status-warning-text\" />\n <p className=\"text-xs text-status-warning-text\">\n {tr(\n 'inbox.readingPane.attention',\n 'This message needs your attention — review it before its provider deadline.'\n )}\n </p>\n </div>\n )}\n\n {onViewRelationship && (\n <button\n type=\"button\"\n onClick={onViewRelationship}\n className=\"mt-4 inline-flex items-center gap-1 self-start text-sm font-medium text-text-link hover:underline\"\n >\n {tr('inbox.message.viewRelationship', 'View relationship')}{' '}\n <ChevronRight className=\"rtl:rotate-180 h-4 w-4\" />\n </button>\n )}\n </GlassCard>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Filter chip\n// ---------------------------------------------------------------------------\n\nfunction Chip({\n active,\n onClick,\n children,\n tone = 'default',\n}: {\n active: boolean;\n onClick: () => void;\n children: React.ReactNode;\n tone?: 'default' | 'warning';\n}) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n aria-pressed={active}\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-xs font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]',\n active\n ? tone === 'warning'\n ? 'border-transparent bg-status-warning-bg-subtle text-status-warning-text'\n : 'border-transparent bg-action-primary-bg text-action-primary-text'\n : 'border-border-subtle text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n )}\n >\n {children}\n </button>\n );\n}\n\nexport function InboxPage() {\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const [page, setPage] = useState(0);\n const [category, setCategory] = useState<'' | SubMessageCategory>('');\n const [unreadOnly, setUnreadOnly] = useState(false);\n const [actionOnly, setActionOnly] = useState(false);\n // The selected message lives in the URL (/inbox/:selectedId) so it can be\n // deep-linked and the assistant can resolve \"this message\".\n const [selectedId, setSelectedId] = useRouteSelection('inbox');\n\n const { data, isLoading, isError, refetch, isFetching } = useInboxMessages({\n category: category || undefined,\n unreadOnly: unreadOnly || undefined,\n pagination: { limit: PAGE_SIZE, offset: page * PAGE_SIZE },\n });\n const { data: channelsData } = useChannels();\n const markRead = useMarkMessageRead();\n const markUnread = useMarkMessageUnread();\n const readStatePending = useRef(false);\n const [readStateError, setReadStateError] = useState(false);\n const markPending = markRead.isPending || markUnread.isPending;\n const changeReadState = async (message: SubInboxMessage) => {\n // Guard same-frame clicks from row and detail before React renders pending state.\n if (readStatePending.current) return;\n readStatePending.current = true;\n setReadStateError(false);\n try {\n await (message.isRead ? markUnread : markRead).mutateAsync(message.id);\n } catch {\n setReadStateError(true);\n } finally {\n readStatePending.current = false;\n }\n };\n\n const items = data?.items ?? [];\n const hasMore = data?.pageInfo.hasMore ?? false;\n\n // \"Action required\" is a client-side lens over the current page.\n const displayed = actionOnly ? items.filter((m) => m.actionRequired) : items;\n\n // Real, computed page stats.\n const unreadCount = items.filter((m) => !m.isRead).length;\n const actionCount = items.filter((m) => m.actionRequired).length;\n\n const channelMap = new Map((channelsData ?? []).map((c) => [c.id, c]));\n const selected = displayed.find((m) => m.id === selectedId) ?? null;\n const selectedChannel = selected ? channelMap.get(selected.channelId) : undefined;\n\n const resetToFirst = () => {\n setPage(0);\n setSelectedId(null);\n };\n\n return (\n <PageLayout\n title={tr('inbox.title', 'Universal Inbox')}\n description={tr(\n 'inbox.description',\n 'Every subscription communication, merged and categorized'\n )}\n >\n <PagePurpose className=\"mb-4\">\n {tr(\n 'inbox.purpose',\n 'Subscription communication is noisy and scattered. The Universal Inbox merges every channel a provider uses and uses AI to categorize each message so you never miss a renewal, required action or security notice.'\n )}\n </PagePurpose>\n\n {/* Category tabs */}\n <div className=\"-mx-1 flex gap-2 overflow-x-auto px-1 pb-1\">\n {CATEGORY_TAB_VALUES.map((t) => (\n <span key={t.value} className=\"shrink-0\">\n <Chip\n active={category === t.value}\n onClick={() => {\n setCategory(t.value);\n resetToFirst();\n }}\n >\n {tr(t.key, t.fallback)}\n </Chip>\n </span>\n ))}\n </div>\n\n {/* Lenses + stats */}\n <div className=\"mt-3 flex flex-wrap items-center gap-2\">\n <Chip\n active={actionOnly}\n tone=\"warning\"\n onClick={() => {\n setActionOnly((v) => !v);\n setSelectedId(null);\n }}\n >\n <AlertTriangle className=\"h-3.5 w-3.5\" />{' '}\n {tr('inbox.filters.actionRequired', 'Action required')}\n </Chip>\n <Chip\n active={unreadOnly}\n onClick={() => {\n setUnreadOnly((v) => !v);\n resetToFirst();\n }}\n >\n <Mail className=\"h-3.5 w-3.5\" /> {tr('inbox.filters.unreadOnly', 'Unread only')}\n </Chip>\n {!isLoading && !isError && items.length > 0 && (\n <p className=\"ms-auto text-xs text-text-secondary\">\n {tr('inbox.filters.unreadCount', '{{count}} unread', { count: unreadCount })}\n {' · '}\n {tr('inbox.filters.actionCount', '{{count}} need action', { count: actionCount })}\n {isFetching ? ` · ${tr('inbox.filters.refreshing', 'refreshing…')}` : ''}\n </p>\n )}\n </div>\n\n {markPending && (\n <p role=\"status\" className=\"mt-3 text-sm text-text-secondary\">\n {tr('inbox.message.saving', 'Saving…')}\n </p>\n )}\n {readStateError && (\n <p role=\"alert\" className=\"mt-3 text-sm text-status-error-text\">\n {tr('inbox.message.updateError', 'Could not update the message. Please try again.')}\n </p>\n )}\n\n {isLoading ? (\n <LoadingView label={tr('inbox.loading', 'Loading inbox…')} />\n ) : isError ? (\n <ErrorView\n message={tr('inbox.error', 'Could not load the inbox.')}\n onRetry={() => void refetch()}\n />\n ) : items.length === 0 ? (\n <div className=\"mt-6\">\n <EmptyState\n illustration=\"empty-notifications\"\n icon={<InboxIcon className=\"h-12 w-12\" />}\n title={tr('inbox.emptyTitle', 'Inbox is empty')}\n description={\n unreadOnly || category\n ? tr('inbox.emptyDescriptionFiltered', 'No messages match these filters.')\n : tr(\n 'inbox.emptyDescription',\n 'Merged subscription communications will appear here once channels start ingesting.'\n )\n }\n />\n </div>\n ) : (\n <div className=\"mt-5 grid grid-cols-1 gap-5 lg:grid-cols-[minmax(0,1fr)_380px]\">\n {/* List */}\n <div className=\"min-w-0\">\n {displayed.length === 0 ? (\n <div className=\"rounded-xl border border-border-subtle bg-bg-surface p-8 text-center\">\n <AlertTriangle className=\"mx-auto h-8 w-8 text-text-secondary\" />\n <p className=\"mt-2 text-sm font-medium text-text-primary\">\n {tr('inbox.noActionTitle', 'No action-required messages on this page')}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr(\n 'inbox.noActionDescription',\n 'Turn off the “Action required” lens or move to another page.'\n )}\n </p>\n </div>\n ) : (\n <div className=\"divide-y divide-border-subtle overflow-hidden rounded-xl border border-border-subtle bg-bg-surface\">\n {displayed.map((m) => (\n <MessageRow\n key={m.id}\n message={m}\n active={m.id === selectedId}\n onSelect={() => setSelectedId(m.id)}\n onChangeReadState={() => void changeReadState(m)}\n markPending={markPending}\n onViewRelationship={\n m.relationshipId\n ? () => navigateTo(`/relationships/${m.relationshipId}`)\n : null\n }\n />\n ))}\n </div>\n )}\n\n <div className=\"mt-4 flex items-center justify-between\">\n <p className=\"text-xs text-text-secondary\">\n {tr('inbox.pagination.page', 'Page {{page}}', { page: page + 1 })}\n {isFetching ? ` · ${tr('inbox.filters.refreshing', 'refreshing…')}` : ''}\n </p>\n <div className=\"flex gap-2\">\n <button\n type=\"button\"\n disabled={page === 0}\n onClick={() => {\n setPage((p) => Math.max(0, p - 1));\n setSelectedId(null);\n }}\n className={cn(\n 'rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium',\n page === 0\n ? 'cursor-not-allowed text-text-secondary opacity-50'\n : 'text-text-primary hover:bg-bg-sunken'\n )}\n >\n {tr('inbox.pagination.previous', 'Previous')}\n </button>\n <button\n type=\"button\"\n disabled={!hasMore}\n onClick={() => {\n setPage((p) => p + 1);\n setSelectedId(null);\n }}\n className={cn(\n 'rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium',\n !hasMore\n ? 'cursor-not-allowed text-text-secondary opacity-50'\n : 'text-text-primary hover:bg-bg-sunken'\n )}\n >\n {tr('inbox.pagination.next', 'Next')}\n </button>\n </div>\n </div>\n </div>\n\n {/* Reading pane — wide screens only */}\n <aside className=\"hidden lg:block\">\n <div className=\"lg:sticky lg:top-4\">\n <ReadingPane\n message={selected}\n channel={selectedChannel}\n onChangeReadState={() => {\n if (selected) void changeReadState(selected);\n }}\n markPending={markPending}\n onViewRelationship={\n selected?.relationshipId\n ? () => navigateTo(`/relationships/${selected.relationshipId}`)\n : null\n }\n />\n </div>\n </aside>\n </div>\n )}\n\n <ChannelsSection />\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;A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AE,CAAC,GAC/D,IAAa,MAAM,EAAG,4BAA4B,aAAa,MAAM,EACrE;UACH,kBAAC,OAAD;OAAK,WAAU;iBAAf,CACE,kBAAC,UAAD;QACE,MAAK;QACL,UAAU,MAAS;QACnB,eAAe;SAEb,AADA,GAAS,MAAM,KAAK,IAAI,GAAG,IAAI,CAAC,CAAC,GACjC,EAAc,IAAI;QACpB;QACA,WAAW,EACT,0EACA,MAAS,IACL,sDACA,sCACN;kBAEC,EAAG,6BAA6B,UAAU;OACrC,CAAA,GACR,kBAAC,UAAD;QACE,MAAK;QACL,UAAU,CAAC;QACX,eAAe;SAEb,AADA,GAAS,MAAM,IAAI,CAAC,GACpB,EAAc,IAAI;QACpB;QACA,WAAW,EACT,0EACC,IAEG,yCADA,mDAEN;kBAEC,EAAG,yBAAyB,MAAM;OAC7B,CAAA,CACL;QACF;OACF;QAGL,kBAAC,SAAD;KAAO,WAAU;eACf,kBAAC,OAAD;MAAK,WAAU;gBACb,kBAAC,IAAD;OACE,SAAS;OACT,SAAS;OACT,yBAAyB;QACvB,AAAI,KAAU,EAAqB,CAAQ;OAC7C;OACa;OACb,oBACE,GAAU,uBACA,EAAW,kBAAkB,EAAS,gBAAgB,IAC5D;MAEP,CAAA;KACE,CAAA;IACA,CAAA,CACJ;;GAGP,kBAAC,IAAD,CAAkB,CAAA;EACR;;AAEhB"}
|
|
@@ -1102,7 +1102,7 @@ function me() {
|
|
|
1102
1102
|
be.length === 0 ? /* @__PURE__ */ H("div", {
|
|
1103
1103
|
className: "mt-4",
|
|
1104
1104
|
children: /* @__PURE__ */ H(a, {
|
|
1105
|
-
illustration: "empty-
|
|
1105
|
+
illustration: "empty-data",
|
|
1106
1106
|
title: y("relationships.detail.empty.noRenewalEventsTitle", "No renewal events"),
|
|
1107
1107
|
description: y("relationships.detail.empty.noRenewalEventsDescription", "Renewals and price changes will appear here as they're detected.")
|
|
1108
1108
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipDetailPage.js","names":[],"sources":["../../../../src/subscriberbot/pages/relationships/RelationshipDetailPage.tsx"],"sourcesContent":["import { useFormatters } from '../../hooks/useFormatters';\nimport { useFormError } from '../../hooks/useFormError';\n/**\n * Relationship detail\n * @module subscriberbot/pages/relationships\n *\n * Full per-relationship view: plan, price, billing period, next renewal,\n * health score, entitlements, attached assets and renewal events — plus\n * lifecycle transitions (validated server-side), edit, and cancel.\n * Reads `subRelationship(id)`; writes `subTransitionRelationship`,\n * `subCancelRelationship`, `subUpdateRelationship`, `subCreateEntitlement`,\n * `subCreateAsset`.\n */\n\nimport { useState, type ReactNode } from 'react';\nimport { useParams } from 'react-router';\nimport {\n ArrowLeft,\n Briefcase,\n CreditCard,\n Wallet,\n ShieldCheck,\n CalendarClock,\n Paperclip,\n Activity,\n Tag,\n Pencil,\n Handshake,\n Plus,\n Pause,\n Play,\n Ban,\n Download,\n} from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../../components/PageLayout';\nimport { StatusBadge } from '../../components/StatusBadge';\nimport { EmptyState } from '../../components/EmptyState';\nimport { Modal } from '../../components/Modal';\nimport { LoadingView, ErrorView, Section } from '../../components/StateViews';\nimport { AiDisclaimer, DecisionCard } from '../../components/decisions';\nimport { Gauge, Timeline, MiniProgress } from '../../components';\nimport type { TimelineItem } from '../../components';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport {\n useRelationship,\n useTransitionRelationship,\n useCancelRelationship,\n useUpdateRelationship,\n useCreateEntitlement,\n useCreateAsset,\n useUploadFile,\n useFileDownloadUrl,\n useProviders,\n usePlans,\n useDecisions,\n useInvoices,\n} from '../../hooks/useSubscriberBotApi';\n\nimport { useTr } from '../../hooks/useTr';\nimport { canTransition } from '../../utils/portfolio';\nimport type {\n SubAssetType,\n SubBillingInterval,\n SubEntitlementType,\n SubInvoice,\n SubRelationship,\n SubRelationshipKind,\n SubRelationshipStatus,\n SubUpdateRelationshipInput,\n} from '../../types';\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 labelCls = 'mb-1 block text-xs font-medium text-text-secondary';\n\nconst INTERVALS: SubBillingInterval[] = [\n 'MONTHLY',\n 'YEARLY',\n 'QUARTERLY',\n 'WEEKLY',\n 'DAILY',\n 'USAGE_BASED',\n 'LIFETIME',\n 'FREE',\n];\n\nconst ENTITLEMENT_TYPES: SubEntitlementType[] = [\n 'FEATURE_ACCESS',\n 'SEAT',\n 'USAGE_QUOTA',\n 'CONTENT',\n 'DISCOUNT',\n 'SUPPORT_TIER',\n];\n\nconst ASSET_TYPES: SubAssetType[] = [\n 'RECEIPT',\n 'INVOICE',\n 'CONTRACT',\n 'LICENSE_KEY',\n 'CREDENTIAL',\n 'CERTIFICATE',\n 'WARRANTY',\n 'DOMAIN',\n];\n\nconst KIND_KEY: Record<SubRelationshipKind, string> = {\n SUBSCRIPTION: 'relationships.kinds.subscription',\n MEMBERSHIP: 'relationships.kinds.membership',\n LICENSE: 'relationships.kinds.license',\n CONTRACT: 'relationships.kinds.contract',\n NEWSLETTER: 'relationships.kinds.newsletter',\n RECURRING_PAYMENT: 'relationships.kinds.recurringPayment',\n ENROLLMENT: 'relationships.kinds.enrollment',\n TRIAL: 'relationships.kinds.trial',\n};\n\n// Lifecycle actions surfaced as buttons; the server validates the transition.\nconst TRANSITIONS: Array<{\n status: SubRelationshipStatus;\n labelKey: string;\n defaultLabel: string;\n icon: typeof Play;\n}> = [\n {\n status: 'ACTIVE',\n labelKey: 'relationships.detail.actions.activate',\n defaultLabel: 'Activate',\n icon: Play,\n },\n {\n status: 'PAUSED',\n labelKey: 'relationships.detail.actions.pause',\n defaultLabel: 'Pause',\n icon: Pause,\n },\n {\n status: 'EXPIRED',\n labelKey: 'relationships.detail.actions.markExpired',\n defaultLabel: 'Mark expired',\n icon: Ban,\n },\n];\n\n/** Compact label/value row for the detail info cards. */\nfunction InfoRow({ label, value }: { label: string; value: ReactNode }) {\n return (\n <div className=\"flex items-center justify-between gap-3 border-b border-border-subtle/60 py-2.5 last:border-0 last:pb-0\">\n <span className=\"shrink-0 text-sm text-text-secondary\">{label}</span>\n <span className=\"min-w-0 truncate text-end text-sm font-medium text-text-primary\">\n {value}\n </span>\n </div>\n );\n}\n\n/** Map a 0–100 health score onto a MiniProgress tone. */\nfunction healthTone(\n score: number | null | undefined\n): 'positive' | 'accent' | 'warning' | 'negative' {\n if (score == null) return 'accent';\n if (score >= 66) return 'positive';\n if (score >= 33) return 'warning';\n return 'negative';\n}\n\n/** ISO string → yyyy-mm-dd for a native <input type=\"date\">. */\nfunction toDateInputValue(iso: string | null | undefined): string {\n if (!iso) return '';\n const d = new Date(iso);\n if (Number.isNaN(d.getTime())) return '';\n return d.toISOString().slice(0, 10);\n}\n\n// ---------------------------------------------------------------------------\n// Edit relationship modal → subUpdateRelationship\n// ---------------------------------------------------------------------------\n\nfunction RelationshipEditModal({\n relationship,\n onClose,\n}: {\n relationship: SubRelationship;\n onClose: () => void;\n}) {\n const tr = useTr();\n const update = useUpdateRelationship();\n const providersQ = useProviders({ pagination: { limit: 100, offset: 0 } });\n\n const [label, setLabel] = useState(relationship.label);\n const [providerId, setProviderId] = useState(relationship.providerId ?? '');\n const [planId, setPlanId] = useState(relationship.planId ?? '');\n const [amount, setAmount] = useState(String(relationship.amount ?? ''));\n const [currency, setCurrency] = useState(relationship.currency);\n const [interval, setInterval] = useState<SubBillingInterval>(relationship.interval);\n const [renewsAt, setRenewsAt] = useState(toDateInputValue(relationship.renewsAt));\n const [autoRenew, setAutoRenew] = useState(relationship.autoRenew);\n const [notes, setNotes] = useState(relationship.notes ?? '');\n const [department, setDepartment] = useState(relationship.department ?? '');\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const plansQ = usePlans(providerId || undefined);\n\n // Ensure the currently-linked provider is always selectable even if it isn't\n // in the first page of the registry.\n const providerOptions = (() => {\n const list = providersQ.data?.items ?? [];\n if (relationship.provider && !list.some((p) => p.id === relationship.provider?.id)) {\n return [relationship.provider, ...list];\n }\n return list;\n })();\n const plans = plansQ.data ?? [];\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n if (!label.trim()) {\n setFormError(\n tr('relationships.detail.editModal.labelRequired', 'A label is required.'),\n 'edit-label'\n );\n return;\n }\n const input: SubUpdateRelationshipInput = {\n label: label.trim(),\n interval,\n autoRenew,\n currency: currency.trim() || 'USD',\n notes: notes.trim(),\n // Always sent: an empty string clears the department allocation.\n department: department.trim(),\n ...(providerId ? { providerId } : {}),\n ...(planId ? { planId } : {}),\n ...(amount.trim() ? { amount: Number(amount) } : {}),\n ...(renewsAt ? { renewsAt: new Date(renewsAt).toISOString() } : {}),\n };\n update.mutate(\n { id: relationship.id, input },\n {\n onSuccess: () => onClose(),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('relationships.detail.editModal.error', 'Could not update relationship.')\n ),\n }\n );\n };\n\n return (\n <Modal\n title={tr('relationships.detail.editModal.title', 'Edit relationship')}\n onClose={onClose}\n maxWidthClassName=\"max-w-2xl\"\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n\n <div>\n <label htmlFor=\"edit-label\" className={labelCls}>\n {tr('relationships.detail.editModal.labelLabel', 'Label')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('edit-label')}\n id=\"edit-label\"\n type=\"text\"\n value={label}\n onChange={(e) => setLabel(e.target.value)}\n className={inputCls}\n required\n />\n </div>\n\n <div>\n <label htmlFor=\"edit-department\" className={labelCls}>\n {tr('relationships.detail.editModal.departmentLabel', 'Department or team')}\n </label>\n <input\n {...fieldErrorProps('edit-department')}\n id=\"edit-department\"\n type=\"text\"\n maxLength={120}\n value={department}\n onChange={(e) => setDepartment(e.target.value)}\n placeholder={tr(\n 'relationships.detail.editModal.departmentPlaceholder',\n 'e.g. Engineering, Marketing'\n )}\n className={inputCls}\n />\n </div>\n\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"edit-provider\" className={labelCls}>\n {tr('relationships.detail.editModal.providerLabel', 'Provider')}\n </label>\n <select\n {...fieldErrorProps('edit-provider')}\n id=\"edit-provider\"\n value={providerId}\n onChange={(e) => {\n setProviderId(e.target.value);\n setPlanId('');\n }}\n className={inputCls}\n >\n <option value=\"\">\n {tr('relationships.detail.editModal.providerNone', '— None —')}\n </option>\n {providerOptions.map((p) => (\n <option key={p.id} value={p.id}>\n {p.name}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"edit-plan\" className={labelCls}>\n {tr('relationships.detail.editModal.planLabel', 'Plan')}\n </label>\n <select\n {...fieldErrorProps('edit-plan')}\n id=\"edit-plan\"\n value={planId}\n onChange={(e) => setPlanId(e.target.value)}\n className={inputCls}\n disabled={!providerId || plans.length === 0}\n >\n <option value=\"\">{tr('relationships.detail.editModal.planNone', '— None —')}</option>\n {plans.map((pl) => (\n <option key={pl.id} value={pl.id}>\n {pl.name}\n </option>\n ))}\n </select>\n </div>\n </div>\n\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <div>\n <label htmlFor=\"edit-amount\" className={labelCls}>\n {tr('relationships.detail.editModal.amountLabel', 'Amount')}\n </label>\n <input\n {...fieldErrorProps('edit-amount')}\n id=\"edit-amount\"\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={amount}\n onChange={(e) => setAmount(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"edit-currency\" className={labelCls}>\n {tr('relationships.detail.editModal.currencyLabel', 'Currency')}\n </label>\n <input\n {...fieldErrorProps('edit-currency')}\n id=\"edit-currency\"\n type=\"text\"\n value={currency}\n onChange={(e) => setCurrency(e.target.value.toUpperCase())}\n maxLength={3}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"edit-interval\" className={labelCls}>\n {tr('relationships.detail.editModal.intervalLabel', 'Billing interval')}\n </label>\n <select\n {...fieldErrorProps('edit-interval')}\n id=\"edit-interval\"\n value={interval}\n onChange={(e) => setInterval(e.target.value as SubBillingInterval)}\n className={inputCls}\n >\n {INTERVALS.map((i) => (\n <option key={i} value={i}>\n {i.replace(/_/g, ' ')}\n </option>\n ))}\n </select>\n </div>\n </div>\n\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <div>\n <label htmlFor=\"edit-renews\" className={labelCls}>\n {tr('relationships.detail.editModal.renewsOnLabel', 'Renews on')}\n </label>\n <input\n {...fieldErrorProps('edit-renews')}\n id=\"edit-renews\"\n type=\"date\"\n value={renewsAt}\n onChange={(e) => setRenewsAt(e.target.value)}\n className={inputCls}\n />\n </div>\n <div className=\"flex items-end\">\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={autoRenew}\n onChange={(e) => setAutoRenew(e.target.checked)}\n className=\"size-4 rounded border-border-subtle\"\n />\n {tr('relationships.detail.editModal.autoRenews', 'Auto-renews')}\n </label>\n </div>\n </div>\n\n <div>\n <label htmlFor=\"edit-notes\" className={labelCls}>\n {tr('relationships.detail.editModal.notesLabel', 'Notes')}\n </label>\n <textarea\n {...fieldErrorProps('edit-notes')}\n id=\"edit-notes\"\n value={notes}\n onChange={(e) => setNotes(e.target.value)}\n rows={3}\n className={inputCls}\n />\n </div>\n\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('relationships.detail.editModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={update.isPending}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {update.isPending\n ? tr('relationships.detail.editModal.saving', 'Saving…')\n : tr('relationships.detail.editModal.submit', 'Save changes')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Add entitlement modal → subCreateEntitlement\n// ---------------------------------------------------------------------------\n\nfunction AddEntitlementModal({\n relationshipId,\n onClose,\n}: {\n relationshipId: string;\n onClose: () => void;\n}) {\n const tr = useTr();\n const create = useCreateEntitlement();\n const [name, setName] = useState('');\n const [type, setType] = useState<SubEntitlementType>('FEATURE_ACCESS');\n const [quota, setQuota] = useState('');\n const [unit, setUnit] = useState('');\n const [description, setDescription] = useState('');\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n if (!name.trim()) {\n setFormError(\n tr(\n 'relationships.detail.addEntitlementModal.nameRequired',\n 'An entitlement name is required.'\n ),\n 'ent-name'\n );\n return;\n }\n create.mutate(\n {\n relationshipId,\n name: name.trim(),\n type,\n ...(quota.trim() ? { quota: Number(quota) } : {}),\n ...(unit.trim() ? { unit: unit.trim() } : {}),\n ...(description.trim() ? { description: description.trim() } : {}),\n },\n {\n onSuccess: () => onClose(),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('relationships.detail.addEntitlementModal.error', 'Could not add entitlement.')\n ),\n }\n );\n };\n\n return (\n <Modal\n title={tr('relationships.detail.addEntitlementModal.title', 'Add entitlement')}\n onClose={onClose}\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n <div>\n <label htmlFor=\"ent-name\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.nameLabel', 'Name')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('ent-name')}\n id=\"ent-name\"\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={tr(\n 'relationships.detail.addEntitlementModal.namePlaceholder',\n 'e.g. Seats, API calls, Priority support'\n )}\n className={inputCls}\n required\n />\n </div>\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <div>\n <label htmlFor=\"ent-type\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.typeLabel', 'Type')}\n </label>\n <select\n {...fieldErrorProps('ent-type')}\n id=\"ent-type\"\n value={type}\n onChange={(e) => setType(e.target.value as SubEntitlementType)}\n className={inputCls}\n >\n {ENTITLEMENT_TYPES.map((t) => (\n <option key={t} value={t}>\n {t.replace(/_/g, ' ')}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"ent-quota\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.quotaLabel', 'Quota')}\n </label>\n <input\n {...fieldErrorProps('ent-quota')}\n id=\"ent-quota\"\n type=\"number\"\n min=\"0\"\n value={quota}\n onChange={(e) => setQuota(e.target.value)}\n placeholder={tr(\n 'relationships.detail.addEntitlementModal.quotaPlaceholder',\n 'e.g. 5'\n )}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"ent-unit\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.unitLabel', 'Unit')}\n </label>\n <input\n {...fieldErrorProps('ent-unit')}\n id=\"ent-unit\"\n type=\"text\"\n value={unit}\n onChange={(e) => setUnit(e.target.value)}\n placeholder={tr(\n 'relationships.detail.addEntitlementModal.unitPlaceholder',\n 'e.g. seats, GB'\n )}\n className={inputCls}\n />\n </div>\n </div>\n <div>\n <label htmlFor=\"ent-desc\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.descriptionLabel', 'Description')}\n </label>\n <textarea\n {...fieldErrorProps('ent-desc')}\n id=\"ent-desc\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n rows={2}\n className={inputCls}\n />\n </div>\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('relationships.detail.addEntitlementModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={create.isPending}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {create.isPending\n ? tr('relationships.detail.addEntitlementModal.adding', 'Adding…')\n : tr('relationships.detail.addEntitlementModal.submit', 'Add entitlement')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Attach asset modal → upload to files-svc, then subCreateAsset\n// ---------------------------------------------------------------------------\n\nfunction AttachAssetModal({\n relationshipId,\n onClose,\n}: {\n relationshipId: string;\n onClose: () => void;\n}) {\n const tr = useTr();\n const create = useCreateAsset();\n const { uploadFile, progress, isUploading } = useUploadFile();\n const [name, setName] = useState('');\n const [type, setType] = useState<SubAssetType>('RECEIPT');\n const [file, setFile] = useState<File | null>(null);\n const [expiresAt, setExpiresAt] = useState('');\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const busy = isUploading || create.isPending;\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n if (!file) {\n setFormError(\n tr('relationships.detail.attachAssetModal.chooseFile', 'Choose a file to attach.'),\n 'asset-file'\n );\n return;\n }\n try {\n const { fileId, fileName } = await uploadFile(file);\n await create.mutateAsync({\n relationshipId,\n name: name.trim() || fileName,\n type,\n fileId,\n ...(expiresAt ? { expiresAt: new Date(expiresAt).toISOString() } : {}),\n });\n onClose();\n } catch (err) {\n setFormError(\n err instanceof Error\n ? err.message\n : tr('relationships.detail.attachAssetModal.error', 'Could not attach the asset.')\n );\n }\n };\n\n return (\n <Modal\n title={tr('relationships.detail.attachAssetModal.title', 'Attach asset')}\n onClose={onClose}\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n <div>\n <label htmlFor=\"asset-file\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.fileLabel', 'File')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('asset-file')}\n id=\"asset-file\"\n type=\"file\"\n onChange={(e) => {\n const f = e.target.files?.[0] ?? null;\n setFile(f);\n if (f && !name.trim()) setName(f.name);\n }}\n className=\"w-full text-sm text-text-secondary file:me-3 file:rounded-lg file:border file:border-border-subtle file:bg-bg-surface file:px-3 file:py-1.5 file:text-sm file:font-medium file:text-text-primary hover:file:bg-bg-sunken\"\n />\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr(\n 'relationships.detail.attachAssetModal.fileHint',\n 'Stored securely in files — only a reference is kept here.'\n )}\n </p>\n </div>\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"asset-name\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.nameLabel', 'Name')}\n </label>\n <input\n {...fieldErrorProps('asset-name')}\n id=\"asset-name\"\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={tr(\n 'relationships.detail.attachAssetModal.namePlaceholder',\n 'Defaults to the file name'\n )}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"asset-type\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.typeLabel', 'Type')}\n </label>\n <select\n {...fieldErrorProps('asset-type')}\n id=\"asset-type\"\n value={type}\n onChange={(e) => setType(e.target.value as SubAssetType)}\n className={inputCls}\n >\n {ASSET_TYPES.map((t) => (\n <option key={t} value={t}>\n {t.replace(/_/g, ' ')}\n </option>\n ))}\n </select>\n </div>\n </div>\n <div>\n <label htmlFor=\"asset-expires\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.expiresOnLabel', 'Expires on')}\n </label>\n <input\n {...fieldErrorProps('asset-expires')}\n id=\"asset-expires\"\n type=\"date\"\n value={expiresAt}\n onChange={(e) => setExpiresAt(e.target.value)}\n className={inputCls}\n />\n </div>\n {isUploading && (\n <p className=\"text-xs text-text-secondary\">\n {tr('relationships.detail.attachAssetModal.uploading', 'Uploading… {{progress}}%', {\n progress,\n })}\n </p>\n )}\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('relationships.detail.attachAssetModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={busy}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {busy\n ? tr('relationships.detail.attachAssetModal.attaching', 'Attaching…')\n : tr('relationships.detail.attachAssetModal.submit', 'Attach asset')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Asset row — resolves a presigned download URL on demand\n// ---------------------------------------------------------------------------\n\nfunction AssetRow({ asset }: { asset: NonNullable<SubRelationship['assets']>[number] }) {\n const { formatDate, formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n const getDownloadUrl = useFileDownloadUrl();\n const [downloading, setDownloading] = useState(false);\n\n const handleDownload = async () => {\n if (!asset.file?.id) return;\n setDownloading(true);\n try {\n const url = await getDownloadUrl(asset.file.id);\n window.open(url, '_blank', 'noopener,noreferrer');\n } catch {\n // Non-fatal: a broken/expired file reference just can't be downloaded.\n } finally {\n setDownloading(false);\n }\n };\n\n return (\n <div className=\"flex items-center justify-between gap-3 p-3\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <Paperclip className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-medium text-text-primary\">{asset.name}</p>\n <p className=\"text-xs text-text-secondary\">{formatEnumLabel(asset.type)}</p>\n </div>\n </div>\n <div className=\"flex shrink-0 items-center gap-3\">\n {asset.expiresAt && (\n <span className=\"text-xs text-text-secondary\">\n {tr('relationships.detail.assetRow.expires', 'Expires {{date}}', {\n date: formatDate(asset.expiresAt),\n })}\n </span>\n )}\n {asset.file?.id && (\n <button\n type=\"button\"\n onClick={handleDownload}\n disabled={downloading}\n className=\"inline-flex items-center gap-1 rounded-lg border border-border-subtle px-2.5 py-1 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n <Download className=\"h-3.5 w-3.5\" />{' '}\n {downloading\n ? tr('relationships.detail.assetRow.opening', 'Opening…')\n : tr('relationships.detail.assetRow.download', 'Download')}\n </button>\n )}\n </div>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Invoice row (BOFF-8659) — every invoice linked to this relationship via\n// `SubInvoice.relationshipId` is shown in the Assets section alongside any\n// file-based assets, so users don't have to leave the relationship page to\n// discover that they have an outstanding invoice tied to it.\n// ---------------------------------------------------------------------------\n\nfunction InvoiceRow({ invoice }: { invoice: SubInvoice }) {\n const { formatCurrency, formatDate, formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n // Each invoice appears once, grouped by the (most-recent) due or issue\n // date and labelled with number · status, then a right-aligned total that\n // matches the Invoices list currency formatting.\n const label =\n invoice.number ?? tr('relationships.detail.invoiceRow.unnumbered', 'Unnumbered invoice');\n return (\n <div className=\"flex items-center justify-between gap-3 p-3\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <CreditCard className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-medium text-text-primary\">{label}</p>\n <p className=\"text-xs text-text-secondary\">\n {formatEnumLabel(invoice.status)}\n {invoice.dueDate\n ? ` · ${tr('relationships.detail.invoiceRow.due', 'due {{date}}', {\n date: formatDate(invoice.dueDate),\n })}`\n : invoice.issueDate\n ? ` · ${formatDate(invoice.issueDate)}`\n : ''}\n </p>\n </div>\n </div>\n <span className=\"shrink-0 text-sm font-medium tabular-nums text-text-primary\">\n {formatCurrency(invoice.total, invoice.currency)}\n </span>\n </div>\n );\n}\n\nexport function RelationshipDetailPage() {\n const { formatCurrency, formatDate, formatEnumLabel, formatIntervalSuffix } = useFormatters();\n\n const tr = useTr();\n const { id } = useParams<{ id: string }>();\n const { navigateTo } = useSubscriberBot();\n const { data: relationship, isLoading, isError, refetch } = useRelationship(id);\n const transition = useTransitionRelationship();\n const cancel = useCancelRelationship();\n const [actionError, setActionError] = useState<string | null>(null);\n const [showEdit, setShowEdit] = useState(false);\n const [showAddEntitlement, setShowAddEntitlement] = useState(false);\n const [showAttachAsset, setShowAttachAsset] = useState(false);\n // Open AI recommendations about this subscription (BOFF-3663). Best effort:\n // if the decision engine is unavailable the section is simply omitted, and\n // every change it could propose stays available through the actions above.\n // Invoices linked through SubInvoice.relationshipId (BOFF-8659). The svc\n // exposes them through subListInvoices(relationshipId), not as a field on\n // SubRelationship, so they are read with their own query.\n const relationshipInvoices = useInvoices(\n { relationshipId: id, pagination: { limit: 50, offset: 0 } },\n { enabled: Boolean(id) }\n );\n const openDecisions = useDecisions(\n { relationshipId: id, status: 'PROPOSED' },\n { enabled: Boolean(id) }\n );\n\n if (isLoading) {\n return (\n <PageLayout title={tr('relationships.title', 'Relationship')}>\n <LoadingView label={tr('relationships.detail.loading', 'Loading relationship…')} />\n </PageLayout>\n );\n }\n\n if (isError) {\n return (\n <PageLayout title={tr('relationships.title', 'Relationship')}>\n <ErrorView\n message={tr('relationships.detail.error', 'Could not load this relationship.')}\n onRetry={() => void refetch()}\n />\n </PageLayout>\n );\n }\n\n if (!relationship) {\n return (\n <PageLayout title={tr('relationships.title', 'Relationship')}>\n <EmptyState\n illustration=\"empty-data\"\n title={tr('relationships.detail.notFoundTitle', 'Relationship not found')}\n description={tr(\n 'relationships.detail.notFoundDescription',\n 'It may have been removed, or you may not have access to it.'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships')}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90\"\n >\n {tr('relationships.detail.backToRelationships', 'Back to relationships')}\n </button>\n }\n />\n </PageLayout>\n );\n }\n\n const r = relationship;\n const isBusy = transition.isPending || cancel.isPending;\n\n const runTransition = (status: SubRelationshipStatus) => {\n setActionError(null);\n transition.mutate(\n { id: r.id, status },\n {\n onError: (e) =>\n setActionError(\n e instanceof Error\n ? e.message\n : tr('relationships.detail.transitionError', 'Transition failed')\n ),\n }\n );\n };\n\n const runCancel = () => {\n setActionError(null);\n cancel.mutate(r.id, {\n onError: (e) =>\n setActionError(\n e instanceof Error ? e.message : tr('relationships.detail.cancelError', 'Cancel failed')\n ),\n });\n };\n\n // Renewal timeline — built entirely from the real renewalEvents, oldest → newest.\n const renewalTimeline: TimelineItem[] = [...(r.renewalEvents ?? [])]\n .sort((a, b) => new Date(a.occursAt).getTime() - new Date(b.occursAt).getTime())\n .map((event) => {\n const ts = new Date(event.occursAt).getTime();\n const isFuture = !Number.isNaN(ts) && ts > Date.now();\n return {\n title: formatEnumLabel(event.eventType),\n sub: `${formatDate(event.occursAt)}${event.detail ? ` · ${event.detail}` : ''}`,\n meta:\n event.amount != null\n ? formatCurrency(event.amount, event.currency ?? r.currency)\n : undefined,\n tone: isFuture ? 'warning' : 'muted',\n };\n });\n\n const autoRenewPill = r.autoRenew ? (\n <span className=\"inline-flex items-center rounded-full bg-status-success-bg-subtle px-2 py-0.5 text-xs font-medium text-status-success-text\">\n {tr('relationships.detail.autoRenewOn', 'On')}\n </span>\n ) : (\n <span className=\"inline-flex items-center rounded-full bg-bg-sunken px-2 py-0.5 text-xs font-medium text-text-secondary\">\n {tr('relationships.detail.autoRenewOff', 'Off')}\n </span>\n );\n\n // Only offer transitions the svc state machine accepts from the current\n // status (a cancelled relationship no longer shows Activate / Pause).\n const availableTransitions = TRANSITIONS.filter((t) => canTransition(r.status, t.status));\n const planFeatures = r.plan?.features ?? [];\n\n return (\n <PageLayout\n title={r.label}\n description={r.provider?.name ?? tr(KIND_KEY[r.kind], formatEnumLabel(r.kind))}\n actions={\n <div className=\"flex flex-wrap items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => setShowEdit(true)}\n className=\"inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Pencil className=\"h-4 w-4\" /> {tr('relationships.detail.edit', 'Edit')}\n </button>\n <button\n type=\"button\"\n data-testid=\"negotiate-bill\"\n onClick={() =>\n navigateTo(`/negotiations/new?relationshipId=${encodeURIComponent(r.id)}`)\n }\n className=\"inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Handshake className=\"h-4 w-4\" />{' '}\n {tr('relationships.detail.negotiate', 'Negotiate this bill')}\n </button>\n <button\n type=\"button\"\n data-testid=\"request-procurement\"\n onClick={() =>\n navigateTo(`/procurement/new?relationshipId=${encodeURIComponent(r.id)}`)\n }\n className=\"inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Briefcase className=\"h-4 w-4\" />{' '}\n {tr('relationships.detail.procurement', 'Ask an expert to negotiate')}\n </button>\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships')}\n className=\"inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <ArrowLeft className=\"rtl:rotate-180 h-4 w-4\" />{' '}\n {tr('relationships.detail.back', 'Back')}\n </button>\n </div>\n }\n >\n {/* Hero summary + lifecycle actions */}\n <GlassCard treatment=\"glass\" glow className=\"p-5 sm:p-6\">\n <div className=\"flex flex-col gap-5 lg:flex-row lg:items-start lg:justify-between\">\n <div className=\"min-w-0\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {tr(KIND_KEY[r.kind], formatEnumLabel(r.kind))}\n </p>\n <div className=\"mt-2 flex flex-wrap items-center gap-3\">\n <span className=\"text-3xl font-bold tabular-nums text-text-primary\">\n {formatCurrency(r.amount, r.currency)}\n <span className=\"text-base font-normal text-text-secondary\">\n {formatIntervalSuffix(r.interval)}\n </span>\n </span>\n <StatusBadge status={r.status} />\n </div>\n <div className=\"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-text-secondary\">\n <span className=\"inline-flex items-center gap-1.5\">\n <CalendarClock className=\"h-3.5 w-3.5\" />\n {r.renewsAt\n ? tr('relationships.detail.renews', 'Renews {{date}}', {\n date: formatDate(r.renewsAt),\n })\n : tr('relationships.detail.noRenewalScheduled', 'No renewal scheduled')}\n </span>\n <span className=\"inline-flex items-center gap-1.5\">\n <ShieldCheck className=\"h-3.5 w-3.5\" />\n {formatEnumLabel(r.discoverySource)}\n </span>\n <span className=\"inline-flex items-center gap-1.5\">\n {tr('relationships.detail.autoRenew', 'Auto-renew')} {autoRenewPill}\n </span>\n </div>\n {r.tags.length > 0 && (\n <div className=\"mt-3 flex flex-wrap items-center gap-2\">\n <Tag className=\"h-3.5 w-3.5 text-text-secondary\" />\n {r.tags.map((tag) => (\n <span\n key={tag}\n className=\"rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs text-text-secondary\"\n >\n {tag}\n </span>\n ))}\n </div>\n )}\n </div>\n\n {/* Lifecycle actions */}\n <div className=\"grid shrink-0 grid-cols-2 gap-2 sm:flex sm:flex-wrap lg:flex-col lg:items-stretch\">\n {availableTransitions.map((t) => {\n const Icon = t.icon;\n return (\n <button\n key={t.status}\n type=\"button\"\n disabled={isBusy}\n onClick={() => runTransition(t.status)}\n className=\"inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm sm:min-h-0 sm:text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n <Icon className=\"h-3.5 w-3.5\" /> {tr(t.labelKey, t.defaultLabel)}\n </button>\n );\n })}\n {canTransition(r.status, 'CANCELLED') && (\n <button\n type=\"button\"\n disabled={isBusy}\n onClick={runCancel}\n className=\"inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-3 py-1.5 text-sm sm:min-h-0 sm:text-xs font-medium text-status-error-text hover:opacity-90 disabled:opacity-50\"\n >\n <Ban className=\"h-3.5 w-3.5\" />{' '}\n {tr('relationships.detail.actions.cancel', 'Cancel')}\n </button>\n )}\n </div>\n </div>\n </GlassCard>\n\n {actionError && (\n <div className=\"mt-4 rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\">\n {actionError}\n </div>\n )}\n\n {/* Main layout: details (left) + health & timeline rail (right) */}\n <div className=\"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-3\">\n <div className=\"space-y-4 lg:col-span-2\">\n <div className=\"grid grid-cols-1 gap-4 md:grid-cols-2\">\n {/* Plan & pricing */}\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <CreditCard className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.planPricing', 'Plan & pricing')}\n </div>\n <div className=\"mt-3\">\n <InfoRow\n label={tr('relationships.detail.info.plan', 'Plan')}\n value={r.plan?.name ?? '—'}\n />\n <InfoRow\n label={tr('relationships.detail.info.price', 'Price')}\n value={\n <>\n {formatCurrency(r.amount, r.currency)}\n <span className=\"font-normal text-text-secondary\">\n {formatIntervalSuffix(r.interval)}\n </span>\n </>\n }\n />\n <InfoRow\n label={tr('relationships.detail.info.billingInterval', 'Billing interval')}\n value={formatEnumLabel(r.interval)}\n />\n <InfoRow\n label={tr('relationships.detail.info.provider', 'Provider')}\n value={r.provider?.name ?? '—'}\n />\n </div>\n {planFeatures.length > 0 && (\n <div className=\"mt-3 flex flex-wrap gap-1.5\">\n {planFeatures.map((f) => (\n <span\n key={f}\n className=\"rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs text-text-secondary\"\n >\n {f}\n </span>\n ))}\n </div>\n )}\n </GlassCard>\n\n {/* Payment & billing */}\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <Wallet className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.paymentBilling', 'Payment & billing')}\n </div>\n <div className=\"mt-3\">\n <InfoRow\n label={tr('relationships.detail.info.currency', 'Currency')}\n value={r.currency}\n />\n <InfoRow\n label={tr('relationships.detail.info.autoRenew', 'Auto-renew')}\n value={autoRenewPill}\n />\n <InfoRow\n label={tr('relationships.detail.info.nextRenewal', 'Next renewal')}\n value={r.renewsAt ? formatDate(r.renewsAt) : '—'}\n />\n <InfoRow\n label={tr('relationships.detail.info.started', 'Started')}\n value={r.startedAt ? formatDate(r.startedAt) : '—'}\n />\n {r.trialEndsAt && (\n <InfoRow\n label={tr('relationships.detail.info.trialEnds', 'Trial ends')}\n value={formatDate(r.trialEndsAt)}\n />\n )}\n </div>\n </GlassCard>\n </div>\n\n {/* Open AI recommendations for this subscription */}\n {(openDecisions.data?.items.length ?? 0) > 0 && (\n <Section\n className=\"mt-0\"\n title={tr('relationships.detail.sections.aiRecommendations', 'AI recommendations')}\n description={tr(\n 'relationships.detail.sections.aiRecommendationsDescription',\n 'Open recommendations about this subscription. You can also make any of these changes by hand above.'\n )}\n >\n <AiDisclaimer className=\"mb-3\" />\n <div className=\"grid grid-cols-1 gap-3\" data-testid=\"relationship-decisions\">\n {openDecisions.data?.items.map((d) => (\n <DecisionCard key={d.id} decision={d} />\n ))}\n </div>\n </Section>\n )}\n\n {/* Entitlements */}\n <Section\n className=\"mt-0\"\n title={tr('relationships.detail.sections.entitlements', 'Entitlements')}\n description={tr(\n 'relationships.detail.sections.entitlementsDescription',\n 'What this relationship grants you'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => setShowAddEntitlement(true)}\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Plus className=\"h-3.5 w-3.5\" />{' '}\n {tr('relationships.detail.sections.addEntitlement', 'Add entitlement')}\n </button>\n }\n >\n {!r.entitlements || r.entitlements.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('relationships.detail.empty.noEntitlementsTitle', 'No entitlements')}\n description={tr(\n 'relationships.detail.empty.noEntitlementsDescription',\n 'Entitlements (seats, quotas, feature access) will appear here.'\n )}\n />\n ) : (\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n {r.entitlements.map((e) => {\n const hasQuota = e.quota != null && e.quota > 0;\n return (\n <GlassCard key={e.id} treatment=\"plain\" className=\"p-4\">\n <div className=\"flex items-start justify-between gap-2\">\n <p className=\"min-w-0 truncate text-sm font-medium text-text-primary\">\n {e.name}\n </p>\n <StatusBadge status={e.isActive ? 'ACTIVE' : 'DISABLED'} />\n </div>\n <p className=\"mt-1 text-xs text-text-secondary\">{formatEnumLabel(e.type)}</p>\n {hasQuota && (\n <div className=\"mt-3\">\n <div className=\"flex items-center justify-between text-xs text-text-secondary\">\n <span>\n {e.used} / {e.quota}\n {e.unit ? ` ${e.unit}` : ''}\n </span>\n <span className=\"tabular-nums\">\n {Math.round((e.used / (e.quota as number)) * 100)}%\n </span>\n </div>\n <MiniProgress\n label={tr('common.quotaUtilization', 'Quota utilization')}\n value={e.used}\n max={e.quota as number}\n tone={\n e.used / (e.quota as number) >= 0.9\n ? 'negative'\n : e.used / (e.quota as number) >= 0.7\n ? 'warning'\n : 'accent'\n }\n className=\"mt-1.5\"\n />\n </div>\n )}\n </GlassCard>\n );\n })}\n </div>\n )}\n </Section>\n\n {/* Assets — file-based assets + relationship-owned invoices.\n BOFF-8659: invoices linked via `SubInvoice.relationshipId` are now\n shown here too, so the panel copy \"Invoices, contracts, licenses\n and credentials\" is honored for the cross-module Relationships ↔\n Invoices flow. */}\n <Section\n className=\"mt-0\"\n title={tr('relationships.detail.sections.assets', 'Assets')}\n description={tr(\n 'relationships.detail.sections.assetsDescription',\n 'Invoices, contracts, licenses and credentials'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => setShowAttachAsset(true)}\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Plus className=\"h-3.5 w-3.5\" />{' '}\n {tr('relationships.detail.sections.attachAsset', 'Attach asset')}\n </button>\n }\n >\n {(() => {\n const assets = r.assets ?? [];\n // BOFF-8659 — pull relationship-owned invoices into the same\n // Assets list, sorted next to file-based assets by their sort\n // time so invoices appear in the same order as the Invoices\n // list (newest first).\n const invoices: SubInvoice[] = relationshipInvoices.data?.items ?? [];\n const hasAny = assets.length > 0 || invoices.length > 0;\n if (!hasAny) {\n return (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('relationships.detail.empty.noAssetsTitle', 'No assets attached')}\n description={tr(\n 'relationships.detail.empty.noAssetsDescription',\n 'Attach invoices, contracts, licenses or receipts to this relationship.'\n )}\n />\n );\n }\n type AssetLike =\n | {\n kind: 'asset';\n sort: number;\n asset: NonNullable<SubRelationship['assets']>[number];\n }\n | {\n kind: 'invoice';\n sort: number;\n invoice: SubInvoice;\n };\n const combined: AssetLike[] = [\n ...assets.map((a) => ({\n kind: 'asset' as const,\n sort: new Date(a.createdAt).getTime() || 0,\n asset: a,\n })),\n ...invoices.map((i) => ({\n kind: 'invoice' as const,\n sort: new Date(i.createdAt).getTime() || 0,\n invoice: i,\n })),\n ].sort((x, y) => y.sort - x.sort);\n return (\n <GlassCard treatment=\"plain\" className=\"divide-y divide-border-subtle p-0\">\n {combined.map((row) =>\n row.kind === 'asset' ? (\n <AssetRow key={`a-${row.asset.id}`} asset={row.asset} />\n ) : (\n <InvoiceRow key={`i-${row.invoice.id}`} invoice={row.invoice} />\n )\n )}\n </GlassCard>\n );\n })()}\n </Section>\n\n {r.notes && (\n <GlassCard treatment=\"plain\" className=\"p-4\">\n <p className=\"text-xs font-medium text-text-secondary\">\n {tr('relationships.detail.sections.notes', 'Notes')}\n </p>\n <p className=\"mt-1 whitespace-pre-wrap text-sm text-text-primary\">{r.notes}</p>\n </GlassCard>\n )}\n </div>\n\n {/* Right rail: health gauge + renewal timeline */}\n <div className=\"space-y-4\">\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <Activity className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.healthScore', 'Health score')}\n </div>\n {r.healthScore != null ? (\n <div className=\"mt-4 flex flex-col items-center\">\n <Gauge\n value={r.healthScore}\n max={100}\n size={160}\n label={tr('relationships.detail.outOf100', 'of 100')}\n />\n <div className=\"mt-2 w-full\">\n <MiniProgress\n label={tr('common.healthScore', 'Health score')}\n value={r.healthScore}\n max={100}\n tone={healthTone(r.healthScore)}\n />\n </div>\n <p\n className=\"mt-3 text-center text-xs text-text-secondary\"\n data-testid=\"health-score-basis\"\n >\n {tr(\n 'relationships.detail.healthScoreBasis',\n 'Computed from usage, payment history, price stability and overlap with your other subscriptions.'\n )}\n </p>\n </div>\n ) : (\n <p className=\"mt-4 text-sm text-text-secondary\">\n {tr(\n 'relationships.detail.empty.noHealthScore',\n 'Not scored yet. A health score appears once Subscriber Bot has enough signal.'\n )}\n </p>\n )}\n </GlassCard>\n\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <CalendarClock className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.renewalTimeline', 'Renewal timeline')}\n </div>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {tr(\n 'relationships.detail.sections.renewalTimelineDescription',\n 'Detected renewals and price changes'\n )}\n </p>\n {renewalTimeline.length === 0 ? (\n <div className=\"mt-4\">\n <EmptyState\n illustration=\"empty-calendar\"\n title={tr('relationships.detail.empty.noRenewalEventsTitle', 'No renewal events')}\n description={tr(\n 'relationships.detail.empty.noRenewalEventsDescription',\n \"Renewals and price changes will appear here as they're detected.\"\n )}\n />\n </div>\n ) : (\n <Timeline items={renewalTimeline} className=\"mt-4\" />\n )}\n </GlassCard>\n </div>\n </div>\n\n {showEdit && <RelationshipEditModal relationship={r} onClose={() => setShowEdit(false)} />}\n {showAddEntitlement && (\n <AddEntitlementModal relationshipId={r.id} onClose={() => setShowAddEntitlement(false)} />\n )}\n {showAttachAsset && (\n <AttachAssetModal relationshipId={r.id} onClose={() => setShowAttachAsset(false)} />\n )}\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwEA,IAAM,IACJ,wMACI,IAAW,sDAEX,IAAkC;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,IAA0C;CAC9C;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,IAA8B;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,KAAgD;CACpD,cAAc;CACd,YAAY;CACZ,SAAS;CACT,UAAU;CACV,YAAY;CACZ,mBAAmB;CACnB,YAAY;CACZ,OAAO;AACT,GAGM,KAKD;CACH;EACE,QAAQ;EACR,UAAU;EACV,cAAc;EACd,MAAM;CACR;CACA;EACE,QAAQ;EACR,UAAU;EACV,cAAc;EACd,MAAM;CACR;CACA;EACE,QAAQ;EACR,UAAU;EACV,cAAc;EACd,MAAM;CACR;AACF;AAGA,SAAS,EAAQ,EAAE,UAAO,YAA8C;CACtE,OACE,kBAAC,OAAD;EAAK,WAAU;YAAf,C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C,CAAA,IA/BH,kBAAC,OAAD;OAAK,WAAU;iBAAf;QACE,kBAAC,GAAD;SACE,OAAO,EAAE;SACT,KAAK;SACL,MAAM;SACN,OAAO,EAAG,iCAAiC,QAAQ;QACpD,CAAA;QACD,kBAAC,OAAD;SAAK,WAAU;mBACb,kBAAC,GAAD;UACE,OAAO,EAAG,sBAAsB,cAAc;UAC9C,OAAO,EAAE;UACT,KAAK;UACL,MAAM,GAAW,EAAE,WAAW;SAC/B,CAAA;QACE,CAAA;QACL,kBAAC,KAAD;SACE,WAAU;SACV,eAAY;mBAEX,EACC,yCACA,kGACF;QACC,CAAA;OACA;QASE;SAEX,kBAAC,GAAD;MAAW,WAAU;MAAS,WAAU;gBAAxC;OACE,kBAAC,OAAD;QAAK,WAAU;kBAAf;SACE,kBAAC,GAAD,EAAe,WAAU,8BAA+B,CAAA;SAAE;SACzD,EAAG,iDAAiD,kBAAkB;QACpE;;OACL,kBAAC,KAAD;QAAG,WAAU;kBACV,EACC,4DACA,qCACF;OACC,CAAA;OACF,GAAgB,WAAW,IAC1B,kBAAC,OAAD;QAAK,WAAU;kBACb,kBAAC,GAAD;SACE,cAAa;SACb,OAAO,EAAG,mDAAmD,mBAAmB;SAChF,aAAa,EACX,yDACA,kEACF;QACD,CAAA;OACE,CAAA,IAEL,kBAAC,GAAD;QAAU,OAAO;QAAiB,WAAU;OAAQ,CAAA;MAE7C;OACR;MACF;;GAEJ,KAAY,kBAAC,IAAD;IAAuB,cAAc;IAAG,eAAe,EAAY,EAAK;GAAI,CAAA;GACxF,KACC,kBAAC,IAAD;IAAqB,gBAAgB,EAAE;IAAI,eAAe,EAAsB,EAAK;GAAI,CAAA;GAE1F,MACC,kBAAC,IAAD;IAAkB,gBAAgB,EAAE;IAAI,eAAe,EAAmB,EAAK;GAAI,CAAA;EAE3E;;AAEhB"}
|
|
1
|
+
{"version":3,"file":"RelationshipDetailPage.js","names":[],"sources":["../../../../src/subscriberbot/pages/relationships/RelationshipDetailPage.tsx"],"sourcesContent":["import { useFormatters } from '../../hooks/useFormatters';\nimport { useFormError } from '../../hooks/useFormError';\n/**\n * Relationship detail\n * @module subscriberbot/pages/relationships\n *\n * Full per-relationship view: plan, price, billing period, next renewal,\n * health score, entitlements, attached assets and renewal events — plus\n * lifecycle transitions (validated server-side), edit, and cancel.\n * Reads `subRelationship(id)`; writes `subTransitionRelationship`,\n * `subCancelRelationship`, `subUpdateRelationship`, `subCreateEntitlement`,\n * `subCreateAsset`.\n */\n\nimport { useState, type ReactNode } from 'react';\nimport { useParams } from 'react-router';\nimport {\n ArrowLeft,\n Briefcase,\n CreditCard,\n Wallet,\n ShieldCheck,\n CalendarClock,\n Paperclip,\n Activity,\n Tag,\n Pencil,\n Handshake,\n Plus,\n Pause,\n Play,\n Ban,\n Download,\n} from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../../components/PageLayout';\nimport { StatusBadge } from '../../components/StatusBadge';\nimport { EmptyState } from '../../components/EmptyState';\nimport { Modal } from '../../components/Modal';\nimport { LoadingView, ErrorView, Section } from '../../components/StateViews';\nimport { AiDisclaimer, DecisionCard } from '../../components/decisions';\nimport { Gauge, Timeline, MiniProgress } from '../../components';\nimport type { TimelineItem } from '../../components';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport {\n useRelationship,\n useTransitionRelationship,\n useCancelRelationship,\n useUpdateRelationship,\n useCreateEntitlement,\n useCreateAsset,\n useUploadFile,\n useFileDownloadUrl,\n useProviders,\n usePlans,\n useDecisions,\n useInvoices,\n} from '../../hooks/useSubscriberBotApi';\n\nimport { useTr } from '../../hooks/useTr';\nimport { canTransition } from '../../utils/portfolio';\nimport type {\n SubAssetType,\n SubBillingInterval,\n SubEntitlementType,\n SubInvoice,\n SubRelationship,\n SubRelationshipKind,\n SubRelationshipStatus,\n SubUpdateRelationshipInput,\n} from '../../types';\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 labelCls = 'mb-1 block text-xs font-medium text-text-secondary';\n\nconst INTERVALS: SubBillingInterval[] = [\n 'MONTHLY',\n 'YEARLY',\n 'QUARTERLY',\n 'WEEKLY',\n 'DAILY',\n 'USAGE_BASED',\n 'LIFETIME',\n 'FREE',\n];\n\nconst ENTITLEMENT_TYPES: SubEntitlementType[] = [\n 'FEATURE_ACCESS',\n 'SEAT',\n 'USAGE_QUOTA',\n 'CONTENT',\n 'DISCOUNT',\n 'SUPPORT_TIER',\n];\n\nconst ASSET_TYPES: SubAssetType[] = [\n 'RECEIPT',\n 'INVOICE',\n 'CONTRACT',\n 'LICENSE_KEY',\n 'CREDENTIAL',\n 'CERTIFICATE',\n 'WARRANTY',\n 'DOMAIN',\n];\n\nconst KIND_KEY: Record<SubRelationshipKind, string> = {\n SUBSCRIPTION: 'relationships.kinds.subscription',\n MEMBERSHIP: 'relationships.kinds.membership',\n LICENSE: 'relationships.kinds.license',\n CONTRACT: 'relationships.kinds.contract',\n NEWSLETTER: 'relationships.kinds.newsletter',\n RECURRING_PAYMENT: 'relationships.kinds.recurringPayment',\n ENROLLMENT: 'relationships.kinds.enrollment',\n TRIAL: 'relationships.kinds.trial',\n};\n\n// Lifecycle actions surfaced as buttons; the server validates the transition.\nconst TRANSITIONS: Array<{\n status: SubRelationshipStatus;\n labelKey: string;\n defaultLabel: string;\n icon: typeof Play;\n}> = [\n {\n status: 'ACTIVE',\n labelKey: 'relationships.detail.actions.activate',\n defaultLabel: 'Activate',\n icon: Play,\n },\n {\n status: 'PAUSED',\n labelKey: 'relationships.detail.actions.pause',\n defaultLabel: 'Pause',\n icon: Pause,\n },\n {\n status: 'EXPIRED',\n labelKey: 'relationships.detail.actions.markExpired',\n defaultLabel: 'Mark expired',\n icon: Ban,\n },\n];\n\n/** Compact label/value row for the detail info cards. */\nfunction InfoRow({ label, value }: { label: string; value: ReactNode }) {\n return (\n <div className=\"flex items-center justify-between gap-3 border-b border-border-subtle/60 py-2.5 last:border-0 last:pb-0\">\n <span className=\"shrink-0 text-sm text-text-secondary\">{label}</span>\n <span className=\"min-w-0 truncate text-end text-sm font-medium text-text-primary\">\n {value}\n </span>\n </div>\n );\n}\n\n/** Map a 0–100 health score onto a MiniProgress tone. */\nfunction healthTone(\n score: number | null | undefined\n): 'positive' | 'accent' | 'warning' | 'negative' {\n if (score == null) return 'accent';\n if (score >= 66) return 'positive';\n if (score >= 33) return 'warning';\n return 'negative';\n}\n\n/** ISO string → yyyy-mm-dd for a native <input type=\"date\">. */\nfunction toDateInputValue(iso: string | null | undefined): string {\n if (!iso) return '';\n const d = new Date(iso);\n if (Number.isNaN(d.getTime())) return '';\n return d.toISOString().slice(0, 10);\n}\n\n// ---------------------------------------------------------------------------\n// Edit relationship modal → subUpdateRelationship\n// ---------------------------------------------------------------------------\n\nfunction RelationshipEditModal({\n relationship,\n onClose,\n}: {\n relationship: SubRelationship;\n onClose: () => void;\n}) {\n const tr = useTr();\n const update = useUpdateRelationship();\n const providersQ = useProviders({ pagination: { limit: 100, offset: 0 } });\n\n const [label, setLabel] = useState(relationship.label);\n const [providerId, setProviderId] = useState(relationship.providerId ?? '');\n const [planId, setPlanId] = useState(relationship.planId ?? '');\n const [amount, setAmount] = useState(String(relationship.amount ?? ''));\n const [currency, setCurrency] = useState(relationship.currency);\n const [interval, setInterval] = useState<SubBillingInterval>(relationship.interval);\n const [renewsAt, setRenewsAt] = useState(toDateInputValue(relationship.renewsAt));\n const [autoRenew, setAutoRenew] = useState(relationship.autoRenew);\n const [notes, setNotes] = useState(relationship.notes ?? '');\n const [department, setDepartment] = useState(relationship.department ?? '');\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const plansQ = usePlans(providerId || undefined);\n\n // Ensure the currently-linked provider is always selectable even if it isn't\n // in the first page of the registry.\n const providerOptions = (() => {\n const list = providersQ.data?.items ?? [];\n if (relationship.provider && !list.some((p) => p.id === relationship.provider?.id)) {\n return [relationship.provider, ...list];\n }\n return list;\n })();\n const plans = plansQ.data ?? [];\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n if (!label.trim()) {\n setFormError(\n tr('relationships.detail.editModal.labelRequired', 'A label is required.'),\n 'edit-label'\n );\n return;\n }\n const input: SubUpdateRelationshipInput = {\n label: label.trim(),\n interval,\n autoRenew,\n currency: currency.trim() || 'USD',\n notes: notes.trim(),\n // Always sent: an empty string clears the department allocation.\n department: department.trim(),\n ...(providerId ? { providerId } : {}),\n ...(planId ? { planId } : {}),\n ...(amount.trim() ? { amount: Number(amount) } : {}),\n ...(renewsAt ? { renewsAt: new Date(renewsAt).toISOString() } : {}),\n };\n update.mutate(\n { id: relationship.id, input },\n {\n onSuccess: () => onClose(),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('relationships.detail.editModal.error', 'Could not update relationship.')\n ),\n }\n );\n };\n\n return (\n <Modal\n title={tr('relationships.detail.editModal.title', 'Edit relationship')}\n onClose={onClose}\n maxWidthClassName=\"max-w-2xl\"\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n\n <div>\n <label htmlFor=\"edit-label\" className={labelCls}>\n {tr('relationships.detail.editModal.labelLabel', 'Label')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('edit-label')}\n id=\"edit-label\"\n type=\"text\"\n value={label}\n onChange={(e) => setLabel(e.target.value)}\n className={inputCls}\n required\n />\n </div>\n\n <div>\n <label htmlFor=\"edit-department\" className={labelCls}>\n {tr('relationships.detail.editModal.departmentLabel', 'Department or team')}\n </label>\n <input\n {...fieldErrorProps('edit-department')}\n id=\"edit-department\"\n type=\"text\"\n maxLength={120}\n value={department}\n onChange={(e) => setDepartment(e.target.value)}\n placeholder={tr(\n 'relationships.detail.editModal.departmentPlaceholder',\n 'e.g. Engineering, Marketing'\n )}\n className={inputCls}\n />\n </div>\n\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"edit-provider\" className={labelCls}>\n {tr('relationships.detail.editModal.providerLabel', 'Provider')}\n </label>\n <select\n {...fieldErrorProps('edit-provider')}\n id=\"edit-provider\"\n value={providerId}\n onChange={(e) => {\n setProviderId(e.target.value);\n setPlanId('');\n }}\n className={inputCls}\n >\n <option value=\"\">\n {tr('relationships.detail.editModal.providerNone', '— None —')}\n </option>\n {providerOptions.map((p) => (\n <option key={p.id} value={p.id}>\n {p.name}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"edit-plan\" className={labelCls}>\n {tr('relationships.detail.editModal.planLabel', 'Plan')}\n </label>\n <select\n {...fieldErrorProps('edit-plan')}\n id=\"edit-plan\"\n value={planId}\n onChange={(e) => setPlanId(e.target.value)}\n className={inputCls}\n disabled={!providerId || plans.length === 0}\n >\n <option value=\"\">{tr('relationships.detail.editModal.planNone', '— None —')}</option>\n {plans.map((pl) => (\n <option key={pl.id} value={pl.id}>\n {pl.name}\n </option>\n ))}\n </select>\n </div>\n </div>\n\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <div>\n <label htmlFor=\"edit-amount\" className={labelCls}>\n {tr('relationships.detail.editModal.amountLabel', 'Amount')}\n </label>\n <input\n {...fieldErrorProps('edit-amount')}\n id=\"edit-amount\"\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={amount}\n onChange={(e) => setAmount(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"edit-currency\" className={labelCls}>\n {tr('relationships.detail.editModal.currencyLabel', 'Currency')}\n </label>\n <input\n {...fieldErrorProps('edit-currency')}\n id=\"edit-currency\"\n type=\"text\"\n value={currency}\n onChange={(e) => setCurrency(e.target.value.toUpperCase())}\n maxLength={3}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"edit-interval\" className={labelCls}>\n {tr('relationships.detail.editModal.intervalLabel', 'Billing interval')}\n </label>\n <select\n {...fieldErrorProps('edit-interval')}\n id=\"edit-interval\"\n value={interval}\n onChange={(e) => setInterval(e.target.value as SubBillingInterval)}\n className={inputCls}\n >\n {INTERVALS.map((i) => (\n <option key={i} value={i}>\n {i.replace(/_/g, ' ')}\n </option>\n ))}\n </select>\n </div>\n </div>\n\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <div>\n <label htmlFor=\"edit-renews\" className={labelCls}>\n {tr('relationships.detail.editModal.renewsOnLabel', 'Renews on')}\n </label>\n <input\n {...fieldErrorProps('edit-renews')}\n id=\"edit-renews\"\n type=\"date\"\n value={renewsAt}\n onChange={(e) => setRenewsAt(e.target.value)}\n className={inputCls}\n />\n </div>\n <div className=\"flex items-end\">\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={autoRenew}\n onChange={(e) => setAutoRenew(e.target.checked)}\n className=\"size-4 rounded border-border-subtle\"\n />\n {tr('relationships.detail.editModal.autoRenews', 'Auto-renews')}\n </label>\n </div>\n </div>\n\n <div>\n <label htmlFor=\"edit-notes\" className={labelCls}>\n {tr('relationships.detail.editModal.notesLabel', 'Notes')}\n </label>\n <textarea\n {...fieldErrorProps('edit-notes')}\n id=\"edit-notes\"\n value={notes}\n onChange={(e) => setNotes(e.target.value)}\n rows={3}\n className={inputCls}\n />\n </div>\n\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('relationships.detail.editModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={update.isPending}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {update.isPending\n ? tr('relationships.detail.editModal.saving', 'Saving…')\n : tr('relationships.detail.editModal.submit', 'Save changes')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Add entitlement modal → subCreateEntitlement\n// ---------------------------------------------------------------------------\n\nfunction AddEntitlementModal({\n relationshipId,\n onClose,\n}: {\n relationshipId: string;\n onClose: () => void;\n}) {\n const tr = useTr();\n const create = useCreateEntitlement();\n const [name, setName] = useState('');\n const [type, setType] = useState<SubEntitlementType>('FEATURE_ACCESS');\n const [quota, setQuota] = useState('');\n const [unit, setUnit] = useState('');\n const [description, setDescription] = useState('');\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n if (!name.trim()) {\n setFormError(\n tr(\n 'relationships.detail.addEntitlementModal.nameRequired',\n 'An entitlement name is required.'\n ),\n 'ent-name'\n );\n return;\n }\n create.mutate(\n {\n relationshipId,\n name: name.trim(),\n type,\n ...(quota.trim() ? { quota: Number(quota) } : {}),\n ...(unit.trim() ? { unit: unit.trim() } : {}),\n ...(description.trim() ? { description: description.trim() } : {}),\n },\n {\n onSuccess: () => onClose(),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('relationships.detail.addEntitlementModal.error', 'Could not add entitlement.')\n ),\n }\n );\n };\n\n return (\n <Modal\n title={tr('relationships.detail.addEntitlementModal.title', 'Add entitlement')}\n onClose={onClose}\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n <div>\n <label htmlFor=\"ent-name\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.nameLabel', 'Name')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('ent-name')}\n id=\"ent-name\"\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={tr(\n 'relationships.detail.addEntitlementModal.namePlaceholder',\n 'e.g. Seats, API calls, Priority support'\n )}\n className={inputCls}\n required\n />\n </div>\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <div>\n <label htmlFor=\"ent-type\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.typeLabel', 'Type')}\n </label>\n <select\n {...fieldErrorProps('ent-type')}\n id=\"ent-type\"\n value={type}\n onChange={(e) => setType(e.target.value as SubEntitlementType)}\n className={inputCls}\n >\n {ENTITLEMENT_TYPES.map((t) => (\n <option key={t} value={t}>\n {t.replace(/_/g, ' ')}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"ent-quota\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.quotaLabel', 'Quota')}\n </label>\n <input\n {...fieldErrorProps('ent-quota')}\n id=\"ent-quota\"\n type=\"number\"\n min=\"0\"\n value={quota}\n onChange={(e) => setQuota(e.target.value)}\n placeholder={tr(\n 'relationships.detail.addEntitlementModal.quotaPlaceholder',\n 'e.g. 5'\n )}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"ent-unit\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.unitLabel', 'Unit')}\n </label>\n <input\n {...fieldErrorProps('ent-unit')}\n id=\"ent-unit\"\n type=\"text\"\n value={unit}\n onChange={(e) => setUnit(e.target.value)}\n placeholder={tr(\n 'relationships.detail.addEntitlementModal.unitPlaceholder',\n 'e.g. seats, GB'\n )}\n className={inputCls}\n />\n </div>\n </div>\n <div>\n <label htmlFor=\"ent-desc\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.descriptionLabel', 'Description')}\n </label>\n <textarea\n {...fieldErrorProps('ent-desc')}\n id=\"ent-desc\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n rows={2}\n className={inputCls}\n />\n </div>\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('relationships.detail.addEntitlementModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={create.isPending}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {create.isPending\n ? tr('relationships.detail.addEntitlementModal.adding', 'Adding…')\n : tr('relationships.detail.addEntitlementModal.submit', 'Add entitlement')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Attach asset modal → upload to files-svc, then subCreateAsset\n// ---------------------------------------------------------------------------\n\nfunction AttachAssetModal({\n relationshipId,\n onClose,\n}: {\n relationshipId: string;\n onClose: () => void;\n}) {\n const tr = useTr();\n const create = useCreateAsset();\n const { uploadFile, progress, isUploading } = useUploadFile();\n const [name, setName] = useState('');\n const [type, setType] = useState<SubAssetType>('RECEIPT');\n const [file, setFile] = useState<File | null>(null);\n const [expiresAt, setExpiresAt] = useState('');\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const busy = isUploading || create.isPending;\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n if (!file) {\n setFormError(\n tr('relationships.detail.attachAssetModal.chooseFile', 'Choose a file to attach.'),\n 'asset-file'\n );\n return;\n }\n try {\n const { fileId, fileName } = await uploadFile(file);\n await create.mutateAsync({\n relationshipId,\n name: name.trim() || fileName,\n type,\n fileId,\n ...(expiresAt ? { expiresAt: new Date(expiresAt).toISOString() } : {}),\n });\n onClose();\n } catch (err) {\n setFormError(\n err instanceof Error\n ? err.message\n : tr('relationships.detail.attachAssetModal.error', 'Could not attach the asset.')\n );\n }\n };\n\n return (\n <Modal\n title={tr('relationships.detail.attachAssetModal.title', 'Attach asset')}\n onClose={onClose}\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n <div>\n <label htmlFor=\"asset-file\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.fileLabel', 'File')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('asset-file')}\n id=\"asset-file\"\n type=\"file\"\n onChange={(e) => {\n const f = e.target.files?.[0] ?? null;\n setFile(f);\n if (f && !name.trim()) setName(f.name);\n }}\n className=\"w-full text-sm text-text-secondary file:me-3 file:rounded-lg file:border file:border-border-subtle file:bg-bg-surface file:px-3 file:py-1.5 file:text-sm file:font-medium file:text-text-primary hover:file:bg-bg-sunken\"\n />\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr(\n 'relationships.detail.attachAssetModal.fileHint',\n 'Stored securely in files — only a reference is kept here.'\n )}\n </p>\n </div>\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"asset-name\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.nameLabel', 'Name')}\n </label>\n <input\n {...fieldErrorProps('asset-name')}\n id=\"asset-name\"\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={tr(\n 'relationships.detail.attachAssetModal.namePlaceholder',\n 'Defaults to the file name'\n )}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"asset-type\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.typeLabel', 'Type')}\n </label>\n <select\n {...fieldErrorProps('asset-type')}\n id=\"asset-type\"\n value={type}\n onChange={(e) => setType(e.target.value as SubAssetType)}\n className={inputCls}\n >\n {ASSET_TYPES.map((t) => (\n <option key={t} value={t}>\n {t.replace(/_/g, ' ')}\n </option>\n ))}\n </select>\n </div>\n </div>\n <div>\n <label htmlFor=\"asset-expires\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.expiresOnLabel', 'Expires on')}\n </label>\n <input\n {...fieldErrorProps('asset-expires')}\n id=\"asset-expires\"\n type=\"date\"\n value={expiresAt}\n onChange={(e) => setExpiresAt(e.target.value)}\n className={inputCls}\n />\n </div>\n {isUploading && (\n <p className=\"text-xs text-text-secondary\">\n {tr('relationships.detail.attachAssetModal.uploading', 'Uploading… {{progress}}%', {\n progress,\n })}\n </p>\n )}\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('relationships.detail.attachAssetModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={busy}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {busy\n ? tr('relationships.detail.attachAssetModal.attaching', 'Attaching…')\n : tr('relationships.detail.attachAssetModal.submit', 'Attach asset')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Asset row — resolves a presigned download URL on demand\n// ---------------------------------------------------------------------------\n\nfunction AssetRow({ asset }: { asset: NonNullable<SubRelationship['assets']>[number] }) {\n const { formatDate, formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n const getDownloadUrl = useFileDownloadUrl();\n const [downloading, setDownloading] = useState(false);\n\n const handleDownload = async () => {\n if (!asset.file?.id) return;\n setDownloading(true);\n try {\n const url = await getDownloadUrl(asset.file.id);\n window.open(url, '_blank', 'noopener,noreferrer');\n } catch {\n // Non-fatal: a broken/expired file reference just can't be downloaded.\n } finally {\n setDownloading(false);\n }\n };\n\n return (\n <div className=\"flex items-center justify-between gap-3 p-3\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <Paperclip className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-medium text-text-primary\">{asset.name}</p>\n <p className=\"text-xs text-text-secondary\">{formatEnumLabel(asset.type)}</p>\n </div>\n </div>\n <div className=\"flex shrink-0 items-center gap-3\">\n {asset.expiresAt && (\n <span className=\"text-xs text-text-secondary\">\n {tr('relationships.detail.assetRow.expires', 'Expires {{date}}', {\n date: formatDate(asset.expiresAt),\n })}\n </span>\n )}\n {asset.file?.id && (\n <button\n type=\"button\"\n onClick={handleDownload}\n disabled={downloading}\n className=\"inline-flex items-center gap-1 rounded-lg border border-border-subtle px-2.5 py-1 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n <Download className=\"h-3.5 w-3.5\" />{' '}\n {downloading\n ? tr('relationships.detail.assetRow.opening', 'Opening…')\n : tr('relationships.detail.assetRow.download', 'Download')}\n </button>\n )}\n </div>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Invoice row (BOFF-8659) — every invoice linked to this relationship via\n// `SubInvoice.relationshipId` is shown in the Assets section alongside any\n// file-based assets, so users don't have to leave the relationship page to\n// discover that they have an outstanding invoice tied to it.\n// ---------------------------------------------------------------------------\n\nfunction InvoiceRow({ invoice }: { invoice: SubInvoice }) {\n const { formatCurrency, formatDate, formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n // Each invoice appears once, grouped by the (most-recent) due or issue\n // date and labelled with number · status, then a right-aligned total that\n // matches the Invoices list currency formatting.\n const label =\n invoice.number ?? tr('relationships.detail.invoiceRow.unnumbered', 'Unnumbered invoice');\n return (\n <div className=\"flex items-center justify-between gap-3 p-3\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <CreditCard className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-medium text-text-primary\">{label}</p>\n <p className=\"text-xs text-text-secondary\">\n {formatEnumLabel(invoice.status)}\n {invoice.dueDate\n ? ` · ${tr('relationships.detail.invoiceRow.due', 'due {{date}}', {\n date: formatDate(invoice.dueDate),\n })}`\n : invoice.issueDate\n ? ` · ${formatDate(invoice.issueDate)}`\n : ''}\n </p>\n </div>\n </div>\n <span className=\"shrink-0 text-sm font-medium tabular-nums text-text-primary\">\n {formatCurrency(invoice.total, invoice.currency)}\n </span>\n </div>\n );\n}\n\nexport function RelationshipDetailPage() {\n const { formatCurrency, formatDate, formatEnumLabel, formatIntervalSuffix } = useFormatters();\n\n const tr = useTr();\n const { id } = useParams<{ id: string }>();\n const { navigateTo } = useSubscriberBot();\n const { data: relationship, isLoading, isError, refetch } = useRelationship(id);\n const transition = useTransitionRelationship();\n const cancel = useCancelRelationship();\n const [actionError, setActionError] = useState<string | null>(null);\n const [showEdit, setShowEdit] = useState(false);\n const [showAddEntitlement, setShowAddEntitlement] = useState(false);\n const [showAttachAsset, setShowAttachAsset] = useState(false);\n // Open AI recommendations about this subscription (BOFF-3663). Best effort:\n // if the decision engine is unavailable the section is simply omitted, and\n // every change it could propose stays available through the actions above.\n // Invoices linked through SubInvoice.relationshipId (BOFF-8659). The svc\n // exposes them through subListInvoices(relationshipId), not as a field on\n // SubRelationship, so they are read with their own query.\n const relationshipInvoices = useInvoices(\n { relationshipId: id, pagination: { limit: 50, offset: 0 } },\n { enabled: Boolean(id) }\n );\n const openDecisions = useDecisions(\n { relationshipId: id, status: 'PROPOSED' },\n { enabled: Boolean(id) }\n );\n\n if (isLoading) {\n return (\n <PageLayout title={tr('relationships.title', 'Relationship')}>\n <LoadingView label={tr('relationships.detail.loading', 'Loading relationship…')} />\n </PageLayout>\n );\n }\n\n if (isError) {\n return (\n <PageLayout title={tr('relationships.title', 'Relationship')}>\n <ErrorView\n message={tr('relationships.detail.error', 'Could not load this relationship.')}\n onRetry={() => void refetch()}\n />\n </PageLayout>\n );\n }\n\n if (!relationship) {\n return (\n <PageLayout title={tr('relationships.title', 'Relationship')}>\n <EmptyState\n illustration=\"empty-data\"\n title={tr('relationships.detail.notFoundTitle', 'Relationship not found')}\n description={tr(\n 'relationships.detail.notFoundDescription',\n 'It may have been removed, or you may not have access to it.'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships')}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90\"\n >\n {tr('relationships.detail.backToRelationships', 'Back to relationships')}\n </button>\n }\n />\n </PageLayout>\n );\n }\n\n const r = relationship;\n const isBusy = transition.isPending || cancel.isPending;\n\n const runTransition = (status: SubRelationshipStatus) => {\n setActionError(null);\n transition.mutate(\n { id: r.id, status },\n {\n onError: (e) =>\n setActionError(\n e instanceof Error\n ? e.message\n : tr('relationships.detail.transitionError', 'Transition failed')\n ),\n }\n );\n };\n\n const runCancel = () => {\n setActionError(null);\n cancel.mutate(r.id, {\n onError: (e) =>\n setActionError(\n e instanceof Error ? e.message : tr('relationships.detail.cancelError', 'Cancel failed')\n ),\n });\n };\n\n // Renewal timeline — built entirely from the real renewalEvents, oldest → newest.\n const renewalTimeline: TimelineItem[] = [...(r.renewalEvents ?? [])]\n .sort((a, b) => new Date(a.occursAt).getTime() - new Date(b.occursAt).getTime())\n .map((event) => {\n const ts = new Date(event.occursAt).getTime();\n const isFuture = !Number.isNaN(ts) && ts > Date.now();\n return {\n title: formatEnumLabel(event.eventType),\n sub: `${formatDate(event.occursAt)}${event.detail ? ` · ${event.detail}` : ''}`,\n meta:\n event.amount != null\n ? formatCurrency(event.amount, event.currency ?? r.currency)\n : undefined,\n tone: isFuture ? 'warning' : 'muted',\n };\n });\n\n const autoRenewPill = r.autoRenew ? (\n <span className=\"inline-flex items-center rounded-full bg-status-success-bg-subtle px-2 py-0.5 text-xs font-medium text-status-success-text\">\n {tr('relationships.detail.autoRenewOn', 'On')}\n </span>\n ) : (\n <span className=\"inline-flex items-center rounded-full bg-bg-sunken px-2 py-0.5 text-xs font-medium text-text-secondary\">\n {tr('relationships.detail.autoRenewOff', 'Off')}\n </span>\n );\n\n // Only offer transitions the svc state machine accepts from the current\n // status (a cancelled relationship no longer shows Activate / Pause).\n const availableTransitions = TRANSITIONS.filter((t) => canTransition(r.status, t.status));\n const planFeatures = r.plan?.features ?? [];\n\n return (\n <PageLayout\n title={r.label}\n description={r.provider?.name ?? tr(KIND_KEY[r.kind], formatEnumLabel(r.kind))}\n actions={\n <div className=\"flex flex-wrap items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => setShowEdit(true)}\n className=\"inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Pencil className=\"h-4 w-4\" /> {tr('relationships.detail.edit', 'Edit')}\n </button>\n <button\n type=\"button\"\n data-testid=\"negotiate-bill\"\n onClick={() =>\n navigateTo(`/negotiations/new?relationshipId=${encodeURIComponent(r.id)}`)\n }\n className=\"inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Handshake className=\"h-4 w-4\" />{' '}\n {tr('relationships.detail.negotiate', 'Negotiate this bill')}\n </button>\n <button\n type=\"button\"\n data-testid=\"request-procurement\"\n onClick={() =>\n navigateTo(`/procurement/new?relationshipId=${encodeURIComponent(r.id)}`)\n }\n className=\"inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Briefcase className=\"h-4 w-4\" />{' '}\n {tr('relationships.detail.procurement', 'Ask an expert to negotiate')}\n </button>\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships')}\n className=\"inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <ArrowLeft className=\"rtl:rotate-180 h-4 w-4\" />{' '}\n {tr('relationships.detail.back', 'Back')}\n </button>\n </div>\n }\n >\n {/* Hero summary + lifecycle actions */}\n <GlassCard treatment=\"glass\" glow className=\"p-5 sm:p-6\">\n <div className=\"flex flex-col gap-5 lg:flex-row lg:items-start lg:justify-between\">\n <div className=\"min-w-0\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {tr(KIND_KEY[r.kind], formatEnumLabel(r.kind))}\n </p>\n <div className=\"mt-2 flex flex-wrap items-center gap-3\">\n <span className=\"text-3xl font-bold tabular-nums text-text-primary\">\n {formatCurrency(r.amount, r.currency)}\n <span className=\"text-base font-normal text-text-secondary\">\n {formatIntervalSuffix(r.interval)}\n </span>\n </span>\n <StatusBadge status={r.status} />\n </div>\n <div className=\"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-text-secondary\">\n <span className=\"inline-flex items-center gap-1.5\">\n <CalendarClock className=\"h-3.5 w-3.5\" />\n {r.renewsAt\n ? tr('relationships.detail.renews', 'Renews {{date}}', {\n date: formatDate(r.renewsAt),\n })\n : tr('relationships.detail.noRenewalScheduled', 'No renewal scheduled')}\n </span>\n <span className=\"inline-flex items-center gap-1.5\">\n <ShieldCheck className=\"h-3.5 w-3.5\" />\n {formatEnumLabel(r.discoverySource)}\n </span>\n <span className=\"inline-flex items-center gap-1.5\">\n {tr('relationships.detail.autoRenew', 'Auto-renew')} {autoRenewPill}\n </span>\n </div>\n {r.tags.length > 0 && (\n <div className=\"mt-3 flex flex-wrap items-center gap-2\">\n <Tag className=\"h-3.5 w-3.5 text-text-secondary\" />\n {r.tags.map((tag) => (\n <span\n key={tag}\n className=\"rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs text-text-secondary\"\n >\n {tag}\n </span>\n ))}\n </div>\n )}\n </div>\n\n {/* Lifecycle actions */}\n <div className=\"grid shrink-0 grid-cols-2 gap-2 sm:flex sm:flex-wrap lg:flex-col lg:items-stretch\">\n {availableTransitions.map((t) => {\n const Icon = t.icon;\n return (\n <button\n key={t.status}\n type=\"button\"\n disabled={isBusy}\n onClick={() => runTransition(t.status)}\n className=\"inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm sm:min-h-0 sm:text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n <Icon className=\"h-3.5 w-3.5\" /> {tr(t.labelKey, t.defaultLabel)}\n </button>\n );\n })}\n {canTransition(r.status, 'CANCELLED') && (\n <button\n type=\"button\"\n disabled={isBusy}\n onClick={runCancel}\n className=\"inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-3 py-1.5 text-sm sm:min-h-0 sm:text-xs font-medium text-status-error-text hover:opacity-90 disabled:opacity-50\"\n >\n <Ban className=\"h-3.5 w-3.5\" />{' '}\n {tr('relationships.detail.actions.cancel', 'Cancel')}\n </button>\n )}\n </div>\n </div>\n </GlassCard>\n\n {actionError && (\n <div className=\"mt-4 rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\">\n {actionError}\n </div>\n )}\n\n {/* Main layout: details (left) + health & timeline rail (right) */}\n <div className=\"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-3\">\n <div className=\"space-y-4 lg:col-span-2\">\n <div className=\"grid grid-cols-1 gap-4 md:grid-cols-2\">\n {/* Plan & pricing */}\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <CreditCard className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.planPricing', 'Plan & pricing')}\n </div>\n <div className=\"mt-3\">\n <InfoRow\n label={tr('relationships.detail.info.plan', 'Plan')}\n value={r.plan?.name ?? '—'}\n />\n <InfoRow\n label={tr('relationships.detail.info.price', 'Price')}\n value={\n <>\n {formatCurrency(r.amount, r.currency)}\n <span className=\"font-normal text-text-secondary\">\n {formatIntervalSuffix(r.interval)}\n </span>\n </>\n }\n />\n <InfoRow\n label={tr('relationships.detail.info.billingInterval', 'Billing interval')}\n value={formatEnumLabel(r.interval)}\n />\n <InfoRow\n label={tr('relationships.detail.info.provider', 'Provider')}\n value={r.provider?.name ?? '—'}\n />\n </div>\n {planFeatures.length > 0 && (\n <div className=\"mt-3 flex flex-wrap gap-1.5\">\n {planFeatures.map((f) => (\n <span\n key={f}\n className=\"rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs text-text-secondary\"\n >\n {f}\n </span>\n ))}\n </div>\n )}\n </GlassCard>\n\n {/* Payment & billing */}\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <Wallet className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.paymentBilling', 'Payment & billing')}\n </div>\n <div className=\"mt-3\">\n <InfoRow\n label={tr('relationships.detail.info.currency', 'Currency')}\n value={r.currency}\n />\n <InfoRow\n label={tr('relationships.detail.info.autoRenew', 'Auto-renew')}\n value={autoRenewPill}\n />\n <InfoRow\n label={tr('relationships.detail.info.nextRenewal', 'Next renewal')}\n value={r.renewsAt ? formatDate(r.renewsAt) : '—'}\n />\n <InfoRow\n label={tr('relationships.detail.info.started', 'Started')}\n value={r.startedAt ? formatDate(r.startedAt) : '—'}\n />\n {r.trialEndsAt && (\n <InfoRow\n label={tr('relationships.detail.info.trialEnds', 'Trial ends')}\n value={formatDate(r.trialEndsAt)}\n />\n )}\n </div>\n </GlassCard>\n </div>\n\n {/* Open AI recommendations for this subscription */}\n {(openDecisions.data?.items.length ?? 0) > 0 && (\n <Section\n className=\"mt-0\"\n title={tr('relationships.detail.sections.aiRecommendations', 'AI recommendations')}\n description={tr(\n 'relationships.detail.sections.aiRecommendationsDescription',\n 'Open recommendations about this subscription. You can also make any of these changes by hand above.'\n )}\n >\n <AiDisclaimer className=\"mb-3\" />\n <div className=\"grid grid-cols-1 gap-3\" data-testid=\"relationship-decisions\">\n {openDecisions.data?.items.map((d) => (\n <DecisionCard key={d.id} decision={d} />\n ))}\n </div>\n </Section>\n )}\n\n {/* Entitlements */}\n <Section\n className=\"mt-0\"\n title={tr('relationships.detail.sections.entitlements', 'Entitlements')}\n description={tr(\n 'relationships.detail.sections.entitlementsDescription',\n 'What this relationship grants you'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => setShowAddEntitlement(true)}\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Plus className=\"h-3.5 w-3.5\" />{' '}\n {tr('relationships.detail.sections.addEntitlement', 'Add entitlement')}\n </button>\n }\n >\n {!r.entitlements || r.entitlements.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('relationships.detail.empty.noEntitlementsTitle', 'No entitlements')}\n description={tr(\n 'relationships.detail.empty.noEntitlementsDescription',\n 'Entitlements (seats, quotas, feature access) will appear here.'\n )}\n />\n ) : (\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n {r.entitlements.map((e) => {\n const hasQuota = e.quota != null && e.quota > 0;\n return (\n <GlassCard key={e.id} treatment=\"plain\" className=\"p-4\">\n <div className=\"flex items-start justify-between gap-2\">\n <p className=\"min-w-0 truncate text-sm font-medium text-text-primary\">\n {e.name}\n </p>\n <StatusBadge status={e.isActive ? 'ACTIVE' : 'DISABLED'} />\n </div>\n <p className=\"mt-1 text-xs text-text-secondary\">{formatEnumLabel(e.type)}</p>\n {hasQuota && (\n <div className=\"mt-3\">\n <div className=\"flex items-center justify-between text-xs text-text-secondary\">\n <span>\n {e.used} / {e.quota}\n {e.unit ? ` ${e.unit}` : ''}\n </span>\n <span className=\"tabular-nums\">\n {Math.round((e.used / (e.quota as number)) * 100)}%\n </span>\n </div>\n <MiniProgress\n label={tr('common.quotaUtilization', 'Quota utilization')}\n value={e.used}\n max={e.quota as number}\n tone={\n e.used / (e.quota as number) >= 0.9\n ? 'negative'\n : e.used / (e.quota as number) >= 0.7\n ? 'warning'\n : 'accent'\n }\n className=\"mt-1.5\"\n />\n </div>\n )}\n </GlassCard>\n );\n })}\n </div>\n )}\n </Section>\n\n {/* Assets — file-based assets + relationship-owned invoices.\n BOFF-8659: invoices linked via `SubInvoice.relationshipId` are now\n shown here too, so the panel copy \"Invoices, contracts, licenses\n and credentials\" is honored for the cross-module Relationships ↔\n Invoices flow. */}\n <Section\n className=\"mt-0\"\n title={tr('relationships.detail.sections.assets', 'Assets')}\n description={tr(\n 'relationships.detail.sections.assetsDescription',\n 'Invoices, contracts, licenses and credentials'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => setShowAttachAsset(true)}\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Plus className=\"h-3.5 w-3.5\" />{' '}\n {tr('relationships.detail.sections.attachAsset', 'Attach asset')}\n </button>\n }\n >\n {(() => {\n const assets = r.assets ?? [];\n // BOFF-8659 — pull relationship-owned invoices into the same\n // Assets list, sorted next to file-based assets by their sort\n // time so invoices appear in the same order as the Invoices\n // list (newest first).\n const invoices: SubInvoice[] = relationshipInvoices.data?.items ?? [];\n const hasAny = assets.length > 0 || invoices.length > 0;\n if (!hasAny) {\n return (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('relationships.detail.empty.noAssetsTitle', 'No assets attached')}\n description={tr(\n 'relationships.detail.empty.noAssetsDescription',\n 'Attach invoices, contracts, licenses or receipts to this relationship.'\n )}\n />\n );\n }\n type AssetLike =\n | {\n kind: 'asset';\n sort: number;\n asset: NonNullable<SubRelationship['assets']>[number];\n }\n | {\n kind: 'invoice';\n sort: number;\n invoice: SubInvoice;\n };\n const combined: AssetLike[] = [\n ...assets.map((a) => ({\n kind: 'asset' as const,\n sort: new Date(a.createdAt).getTime() || 0,\n asset: a,\n })),\n ...invoices.map((i) => ({\n kind: 'invoice' as const,\n sort: new Date(i.createdAt).getTime() || 0,\n invoice: i,\n })),\n ].sort((x, y) => y.sort - x.sort);\n return (\n <GlassCard treatment=\"plain\" className=\"divide-y divide-border-subtle p-0\">\n {combined.map((row) =>\n row.kind === 'asset' ? (\n <AssetRow key={`a-${row.asset.id}`} asset={row.asset} />\n ) : (\n <InvoiceRow key={`i-${row.invoice.id}`} invoice={row.invoice} />\n )\n )}\n </GlassCard>\n );\n })()}\n </Section>\n\n {r.notes && (\n <GlassCard treatment=\"plain\" className=\"p-4\">\n <p className=\"text-xs font-medium text-text-secondary\">\n {tr('relationships.detail.sections.notes', 'Notes')}\n </p>\n <p className=\"mt-1 whitespace-pre-wrap text-sm text-text-primary\">{r.notes}</p>\n </GlassCard>\n )}\n </div>\n\n {/* Right rail: health gauge + renewal timeline */}\n <div className=\"space-y-4\">\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <Activity className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.healthScore', 'Health score')}\n </div>\n {r.healthScore != null ? (\n <div className=\"mt-4 flex flex-col items-center\">\n <Gauge\n value={r.healthScore}\n max={100}\n size={160}\n label={tr('relationships.detail.outOf100', 'of 100')}\n />\n <div className=\"mt-2 w-full\">\n <MiniProgress\n label={tr('common.healthScore', 'Health score')}\n value={r.healthScore}\n max={100}\n tone={healthTone(r.healthScore)}\n />\n </div>\n <p\n className=\"mt-3 text-center text-xs text-text-secondary\"\n data-testid=\"health-score-basis\"\n >\n {tr(\n 'relationships.detail.healthScoreBasis',\n 'Computed from usage, payment history, price stability and overlap with your other subscriptions.'\n )}\n </p>\n </div>\n ) : (\n <p className=\"mt-4 text-sm text-text-secondary\">\n {tr(\n 'relationships.detail.empty.noHealthScore',\n 'Not scored yet. A health score appears once Subscriber Bot has enough signal.'\n )}\n </p>\n )}\n </GlassCard>\n\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <CalendarClock className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.renewalTimeline', 'Renewal timeline')}\n </div>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {tr(\n 'relationships.detail.sections.renewalTimelineDescription',\n 'Detected renewals and price changes'\n )}\n </p>\n {renewalTimeline.length === 0 ? (\n <div className=\"mt-4\">\n <EmptyState\n illustration=\"empty-data\"\n title={tr('relationships.detail.empty.noRenewalEventsTitle', 'No renewal events')}\n description={tr(\n 'relationships.detail.empty.noRenewalEventsDescription',\n \"Renewals and price changes will appear here as they're detected.\"\n )}\n />\n </div>\n ) : (\n <Timeline items={renewalTimeline} className=\"mt-4\" />\n )}\n </GlassCard>\n </div>\n </div>\n\n {showEdit && <RelationshipEditModal relationship={r} onClose={() => setShowEdit(false)} />}\n {showAddEntitlement && (\n <AddEntitlementModal relationshipId={r.id} onClose={() => setShowAddEntitlement(false)} />\n )}\n {showAttachAsset && (\n <AttachAssetModal relationshipId={r.id} onClose={() => setShowAttachAsset(false)} />\n )}\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwEA,IAAM,IACJ,wMACI,IAAW,sDAEX,IAAkC;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,IAA0C;CAC9C;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,IAA8B;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,KAAgD;CACpD,cAAc;CACd,YAAY;CACZ,SAAS;CACT,UAAU;CACV,YAAY;CACZ,mBAAmB;CACnB,YAAY;CACZ,OAAO;AACT,GAGM,KAKD;CACH;EACE,QAAQ;EACR,UAAU;EACV,cAAc;EACd,MAAM;CACR;CACA;EACE,QAAQ;EACR,UAAU;EACV,cAAc;EACd,MAAM;CACR;CACA;EACE,QAAQ;EACR,UAAU;EACV,cAAc;EACd,MAAM;CACR;AACF;AAGA,SAAS,EAAQ,EAAE,UAAO,YAA8C;CACtE,OACE,kBAAC,OAAD;EAAK,WAAU;YAAf,CACE,kBAAC,QAAD;GAAM,WAAU;aAAwC;EAAY,CAAA,GACpE,kBAAC,QAAD;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ACE,OAAO,EAAE;SACT,KAAK;SACL,MAAM;SACN,OAAO,EAAG,iCAAiC,QAAQ;QACpD,CAAA;QACD,kBAAC,OAAD;SAAK,WAAU;mBACb,kBAAC,GAAD;UACE,OAAO,EAAG,sBAAsB,cAAc;UAC9C,OAAO,EAAE;UACT,KAAK;UACL,MAAM,GAAW,EAAE,WAAW;SAC/B,CAAA;QACE,CAAA;QACL,kBAAC,KAAD;SACE,WAAU;SACV,eAAY;mBAEX,EACC,yCACA,kGACF;QACC,CAAA;OACA;QASE;SAEX,kBAAC,GAAD;MAAW,WAAU;MAAS,WAAU;gBAAxC;OACE,kBAAC,OAAD;QAAK,WAAU;kBAAf;SACE,kBAAC,GAAD,EAAe,WAAU,8BAA+B,CAAA;SAAE;SACzD,EAAG,iDAAiD,kBAAkB;QACpE;;OACL,kBAAC,KAAD;QAAG,WAAU;kBACV,EACC,4DACA,qCACF;OACC,CAAA;OACF,GAAgB,WAAW,IAC1B,kBAAC,OAAD;QAAK,WAAU;kBACb,kBAAC,GAAD;SACE,cAAa;SACb,OAAO,EAAG,mDAAmD,mBAAmB;SAChF,aAAa,EACX,yDACA,kEACF;QACD,CAAA;OACE,CAAA,IAEL,kBAAC,GAAD;QAAU,OAAO;QAAiB,WAAU;OAAQ,CAAA;MAE7C;OACR;MACF;;GAEJ,KAAY,kBAAC,IAAD;IAAuB,cAAc;IAAG,eAAe,EAAY,EAAK;GAAI,CAAA;GACxF,KACC,kBAAC,IAAD;IAAqB,gBAAgB,EAAE;IAAI,eAAe,EAAsB,EAAK;GAAI,CAAA;GAE1F,MACC,kBAAC,IAAD;IAAkB,gBAAgB,EAAE;IAAI,eAAe,EAAmB,EAAK;GAAI,CAAA;EAE3E;;AAEhB"}
|
|
@@ -51,9 +51,10 @@ export interface UpcomingRenewal {
|
|
|
51
51
|
soon: boolean;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
* Upcoming renewals, soonest first.
|
|
55
|
-
*
|
|
56
|
-
* `renewsAt`, so a
|
|
54
|
+
* Upcoming renewals, soonest first. A relationship's renewal event wins over
|
|
55
|
+
* its own `renewsAt`; a relationship with no event is still listed from its
|
|
56
|
+
* future `renewsAt`, so tracking a new subscription shows what renews next
|
|
57
|
+
* even when other relationships already have renewal events.
|
|
57
58
|
* `fallbackTitle` names an event whose relationship is not in the page.
|
|
58
59
|
* Relationships that no longer renew (cancelled, expired, lapsed, paused) are
|
|
59
60
|
* left out of both sources.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/utils/portfolio.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,UAAU,QAAsB,CAAC;AAE9C,yDAAyD;AACzD,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAS7D,CAAC;AAmBF,uDAAuD;AACvD,wBAAgB,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,UAAU,CAAC,GAAG,MAAM,CAEhG;AAED,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,4EAA4E;AAC5E,wBAAgB,cAAc,CAC5B,aAAa,EAAE,SAAS,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAC,EAAE,GAC7F,cAAc,CAOhB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,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Date(e).getTime(), l = (e) => {
|
|
60
60
|
let t = o.get(e);
|
|
61
61
|
return !t || n.has(t.status);
|
|
62
|
-
}
|
|
63
|
-
return r.length > 0 ? r.filter((e) => !Number.isNaN(c(e.occursAt)) && l(e.relationshipId)).map((e) => {
|
|
62
|
+
}, u = r.filter((e) => !Number.isNaN(c(e.occursAt)) && l(e.relationshipId)).map((e) => {
|
|
64
63
|
let t = o.get(e.relationshipId);
|
|
65
64
|
return {
|
|
66
65
|
id: e.id,
|
|
@@ -73,8 +72,8 @@ function l(t, r, i, a = Date.now()) {
|
|
|
73
72
|
kind: t?.kind ?? null,
|
|
74
73
|
soon: c(e.occursAt) <= s
|
|
75
74
|
};
|
|
76
|
-
}).
|
|
77
|
-
if (!e.renewsAt || !n.has(e.status)) return !1;
|
|
75
|
+
}), d = new Set(u.map((e) => e.relationshipId)), f = t.filter((e) => {
|
|
76
|
+
if (d.has(e.id) || !e.renewsAt || !n.has(e.status)) return !1;
|
|
78
77
|
let t = c(e.renewsAt);
|
|
79
78
|
return !Number.isNaN(t) && t >= a;
|
|
80
79
|
}).map((e) => {
|
|
@@ -90,7 +89,8 @@ function l(t, r, i, a = Date.now()) {
|
|
|
90
89
|
kind: e.kind,
|
|
91
90
|
soon: c(t) <= s
|
|
92
91
|
};
|
|
93
|
-
})
|
|
92
|
+
});
|
|
93
|
+
return [...u, ...f].sort((e, t) => c(e.when) - c(t.when));
|
|
94
94
|
}
|
|
95
95
|
var u = {
|
|
96
96
|
TRIAL: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio.js","names":[],"sources":["../../../src/subscriberbot/utils/portfolio.ts"],"sourcesContent":["/**\n * Portfolio model shared by the desktop and mobile Subscriber Bot screens\n * @module subscriberbot/utils/portfolio\n *\n * Pure functions only (no React, no DOM) so the overview, the relationship\n * list and the relationship detail page compute spend, renewals and lifecycle\n * actions the same way at every viewport. Unit-tested in `portfolio.test.ts`.\n */\n\nimport type {\n SubBillingInterval,\n SubRelationship,\n SubRelationshipStatus,\n SubRenewalEvent,\n} from '../types';\n\nexport const MS_PER_DAY = 1000 * 60 * 60 * 24;\n\n/** Renewals inside this window are flagged as \"soon\". */\nexport const SOON_WINDOW_DAYS = 7;\n\n/**\n * Approximate monthly multiplier per billing interval, so total recurring\n * spend can be expressed as one comparable \"per month\" number. Usage-based\n * relationships count at their last known amount; free and lifetime ones\n * do not recur.\n */\nexport const MONTHLY_FACTOR: Record<SubBillingInterval, number> = {\n DAILY: 30,\n WEEKLY: 4.345,\n MONTHLY: 1,\n QUARTERLY: 1 / 3,\n YEARLY: 1 / 12,\n LIFETIME: 0,\n FREE: 0,\n USAGE_BASED: 1,\n};\n\n/**\n * Statuses that still renew. A cancelled, expired, lapsed or paused\n * relationship has no upcoming charge, even if it keeps an old `renewsAt`\n * or the renewal stream still holds an event for it.\n */\nconst RENEWING_STATUSES: ReadonlySet<SubRelationshipStatus> = new Set<SubRelationshipStatus>([\n 'ACTIVE',\n 'TRIAL',\n 'PAST_DUE',\n]);\n\n/** Statuses that are still being billed. */\nconst BILLING_STATUSES: ReadonlySet<SubRelationshipStatus> = new Set<SubRelationshipStatus>([\n 'ACTIVE',\n 'TRIAL',\n]);\n\n/** The relationship's cost normalised to one month. */\nexport function monthlyAmount(relationship: Pick<SubRelationship, 'amount' | 'interval'>): number {\n return relationship.amount * (MONTHLY_FACTOR[relationship.interval] ?? 1);\n}\n\nexport interface RecurringSpend {\n /** Sum of `monthlyAmount` over ACTIVE + TRIAL relationships. */\n monthly: number;\n /** Currency of the first billing relationship (portfolio display currency). */\n currency: string;\n /** Number of relationships that are still billing. */\n activeCount: number;\n}\n\n/** Total monthly recurring spend over the relationships that still bill. */\nexport function recurringSpend(\n relationships: readonly Pick<SubRelationship, 'amount' | 'interval' | 'status' | 'currency'>[]\n): RecurringSpend {\n const active = relationships.filter((r) => BILLING_STATUSES.has(r.status));\n return {\n monthly: active.reduce((sum, r) => sum + monthlyAmount(r), 0),\n currency: active[0]?.currency ?? relationships[0]?.currency ?? 'USD',\n activeCount: active.length,\n };\n}\n\n/**\n * Calendar days from today until `date`, in the viewer's local time zone:\n * 0 is \"today\", 1 is \"tomorrow\", negative is overdue. Counting calendar days\n * (not 24-hour blocks) matters for renewals stored at midnight UTC: one due\n * tomorrow used to read \"Renews today\" for most of the day before\n * (BOFF-4010). Null when the date is missing or unparseable.\n */\nexport function daysUntil(\n date: string | null | undefined,\n now: number = Date.now()\n): number | null {\n if (!date) return null;\n const t = new Date(date).getTime();\n if (Number.isNaN(t)) return null;\n return calendarDay(t) - calendarDay(now);\n}\n\n/**\n * The local calendar date of `ms` as a whole-day ordinal. Local Y/M/D are\n * re-read as a UTC date so daylight-saving shifts never leave a fraction.\n */\nfunction calendarDay(ms: number): number {\n const d = new Date(ms);\n return Math.round(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) / MS_PER_DAY);\n}\n\n/** Translation key, English fallback and params for a renewal countdown. */\nexport interface RenewalCountdown {\n key: string;\n fallback: string;\n params?: Record<string, number>;\n tone: 'overdue' | 'soon' | 'later';\n}\n\nexport function renewalCountdown(days: number): RenewalCountdown {\n if (days < 0) {\n return { key: 'mobile.renewal.overdue', fallback: 'Renewal overdue', tone: 'overdue' };\n }\n if (days === 0) {\n return { key: 'mobile.renewal.today', fallback: 'Renews today', tone: 'soon' };\n }\n if (days === 1) {\n return { key: 'mobile.renewal.tomorrow', fallback: 'Renews tomorrow', tone: 'soon' };\n }\n return {\n key: 'mobile.renewal.inDays',\n fallback: 'Renews in {{count}} days',\n params: { count: days },\n tone: days <= SOON_WINDOW_DAYS ? 'soon' : 'later',\n };\n}\n\n/** One normalised \"what charges next\" row. */\nexport interface UpcomingRenewal {\n id: string;\n relationshipId: string;\n title: string;\n when: string;\n amount: number | null;\n currency: string | null;\n interval: SubBillingInterval | null;\n kind: SubRelationship['kind'] | null;\n soon: boolean;\n}\n\n/**\n * Upcoming renewals, soonest first. Real renewal events win; when the event\n * stream is empty the list is derived from each relationship's own future\n * `renewsAt`, so a freshly-tracked portfolio still shows what renews next.\n * `fallbackTitle` names an event whose relationship is not in the page.\n * Relationships that no longer renew (cancelled, expired, lapsed, paused) are\n * left out of both sources.\n */\nexport function buildUpcomingRenewals(\n relationships: readonly SubRelationship[],\n events: readonly SubRenewalEvent[],\n fallbackTitle: (eventType: string) => string,\n now: number = Date.now()\n): UpcomingRenewal[] {\n const byId = new Map<string, SubRelationship>();\n relationships.forEach((r) => byId.set(r.id, r));\n const soonCutoff = now + SOON_WINDOW_DAYS * MS_PER_DAY;\n const time = (iso: string) => new Date(iso).getTime();\n\n // An event whose relationship is not in the page is kept: its status is\n // unknown here, and the renewal stream is the better source.\n const renews = (relationshipId: string) => {\n const rel = byId.get(relationshipId);\n return !rel || RENEWING_STATUSES.has(rel.status);\n };\n\n if (events.length > 0) {\n return events\n .filter((e) => !Number.isNaN(time(e.occursAt)) && renews(e.relationshipId))\n .map((e) => {\n const rel = byId.get(e.relationshipId);\n return {\n id: e.id,\n relationshipId: e.relationshipId,\n title: rel?.label ?? fallbackTitle(e.eventType),\n when: e.occursAt,\n amount: e.amount ?? rel?.amount ?? null,\n currency: e.currency ?? rel?.currency ?? null,\n interval: rel?.interval ?? null,\n kind: rel?.kind ?? null,\n soon: time(e.occursAt) <= soonCutoff,\n };\n })\n .sort((a, b) => time(a.when) - time(b.when));\n }\n\n return relationships\n .filter((r) => {\n if (!r.renewsAt || !RENEWING_STATUSES.has(r.status)) return false;\n const t = time(r.renewsAt);\n return !Number.isNaN(t) && t >= now;\n })\n .map((r) => {\n const when = r.renewsAt as string;\n return {\n id: r.id,\n relationshipId: r.id,\n title: r.label,\n when,\n amount: r.amount,\n currency: r.currency,\n interval: r.interval,\n kind: r.kind,\n soon: time(when) <= soonCutoff,\n };\n })\n .sort((a, b) => time(a.when) - time(b.when));\n}\n\n/**\n * Lifecycle state machine — mirrors `RELATIONSHIP_TRANSITIONS` in\n * wspace-subscriberbot-svc (relationships.service.ts). The server stays the\n * authority and re-validates every transition; this copy only decides which\n * actions are worth offering so the UI never shows a button that is certain\n * to fail.\n */\nexport const RELATIONSHIP_TRANSITIONS: Record<\n SubRelationshipStatus,\n readonly SubRelationshipStatus[]\n> = {\n TRIAL: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n ACTIVE: ['PAUSED', 'PAST_DUE', 'CANCELLED', 'EXPIRED'],\n PAUSED: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n PAST_DUE: ['ACTIVE', 'LAPSED', 'CANCELLED'],\n LAPSED: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n CANCELLED: [],\n EXPIRED: [],\n};\n\nexport function canTransition(from: SubRelationshipStatus, to: SubRelationshipStatus): boolean {\n return RELATIONSHIP_TRANSITIONS[from]?.includes(to) ?? false;\n}\n\nexport type QuickActionId = 'activate' | 'resume' | 'pause' | 'cancel';\n\nexport interface QuickAction {\n id: QuickActionId;\n /** Status the relationship moves to. CANCELLED goes through subCancelRelationship. */\n target: SubRelationshipStatus;\n /** Destructive actions ask for confirmation first. */\n destructive: boolean;\n}\n\n/**\n * The everyday actions a phone user reaches for from a list row or the\n * detail page — start, pause/resume, cancel — filtered to what the state\n * machine allows from `status`. Rarer bookkeeping transitions (mark expired,\n * past due, lapsed) stay on the desktop detail page.\n */\nexport function quickActionsFor(status: SubRelationshipStatus): QuickAction[] {\n const actions: QuickAction[] = [];\n if (canTransition(status, 'ACTIVE')) {\n actions.push({\n id: status === 'TRIAL' ? 'activate' : 'resume',\n target: 'ACTIVE',\n destructive: false,\n });\n }\n if (canTransition(status, 'PAUSED')) {\n actions.push({ id: 'pause', target: 'PAUSED', destructive: false });\n }\n if (canTransition(status, 'CANCELLED')) {\n actions.push({ id: 'cancel', target: 'CANCELLED', destructive: true });\n }\n return actions;\n}\n\n/**\n * Swipe-to-reveal geometry for a list row. `dx` is the horizontal drag\n * distance (negative = towards the left). Returns the clamped row offset\n * while dragging.\n */\nexport function swipeOffset(dx: number, wasOpen: boolean, revealWidth: number): number {\n const base = wasOpen ? -revealWidth : 0;\n return Math.min(0, Math.max(-revealWidth, base + dx));\n}\n\n/**\n * Whether the row should settle open once the finger lifts: past half the\n * action tray it snaps open, otherwise it snaps shut.\n */\nexport function swipeSettlesOpen(offset: number, revealWidth: number): boolean {\n return revealWidth > 0 && -offset >= revealWidth / 2;\n}\n\n/**\n * How long after a swipe ends the browser's trailing synthetic click is\n * treated as part of the gesture. Browsers dispatch it immediately after\n * `pointerup`, so a short window is enough; a real tap that follows later is\n * never swallowed, and a cancelled swipe (no click at all) leaves nothing\n * pending.\n */\nexport const SWIPE_CLICK_WINDOW_MS = 400;\n\n/** Deadline until which a click counts as the swipe's own trailing click. */\nexport function swipeClickDeadline(endedAt: number): number {\n return endedAt + SWIPE_CLICK_WINDOW_MS;\n}\n\n/** Whether a click at `now` is the trailing click of a swipe ending by `deadline`. */\nexport function isSwipeTrailingClick(now: number, deadline: number): boolean {\n return now <= deadline;\n}\n"],"mappings":";AAgBA,IAAa,IAAa,MAAO,KAAK,KAAK,IAW9B,IAAqD;CAChE,OAAO;CACP,QAAQ;CACR,SAAS;CACT,WAAW,IAAI;CACf,QAAQ,IAAI;CACZ,UAAU;CACV,MAAM;CACN,aAAa;AACf,GAOM,IAAwD,IAAI,IAA2B;CAC3F;CACA;CACA;AACF,CAAC,GAGK,IAAuD,IAAI,IAA2B,CAC1F,UACA,OACF,CAAC;AAGD,SAAgB,EAAc,GAAoE;CAChG,OAAO,EAAa,UAAU,EAAe,EAAa,aAAa;AACzE;AAYA,SAAgB,EACd,GACgB;CAChB,IAAM,IAAS,EAAc,QAAQ,MAAM,EAAiB,IAAI,EAAE,MAAM,CAAC;CACzE,OAAO;EACL,SAAS,EAAO,QAAQ,GAAK,MAAM,IAAM,EAAc,CAAC,GAAG,CAAC;EAC5D,UAAU,EAAO,IAAI,YAAY,EAAc,IAAI,YAAY;EAC/D,aAAa,EAAO;CACtB;AACF;AASA,SAAgB,EACd,GACA,IAAc,KAAK,IAAI,GACR;CACf,I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AAQ,KAAK;EACX,IAAI,MAAW,UAAU,aAAa;EACtC,QAAQ;EACR,aAAa;CACf,CAAC,GAEC,EAAc,GAAQ,QAAQ,KAChC,EAAQ,KAAK;EAAE,IAAI;EAAS,QAAQ;EAAU,aAAa;CAAM,CAAC,GAEhE,EAAc,GAAQ,WAAW,KACnC,EAAQ,KAAK;EAAE,IAAI;EAAU,QAAQ;EAAa,aAAa;CAAK,CAAC,GAEhE;AACT;AAOA,SAAgB,EAAY,GAAY,GAAkB,GAA6B;CACrF,IAAM,IAAO,IAAU,CAAC,IAAc;CACtC,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,GAAa,IAAO,CAAE,CAAC;AACtD;AAMA,SAAgB,EAAiB,GAAgB,GAA8B;CAC7E,OAAO,IAAc,KAAK,CAAC,KAAU,IAAc;AACrD;AAYA,SAAgB,EAAmB,GAAyB;CAC1D,OAAO,IAAA;AACT;AAGA,SAAgB,EAAqB,GAAa,GAA2B;CAC3E,OAAO,KAAO;AAChB"}
|
|
1
|
+
{"version":3,"file":"portfolio.js","names":[],"sources":["../../../src/subscriberbot/utils/portfolio.ts"],"sourcesContent":["/**\n * Portfolio model shared by the desktop and mobile Subscriber Bot screens\n * @module subscriberbot/utils/portfolio\n *\n * Pure functions only (no React, no DOM) so the overview, the relationship\n * list and the relationship detail page compute spend, renewals and lifecycle\n * actions the same way at every viewport. Unit-tested in `portfolio.test.ts`.\n */\n\nimport type {\n SubBillingInterval,\n SubRelationship,\n SubRelationshipStatus,\n SubRenewalEvent,\n} from '../types';\n\nexport const MS_PER_DAY = 1000 * 60 * 60 * 24;\n\n/** Renewals inside this window are flagged as \"soon\". */\nexport const SOON_WINDOW_DAYS = 7;\n\n/**\n * Approximate monthly multiplier per billing interval, so total recurring\n * spend can be expressed as one comparable \"per month\" number. Usage-based\n * relationships count at their last known amount; free and lifetime ones\n * do not recur.\n */\nexport const MONTHLY_FACTOR: Record<SubBillingInterval, number> = {\n DAILY: 30,\n WEEKLY: 4.345,\n MONTHLY: 1,\n QUARTERLY: 1 / 3,\n YEARLY: 1 / 12,\n LIFETIME: 0,\n FREE: 0,\n USAGE_BASED: 1,\n};\n\n/**\n * Statuses that still renew. A cancelled, expired, lapsed or paused\n * relationship has no upcoming charge, even if it keeps an old `renewsAt`\n * or the renewal stream still holds an event for it.\n */\nconst RENEWING_STATUSES: ReadonlySet<SubRelationshipStatus> = new Set<SubRelationshipStatus>([\n 'ACTIVE',\n 'TRIAL',\n 'PAST_DUE',\n]);\n\n/** Statuses that are still being billed. */\nconst BILLING_STATUSES: ReadonlySet<SubRelationshipStatus> = new Set<SubRelationshipStatus>([\n 'ACTIVE',\n 'TRIAL',\n]);\n\n/** The relationship's cost normalised to one month. */\nexport function monthlyAmount(relationship: Pick<SubRelationship, 'amount' | 'interval'>): number {\n return relationship.amount * (MONTHLY_FACTOR[relationship.interval] ?? 1);\n}\n\nexport interface RecurringSpend {\n /** Sum of `monthlyAmount` over ACTIVE + TRIAL relationships. */\n monthly: number;\n /** Currency of the first billing relationship (portfolio display currency). */\n currency: string;\n /** Number of relationships that are still billing. */\n activeCount: number;\n}\n\n/** Total monthly recurring spend over the relationships that still bill. */\nexport function recurringSpend(\n relationships: readonly Pick<SubRelationship, 'amount' | 'interval' | 'status' | 'currency'>[]\n): RecurringSpend {\n const active = relationships.filter((r) => BILLING_STATUSES.has(r.status));\n return {\n monthly: active.reduce((sum, r) => sum + monthlyAmount(r), 0),\n currency: active[0]?.currency ?? relationships[0]?.currency ?? 'USD',\n activeCount: active.length,\n };\n}\n\n/**\n * Calendar days from today until `date`, in the viewer's local time zone:\n * 0 is \"today\", 1 is \"tomorrow\", negative is overdue. Counting calendar days\n * (not 24-hour blocks) matters for renewals stored at midnight UTC: one due\n * tomorrow used to read \"Renews today\" for most of the day before\n * (BOFF-4010). Null when the date is missing or unparseable.\n */\nexport function daysUntil(\n date: string | null | undefined,\n now: number = Date.now()\n): number | null {\n if (!date) return null;\n const t = new Date(date).getTime();\n if (Number.isNaN(t)) return null;\n return calendarDay(t) - calendarDay(now);\n}\n\n/**\n * The local calendar date of `ms` as a whole-day ordinal. Local Y/M/D are\n * re-read as a UTC date so daylight-saving shifts never leave a fraction.\n */\nfunction calendarDay(ms: number): number {\n const d = new Date(ms);\n return Math.round(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) / MS_PER_DAY);\n}\n\n/** Translation key, English fallback and params for a renewal countdown. */\nexport interface RenewalCountdown {\n key: string;\n fallback: string;\n params?: Record<string, number>;\n tone: 'overdue' | 'soon' | 'later';\n}\n\nexport function renewalCountdown(days: number): RenewalCountdown {\n if (days < 0) {\n return { key: 'mobile.renewal.overdue', fallback: 'Renewal overdue', tone: 'overdue' };\n }\n if (days === 0) {\n return { key: 'mobile.renewal.today', fallback: 'Renews today', tone: 'soon' };\n }\n if (days === 1) {\n return { key: 'mobile.renewal.tomorrow', fallback: 'Renews tomorrow', tone: 'soon' };\n }\n return {\n key: 'mobile.renewal.inDays',\n fallback: 'Renews in {{count}} days',\n params: { count: days },\n tone: days <= SOON_WINDOW_DAYS ? 'soon' : 'later',\n };\n}\n\n/** One normalised \"what charges next\" row. */\nexport interface UpcomingRenewal {\n id: string;\n relationshipId: string;\n title: string;\n when: string;\n amount: number | null;\n currency: string | null;\n interval: SubBillingInterval | null;\n kind: SubRelationship['kind'] | null;\n soon: boolean;\n}\n\n/**\n * Upcoming renewals, soonest first. A relationship's renewal event wins over\n * its own `renewsAt`; a relationship with no event is still listed from its\n * future `renewsAt`, so tracking a new subscription shows what renews next\n * even when other relationships already have renewal events.\n * `fallbackTitle` names an event whose relationship is not in the page.\n * Relationships that no longer renew (cancelled, expired, lapsed, paused) are\n * left out of both sources.\n */\nexport function buildUpcomingRenewals(\n relationships: readonly SubRelationship[],\n events: readonly SubRenewalEvent[],\n fallbackTitle: (eventType: string) => string,\n now: number = Date.now()\n): UpcomingRenewal[] {\n const byId = new Map<string, SubRelationship>();\n relationships.forEach((r) => byId.set(r.id, r));\n const soonCutoff = now + SOON_WINDOW_DAYS * MS_PER_DAY;\n const time = (iso: string) => new Date(iso).getTime();\n\n // An event whose relationship is not in the page is kept: its status is\n // unknown here, and the renewal stream is the better source.\n const renews = (relationshipId: string) => {\n const rel = byId.get(relationshipId);\n return !rel || RENEWING_STATUSES.has(rel.status);\n };\n\n const fromEvents: UpcomingRenewal[] = events\n .filter((e) => !Number.isNaN(time(e.occursAt)) && renews(e.relationshipId))\n .map((e) => {\n const rel = byId.get(e.relationshipId);\n return {\n id: e.id,\n relationshipId: e.relationshipId,\n title: rel?.label ?? fallbackTitle(e.eventType),\n when: e.occursAt,\n amount: e.amount ?? rel?.amount ?? null,\n currency: e.currency ?? rel?.currency ?? null,\n interval: rel?.interval ?? null,\n kind: rel?.kind ?? null,\n soon: time(e.occursAt) <= soonCutoff,\n };\n });\n\n // Fall back per relationship, not per page: one relationship's event must\n // not hide the relationships that have no event yet.\n const covered = new Set(fromEvents.map((e) => e.relationshipId));\n const fromRelationships: UpcomingRenewal[] = relationships\n .filter((r) => {\n if (covered.has(r.id)) return false;\n if (!r.renewsAt || !RENEWING_STATUSES.has(r.status)) return false;\n const t = time(r.renewsAt);\n return !Number.isNaN(t) && t >= now;\n })\n .map((r) => {\n const when = r.renewsAt as string;\n return {\n id: r.id,\n relationshipId: r.id,\n title: r.label,\n when,\n amount: r.amount,\n currency: r.currency,\n interval: r.interval,\n kind: r.kind,\n soon: time(when) <= soonCutoff,\n };\n });\n\n return [...fromEvents, ...fromRelationships].sort((a, b) => time(a.when) - time(b.when));\n}\n\n/**\n * Lifecycle state machine — mirrors `RELATIONSHIP_TRANSITIONS` in\n * wspace-subscriberbot-svc (relationships.service.ts). The server stays the\n * authority and re-validates every transition; this copy only decides which\n * actions are worth offering so the UI never shows a button that is certain\n * to fail.\n */\nexport const RELATIONSHIP_TRANSITIONS: Record<\n SubRelationshipStatus,\n readonly SubRelationshipStatus[]\n> = {\n TRIAL: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n ACTIVE: ['PAUSED', 'PAST_DUE', 'CANCELLED', 'EXPIRED'],\n PAUSED: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n PAST_DUE: ['ACTIVE', 'LAPSED', 'CANCELLED'],\n LAPSED: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n CANCELLED: [],\n EXPIRED: [],\n};\n\nexport function canTransition(from: SubRelationshipStatus, to: SubRelationshipStatus): boolean {\n return RELATIONSHIP_TRANSITIONS[from]?.includes(to) ?? false;\n}\n\nexport type QuickActionId = 'activate' | 'resume' | 'pause' | 'cancel';\n\nexport interface QuickAction {\n id: QuickActionId;\n /** Status the relationship moves to. CANCELLED goes through subCancelRelationship. */\n target: SubRelationshipStatus;\n /** Destructive actions ask for confirmation first. */\n destructive: boolean;\n}\n\n/**\n * The everyday actions a phone user reaches for from a list row or the\n * detail page — start, pause/resume, cancel — filtered to what the state\n * machine allows from `status`. Rarer bookkeeping transitions (mark expired,\n * past due, lapsed) stay on the desktop detail page.\n */\nexport function quickActionsFor(status: SubRelationshipStatus): QuickAction[] {\n const actions: QuickAction[] = [];\n if (canTransition(status, 'ACTIVE')) {\n actions.push({\n id: status === 'TRIAL' ? 'activate' : 'resume',\n target: 'ACTIVE',\n destructive: false,\n });\n }\n if (canTransition(status, 'PAUSED')) {\n actions.push({ id: 'pause', target: 'PAUSED', destructive: false });\n }\n if (canTransition(status, 'CANCELLED')) {\n actions.push({ id: 'cancel', target: 'CANCELLED', destructive: true });\n }\n return actions;\n}\n\n/**\n * Swipe-to-reveal geometry for a list row. `dx` is the horizontal drag\n * distance (negative = towards the left). Returns the clamped row offset\n * while dragging.\n */\nexport function swipeOffset(dx: number, wasOpen: boolean, revealWidth: number): number {\n const base = wasOpen ? -revealWidth : 0;\n return Math.min(0, Math.max(-revealWidth, base + dx));\n}\n\n/**\n * Whether the row should settle open once the finger lifts: past half the\n * action tray it snaps open, otherwise it snaps shut.\n */\nexport function swipeSettlesOpen(offset: number, revealWidth: number): boolean {\n return revealWidth > 0 && -offset >= revealWidth / 2;\n}\n\n/**\n * How long after a swipe ends the browser's trailing synthetic click is\n * treated as part of the gesture. Browsers dispatch it immediately after\n * `pointerup`, so a short window is enough; a real tap that follows later is\n * never swallowed, and a cancelled swipe (no click at all) leaves nothing\n * pending.\n */\nexport const SWIPE_CLICK_WINDOW_MS = 400;\n\n/** Deadline until which a click counts as the swipe's own trailing click. */\nexport function swipeClickDeadline(endedAt: number): number {\n return endedAt + SWIPE_CLICK_WINDOW_MS;\n}\n\n/** Whether a click at `now` is the trailing click of a swipe ending by `deadline`. */\nexport function isSwipeTrailingClick(now: number, deadline: number): boolean {\n return now <= deadline;\n}\n"],"mappings":";AAgBA,IAAa,IAAa,MAAO,KAAK,KAAK,IAW9B,IAAqD;CAChE,OAAO;CACP,QAAQ;CACR,SAAS;CACT,WAAW,IAAI;CACf,QAAQ,IAAI;CACZ,UAAU;CACV,MAAM;CACN,aAAa;AACf,GAOM,IAAwD,IAAI,IAA2B;CAC3F;CACA;CACA;AACF,CAAC,GAGK,IAAuD,IAAI,IAA2B,CAC1F,UACA,OACF,CAAC;AAGD,SAAgB,EAAc,GAAoE;CAChG,OAAO,EAAa,UAAU,EAAe,EAAa,aAAa;AACzE;AAYA,SAAgB,EACd,GACgB;CAChB,IAAM,IAAS,EAAc,QAAQ,MAAM,EAAiB,IAAI,EAAE,MAAM,CAAC;CACzE,OAAO;EACL,SAAS,EAAO,QAAQ,GAAK,MAAM,IAAM,EAAc,CAAC,GAAG,CAAC;EAC5D,UAAU,EAAO,IAAI,YAAY,EAAc,IAAI,YAAY;EAC/D,aAAa,EAAO;CACtB;AACF;AASA,SAAgB,EACd,GACA,IAAc,KAAK,IAAI,GACR;CACf,IAAI,CAAC,GAAM,OAAO;CAClB,IAAM,IAAI,IAAI,KAAK,CAAI,EAAE,QAAQ;CAEjC,OADI,OAAO,MAAM,CAAC,IAAU,OACrB,EAAY,CAAC,IAAI,EAAY,CAAG;AACzC;AAMA,SAAS,EAAY,GAAoB;CAC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