From 15c8b56b250ddbc1d97bf56413d2b3fcea2e3a7e Mon Sep 17 00:00:00 2001 From: Marcos Fargas Date: Sat, 17 Oct 2026 20:53:38 +0200 Subject: [PATCH] feat(agencia): kpis y cartera arriba en portafolio y subpagina panel de control conexiones --- src/app/dashboard/agencia/conexiones/page.tsx | 43 +++++++++++++ src/app/dashboard/agencia/page.tsx | 64 +++++++++++-------- src/components/DashboardShell.tsx | 12 +++- 3 files changed, 90 insertions(+), 29 deletions(-) create mode 100644 src/app/dashboard/agencia/conexiones/page.tsx diff --git a/src/app/dashboard/agencia/conexiones/page.tsx b/src/app/dashboard/agencia/conexiones/page.tsx new file mode 100644 index 0000000..27a8aef --- /dev/null +++ b/src/app/dashboard/agencia/conexiones/page.tsx @@ -0,0 +1,43 @@ +import React from 'react'; +import Link from 'next/link'; +import { ArrowLeft } from 'lucide-react'; +import AgencyPortfolioBoard from '@/components/AgencyPortfolioBoard'; +import { createClient } from '@/lib/supabase/server'; +import { redirect } from 'next/navigation'; +import { PageHeader } from '@/components/ui'; +import { isAgencyRole, userRole } from '@/lib/agency'; + +export const revalidate = 0; + +export default async function AgencyConexionesPage() { + const supabase = await createClient(); + const { + data: { user }, + } = await supabase.auth.getUser(); + if (!user) redirect('/login'); + + if (!isAgencyRole(userRole(user))) { + redirect('/dashboard/kpis'); + } + + return ( +
+
+ + + Volver a Portafolio Agencia + + +
+ + +
+ ); +} diff --git a/src/app/dashboard/agencia/page.tsx b/src/app/dashboard/agencia/page.tsx index 9fd0240..25821f3 100644 --- a/src/app/dashboard/agencia/page.tsx +++ b/src/app/dashboard/agencia/page.tsx @@ -1,7 +1,7 @@ import React from 'react'; -import { Building2, DollarSign, Users, TrendingUp } from 'lucide-react'; +import Link from 'next/link'; +import { Building2, DollarSign, Users, TrendingUp, Plug, ArrowRight } from 'lucide-react'; import ClientManagement from '@/components/ClientManagement'; -import AgencyPortfolioBoard from '@/components/AgencyPortfolioBoard'; import { createClient } from '@/lib/supabase/server'; import { redirect } from 'next/navigation'; import { PageHeader } from '@/components/ui'; @@ -47,7 +47,7 @@ export default async function AgencyPage() { fetch(`${supabaseUrl}/rest/v1/tenants?select=*&order=created_at.asc`, { headers, cache: 'no-store' }), fetch(`${supabaseUrl}/rest/v1/ad_daily?select=spend`, { headers, cache: 'no-store' }), fetch(`${supabaseUrl}/rest/v1/leads?select=id`, { headers, cache: 'no-store' }), - fetch(`${supabaseUrl}/rest/v1/deals?select=amount&stage=eq.won`, { headers, cache: 'no-store' }) + fetch(`${supabaseUrl}/rest/v1/deals?select=amount&stage=eq.won`, { headers, cache: 'no-store' }), ]); if (tenantsRes.ok) tenants = await tenantsRes.json(); @@ -72,58 +72,66 @@ export default async function AgencyPage() { return (
- +
+ + + + Panel de control · clientes y conexiones + + +
- - - {/* Global Agency KPI Cards */} + {/* 1. Parte más alta: Global Agency KPI Cards */}
-
+
- Clientes / Tenants - + Clients / Tenants +

{tenants.length}

-

100% aislados vía RLS

+

100% aislados vía RLS

-
+
- Inversión Gestionada - + Inversión gestionada +

{totalSpend.toLocaleString('es-ES', { minimumFractionDigits: 2 })} €

-

Vía Windsor.ai pipeline

+

Vía Windsor.ai pipeline

-
+
- Leads Captados - + Leads captados +

{totalLeads}

-

{totalWonDeals} cerrados ganados

+

{totalWonDeals} cerrados ganados

-
+
- ROAS Blended Agencia - + ROAS blended agencia +

{blendedRoas}x

-

+

{totalRevenue.toLocaleString('es-ES', { minimumFractionDigits: 2 })} € generados

- {/* Interactive Tenants Management with Onboarding Form */} + {/* 2. Debajo: Módulo Cartera de Clientes Activos */}
); diff --git a/src/components/DashboardShell.tsx b/src/components/DashboardShell.tsx index 88edfd5..40747e5 100644 --- a/src/components/DashboardShell.tsx +++ b/src/components/DashboardShell.tsx @@ -23,6 +23,7 @@ import { Sparkles, Images, History, + Plug, } from 'lucide-react'; import SidebarTenantSwitcher from '@/components/SidebarTenantSwitcher'; import type { DashboardModuleId } from '@/lib/tenant-modules'; @@ -137,7 +138,7 @@ function shouldShowDateHeader(pathname: string | null): boolean { function isActive(pathname: string, href: string): boolean { if (pathname === href) return true; - if (href !== '/dashboard' && pathname.startsWith(href + '/')) return true; + if (href !== '/dashboard' && href !== '/dashboard/agencia' && pathname.startsWith(href + '/')) return true; return false; } @@ -288,6 +289,15 @@ export default function DashboardShell({ }} onNavigate={close} /> +