diff --git a/src/app/dashboard/intelligence/page.tsx b/src/app/dashboard/intelligence/page.tsx new file mode 100644 index 0000000..d3ee274 --- /dev/null +++ b/src/app/dashboard/intelligence/page.tsx @@ -0,0 +1,158 @@ +'use client'; + +import Link from 'next/link'; +import { useQuery } from '@tanstack/react-query'; +import { apiFetch } from '../../../lib/api'; +import type { SavedSegment, ResearchBrief } from '../../../lib/api'; +import { useSession } from '../../../components/session-provider'; + +const B = '/dashboard'; + +interface StatCard { label: string; value: number | string; href: string; sublabel?: string } + +export default function IntelligenceOverviewPage() { + const { activeTenant } = useSession(); + const tenantId = activeTenant?.tenantId ?? ''; + + const { data: segments = [], isLoading: loadingSegs } = useQuery({ + queryKey: ['segments-intel', tenantId], + queryFn: () => apiFetch('/v1/segments', { tenantId }), + enabled: Boolean(tenantId), + staleTime: 60_000, + }); + + const { data: briefs = [], isLoading: loadingBriefs } = useQuery({ + queryKey: ['briefs-intel', tenantId], + queryFn: () => apiFetch('/v1/research-briefs', { tenantId }), + enabled: Boolean(tenantId), + staleTime: 60_000, + }); + + const isLoading = loadingSegs || loadingBriefs; + + const recentBriefs = [...briefs].sort( + (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(), + ).slice(0, 5); + + const stats: StatCard[] = [ + { label: 'Segmente salvate', value: segments.length, href: `${B}/segments`, sublabel: 'Căutări B2B salvate' }, + { label: 'Research Briefs', value: briefs.length, href: `${B}/research`, sublabel: 'Rapoarte de cercetare' }, + { label: 'Companii B2B', value: '147M+', href: `${B}/companies`, sublabel: 'Apollo/ClickHouse' }, + { label: 'Contact match AI', value: 'live', href: `${B}/companies`, sublabel: 'intelligence-api activ' }, + ]; + + return ( +
+
+

Intelligence Overview

+

+ Motorul de intelligence B2B — companii, segmente, research și insight-uri. +

+
+ + {isLoading ? ( +

Se încarcă…

+ ) : ( + <> +
+ {stats.map((s) => ( + +

{s.label}

+

{s.value}

+ {s.sublabel &&

{s.sublabel}

} + + ))} +
+ +
+ {/* Recent research briefs */} +
+
+

+ Research recente +

+ + Vezi toate → + +
+ {recentBriefs.length === 0 ? ( +

Niciun brief creat.

+ ) : ( +
    + {recentBriefs.map((b) => ( +
  • +

    {b.title}

    +
    + + {b.status} + + + {new Date(b.createdAt).toLocaleDateString('ro-RO')} + +
    +
  • + ))} +
+ )} +
+ + {/* Active segments */} +
+
+

+ Segmente active +

+ + Gestionează → + +
+ {segments.length === 0 ? ( +

Niciun segment salvat.

+ ) : ( +
    + {segments.slice(0, 6).map((s) => ( +
  • +

    {s.name}

    + + limit {s.resultLimit} + +
  • + ))} + {segments.length > 6 && ( +
  • +{segments.length - 6} mai multe
  • + )} +
+ )} +
+ + {/* Capability map */} +
+

+ Capabilități platformă Intelligence +

+
+ {[ + { label: 'Company Search', status: 'live', href: `${B}/companies` }, + { label: 'Saved Segments', status: 'live', href: `${B}/segments` }, + { label: 'Research Briefs', status: 'live', href: `${B}/research` }, + { label: 'People Intelligence', status: 'a3', href: `${B}/people-intelligence` }, + { label: 'Market Intelligence', status: 'a4', href: '#' }, + { label: 'Insights Engine', status: 'a3', href: '#' }, + { label: 'Trends & Patterns', status: 'a3', href: '#' }, + { label: 'Digital Twin', status: 'a4', href: '#' }, + ].map((cap) => ( +
+

{cap.label}

+ + {cap.status === 'live' ? '● live' : cap.status} + +
+ ))} +
+
+
+ + )} +
+ ); +}