This commit is contained in:
unknown
2026-06-11 11:45:36 -04:00
23 changed files with 3226 additions and 73 deletions

View File

@@ -327,9 +327,15 @@ Somos los únicos en España que combinamos **captura instantánea del lead + ll
- **Título del paso:** ¿Cómo prefieres contarnos tu reforma, [Nombre]? - **Título del paso:** ¿Cómo prefieres contarnos tu reforma, [Nombre]?
- **Subtitle:** Tú eliges. Por cualquiera de las tres nos das lo que necesitamos para preparar tu render y tu presupuesto. - **Subtitle:** Tú eliges. Por cualquiera de las tres nos das lo que necesitamos para preparar tu render y tu presupuesto.
- **Stepper de progreso (encima del título):**
- Paso 1 (completado): *Tus datos*
- Paso 2 (actual): *Tu reforma*
- Paso 3 (pendiente): *Render + presupuesto*
- **Tarjeta Llamada — título:** Que te llamemos - **Tarjeta Llamada — título:** Que te llamemos
**Descripción:** Un asistente te llama y te hace unas preguntas rápidas. Lo más cómodo: no escribes nada. **Descripción:** Un asistente te llama y te hace unas preguntas rápidas. Lo más cómodo: no escribes nada.
**CTA:** Quiero que me llamen **CTA:** Quiero que me llamen
**Badge:** La más rápida
- **Tarjeta WhatsApp — título:** Por WhatsApp - **Tarjeta WhatsApp — título:** Por WhatsApp
**Descripción:** Seguimos por chat a tu ritmo. Puedes mandar fotos y notas cuando quieras. **Descripción:** Seguimos por chat a tu ritmo. Puedes mandar fotos y notas cuando quieras.
**CTA:** Seguir por WhatsApp **CTA:** Seguir por WhatsApp
@@ -337,6 +343,19 @@ Somos los únicos en España que combinamos **captura instantánea del lead + ll
**Descripción:** Tú lo cuentas zona por zona y subes las fotos. Recibes el presupuesto al instante. **Descripción:** Tú lo cuentas zona por zona y subes las fotos. Recibes el presupuesto al instante.
**CTA:** Rellenar el formulario **CTA:** Rellenar el formulario
#### Bloque "Qué pasa después" (debajo de las tarjetas del chooser)
> Recuerda al lead lo que va a recibir elija el canal que elija: personalización, render con
> imágenes en minutos, y visita gratuita posterior para el presupuesto definitivo.
- **Título:** Elijas lo que elijas, esto es lo que pasa después
- **Paso 1 — título:** Nos cuentas tu reforma a tu manera
**Body:** Fotos, medidas, gustos. Cuanto más nos cuentes, más se parecerá el resultado a lo que tienes en la cabeza.
- **Paso 2 — título:** Render + presupuesto en minutos
**Body:** Ves tu espacio ya reformado en imágenes, con un presupuesto orientativo desglosado partida a partida.
- **Paso 3 — título:** Visita gratuita para el presupuesto final
**Body:** Si te convence, acuerdas una visita con [Reformista]: ve la obra, la mide con detalle y te confirma el precio definitivo. Sin compromiso.
### Paso 2 (canal llamada) ### Paso 2 (canal llamada)
- **Título del paso:** Te llamamos cuando quieras - **Título del paso:** Te llamamos cuando quieras
@@ -714,6 +733,40 @@ del espacio. `[url]` apunta a su formulario personal del funnel. Tono: una sola
--- ---
## Onboarding del panel (tour guiado)
> Tooltips del tour del panel (driver.js). Tono cercano y útil, una idea por paso, frases cortas. Las pestañas secundarias se explican "de pasada" (una línea). Copy usado en `src/lib/onboarding/panel-tour.ts`.
### Pestaña Leads (`/panel`)
- **Intro** — *Tu panel de Reformix* · "Te enseño en 30 segundos qué hay en cada sitio. Puedes saltártelo cuando quieras con la X."
- **Leads** — "Aquí caen tus clientes con su presupuesto y su render ya preparados. Es tu día a día."
- **Precios y baremo** — "Tu tabla de precios, la mano de obra y el baremo de rentabilidad. De aquí salen los presupuestos."
- **Galería** — "Tus fotos de trabajos para enseñar en la web."
- **Opiniones** — "Reseñas de tus clientes; las apruebas tú antes de publicarlas."
- **Empresa** — "Tu marca, logo y datos de contacto."
- **Filtra por estado** — "Nuevos, contactados, presupuestados… para centrarte en lo que toca ahora."
- **Tus leads** — "Cada cliente con su estado y su presupuesto. Ábrelo para ver el detalle completo."
### Ficha del lead (`/panel/{id}`)
- **Presupuesto estimado** — "Lo que costaría la reforma según tu catálogo. Si no llega a tu baremo, lo verás en rojo."
- **Estado del lead** — "Avanza el lead por el funnel: contactado, presupuestado, ganado…"
- **Render de la reforma** — "La imagen del «después» que ve tu cliente, generada a partir de su foto y sus gustos."
- **Presupuesto desglosado** — "Edita las partidas, recalcula desde el catálogo y envíaselo al cliente por WhatsApp."
### Precios y baremo (`/panel/precios`)
- **Baremo de rentabilidad** — "El trabajo mínimo que te compensa. Solo te avisa a ti: marca en rojo los leads por debajo."
- **Mano de obra** — "Tus precios de mano de obra por m². El motor los usa para calcular cada presupuesto."
- **Tu catálogo** — "Materiales y precios por calidad. Puedes importarlos en bloque por CSV."
### Botón para repetir
- **Botón flotante** — "❓ Tour" (relanza el tour de la pestaña actual).
---
## Principios aplicados en todo el documento ## Principios aplicados en todo el documento
1. **Beneficios > Features** — "Tus clientes verán su reforma" > "Render IA con SDXL" 1. **Beneficios > Features** — "Tus clientes verán su reforma" > "Render IA con SDXL"

View File

@@ -186,6 +186,7 @@ CREATE TABLE "pricing_config" (
"factor_zona" jsonb DEFAULT '{}'::jsonb NOT NULL, "factor_zona" jsonb DEFAULT '{}'::jsonb NOT NULL,
"mano_obra" jsonb DEFAULT '{}'::jsonb NOT NULL, "mano_obra" jsonb DEFAULT '{}'::jsonb NOT NULL,
"extras" jsonb DEFAULT '{"tuberias":0,"boletin":0,"distribucion":0}'::jsonb NOT NULL, "extras" jsonb DEFAULT '{"tuberias":0,"boletin":0,"distribucion":0}'::jsonb NOT NULL,
"baremo_minimo" integer,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "pricing_config_tenant_id_unique" UNIQUE("tenant_id") CONSTRAINT "pricing_config_tenant_id_unique" UNIQUE("tenant_id")
); );

View File

@@ -0,0 +1 @@
ALTER TABLE "pricing_config" ADD COLUMN "baremo_minimo" integer;

File diff suppressed because it is too large Load Diff

View File

@@ -85,6 +85,13 @@
"when": 1780593183911, "when": 1780593183911,
"tag": "0011_warm_post", "tag": "0011_warm_post",
"breakpoints": true "breakpoints": true
},
{
"idx": 12,
"version": "7",
"when": 1781189893331,
"tag": "0012_lame_sentinel",
"breakpoints": true
} }
] ]
} }

View File

@@ -11,6 +11,7 @@
"@react-pdf/renderer": "^4.5.1", "@react-pdf/renderer": "^4.5.1",
"@tailwindcss/postcss": "^4.3.0", "@tailwindcss/postcss": "^4.3.0",
"bcryptjs": "^3.0.3", "bcryptjs": "^3.0.3",
"driver.js": "^1.4.0",
"drizzle-orm": "^0.45.2", "drizzle-orm": "^0.45.2",
"next": "16.2.6", "next": "16.2.6",
"nodemailer": "^8.0.10", "nodemailer": "^8.0.10",
@@ -4546,6 +4547,12 @@
"url": "https://dotenvx.com" "url": "https://dotenvx.com"
} }
}, },
"node_modules/driver.js": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/driver.js/-/driver.js-1.4.0.tgz",
"integrity": "sha512-Gm64jm6PmcU+si21sQhBrTAM1JvUrR0QhNmjkprNLxohOBzul9+pNHXgQaT9lW84gwg9GMLB3NZGuGolsz5uew==",
"license": "MIT"
},
"node_modules/drizzle-kit": { "node_modules/drizzle-kit": {
"version": "0.31.10", "version": "0.31.10",
"resolved": "https://registry.npmjs.org/drizzle-kit/-/drizzle-kit-0.31.10.tgz", "resolved": "https://registry.npmjs.org/drizzle-kit/-/drizzle-kit-0.31.10.tgz",

View File

@@ -21,6 +21,7 @@
"@react-pdf/renderer": "^4.5.1", "@react-pdf/renderer": "^4.5.1",
"@tailwindcss/postcss": "^4.3.0", "@tailwindcss/postcss": "^4.3.0",
"bcryptjs": "^3.0.3", "bcryptjs": "^3.0.3",
"driver.js": "^1.4.0",
"drizzle-orm": "^0.45.2", "drizzle-orm": "^0.45.2",
"next": "16.2.6", "next": "16.2.6",
"nodemailer": "^8.0.10", "nodemailer": "^8.0.10",

View File

@@ -46,7 +46,7 @@ export default async function FunnelPage({ params }: { params: Promise<{ slug: s
className={theme.heading === 'serif' ? 'theme-serif' : undefined} className={theme.heading === 'serif' ? 'theme-serif' : undefined}
style={themeStyle(tenant.themePreset, tenant.themeColor)} style={themeStyle(tenant.themePreset, tenant.themeColor)}
> >
<TenantBrand nombreEmpresa={tenant.nombreEmpresa} logoUrl={tenant.logoUrl} showLogin /> <TenantBrand nombreEmpresa={tenant.nombreEmpresa} logoUrl={tenant.logoUrl} />
<main id="main-content"> <main id="main-content">
<Hero slug={tenant.slug} /> <Hero slug={tenant.slug} />
<ReformaSlider /> <ReformaSlider />

View File

@@ -58,6 +58,20 @@
--transition-fast: 150ms ease; --transition-fast: 150ms ease;
--transition-base: 250ms ease; --transition-base: 250ms ease;
--transition-slow: 400ms ease; --transition-slow: 400ms ease;
/* Animations (usar con motion-safe: para respetar prefers-reduced-motion) */
--animate-fade-up: fade-up 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
@keyframes fade-up {
from {
opacity: 0;
transform: translateY(14px);
}
to {
opacity: 1;
transform: none;
}
}
} }
@layer base { @layer base {

View File

@@ -2,6 +2,7 @@ import Link from 'next/link';
import { headers } from 'next/headers'; import { headers } from 'next/headers';
import { notFound } from 'next/navigation'; import { notFound } from 'next/navigation';
import { getLead } from '@/db/queries'; import { getLead } from '@/db/queries';
import { getPricingConfigFor } from '@/db/pricing-queries';
import EstadoControl from '@/components/panel/EstadoControl'; import EstadoControl from '@/components/panel/EstadoControl';
import ConceptosEditor from '@/components/panel/ConceptosEditor'; import ConceptosEditor from '@/components/panel/ConceptosEditor';
import OpinionLinkBox from '@/components/panel/OpinionLinkBox'; import OpinionLinkBox from '@/components/panel/OpinionLinkBox';
@@ -19,9 +20,20 @@ import type { BudgetResult } from '@/budget/types';
export const dynamic = 'force-dynamic'; export const dynamic = 'force-dynamic';
function Section({ title, children }: { title: string; children: React.ReactNode }) { function Section({
title,
children,
tour,
}: {
title: string;
children: React.ReactNode;
tour?: string;
}) {
return ( return (
<section className="bg-white border border-gray-200 rounded-xl p-5 flex flex-col gap-3"> <section
data-tour={tour}
className="bg-white border border-gray-200 rounded-xl p-5 flex flex-col gap-3"
>
<h2 className="text-xs uppercase tracking-wide font-semibold text-gray-400">{title}</h2> <h2 className="text-xs uppercase tracking-wide font-semibold text-gray-400">{title}</h2>
{children} {children}
</section> </section>
@@ -41,6 +53,14 @@ export default async function LeadDetailPage({ params }: { params: Promise<{ id:
const prefs = lead.preferencesSnapshot as import('@/lib/voice/preferences').AbstractedPreferences | null; const prefs = lead.preferencesSnapshot as import('@/lib/voice/preferences').AbstractedPreferences | null;
const yaEnviado = lead.pipelineStage === 'whatsapp_entregado'; const yaEnviado = lead.pipelineStage === 'whatsapp_entregado';
// Baremo de rentabilidad del reformista (informativo): si el presupuesto estimado no lo alcanza,
// se marca en rojo. null = sin baremo o sin presupuesto aún (no se marca nada).
const baremoMinimo = (await getPricingConfigFor(lead.tenantId)).baremoMinimo ?? null;
const pasaBaremo =
baremoMinimo != null && lead.presupuestoEstimado != null
? lead.presupuestoEstimado >= baremoMinimo
: null;
const h = await headers(); const h = await headers();
const host = h.get('x-forwarded-host') ?? h.get('host') ?? 'reformix.dv3.com.es'; const host = h.get('x-forwarded-host') ?? h.get('host') ?? 'reformix.dv3.com.es';
const proto = h.get('x-forwarded-proto') ?? 'https'; const proto = h.get('x-forwarded-proto') ?? 'https';
@@ -62,16 +82,25 @@ export default async function LeadDetailPage({ params }: { params: Promise<{ id:
{lead.provincia ?? '—'} · entró {formatFecha(lead.createdAt)} {lead.provincia ?? '—'} · entró {formatFecha(lead.createdAt)}
</p> </p>
</div> </div>
<div className="text-right"> <div className="text-right" data-tour="ficha-presupuesto">
<div className="text-xs text-gray-400">Presupuesto estimado</div> <div className="text-xs text-gray-400">Presupuesto estimado</div>
<div className="text-2xl font-black text-black">{formatEuros(lead.presupuestoEstimado)}</div> <div className={`text-2xl font-black ${pasaBaremo === false ? 'text-red-600' : 'text-black'}`}>
{formatEuros(lead.presupuestoEstimado)}
</div>
{pasaBaremo === false && baremoMinimo != null && (
<div className="mt-0.5 text-xs font-semibold text-red-600">
Por debajo de tu baremo ({formatEuros(baremoMinimo)})
</div>
)}
</div> </div>
</div> </div>
<EstadoControl <div data-tour="ficha-estado">
leadId={lead.id} <EstadoControl
estado={lead.estado} leadId={lead.id}
presupuestoEstimado={lead.presupuestoEstimado} estado={lead.estado}
/> presupuestoEstimado={lead.presupuestoEstimado}
/>
</div>
</div> </div>
{/* Solicitar opinión al cliente */} {/* Solicitar opinión al cliente */}
@@ -164,7 +193,7 @@ export default async function LeadDetailPage({ params }: { params: Promise<{ id:
</Section> </Section>
{/* 4. Render */} {/* 4. Render */}
<Section title="Render generado"> <Section title="Render generado" tour="ficha-render">
{lead.renderUrl ? ( {lead.renderUrl ? (
// eslint-disable-next-line @next/next/no-img-element // eslint-disable-next-line @next/next/no-img-element
<img src={lead.renderUrl} alt="Render de la reforma" className="w-full rounded-lg object-cover" /> <img src={lead.renderUrl} alt="Render de la reforma" className="w-full rounded-lg object-cover" />
@@ -311,7 +340,7 @@ export default async function LeadDetailPage({ params }: { params: Promise<{ id:
)} )}
{/* Presupuesto desglosado */} {/* Presupuesto desglosado */}
<Section title="Presupuesto desglosado"> <Section title="Presupuesto desglosado" tour="ficha-desglose">
<div className="flex flex-wrap items-center gap-3"> <div className="flex flex-wrap items-center gap-3">
<form action={recalcularPresupuesto.bind(null, lead.id)}> <form action={recalcularPresupuesto.bind(null, lead.id)}>
<button <button

View File

@@ -5,6 +5,7 @@ import { db } from '@/db';
import { tenants } from '@/db/schema'; import { tenants } from '@/db/schema';
import { eq } from 'drizzle-orm'; import { eq } from 'drizzle-orm';
import AppNav from '@/components/AppNav'; import AppNav from '@/components/AppNav';
import PanelTour from '@/components/panel/PanelTour';
const PANEL_LINKS = [ const PANEL_LINKS = [
{ href: '/panel', label: 'Leads', icon: 'leads' }, { href: '/panel', label: 'Leads', icon: 'leads' },
@@ -44,6 +45,7 @@ export default async function PanelLayout({ children }: { children: React.ReactN
</div> </div>
</header> </header>
<main className="max-w-6xl mx-auto px-6 py-8 pb-24 sm:pb-8">{children}</main> <main className="max-w-6xl mx-auto px-6 py-8 pb-24 sm:pb-8">{children}</main>
<PanelTour />
</div> </div>
); );
} }

View File

@@ -69,7 +69,7 @@ export default async function PanelPage({
</div> </div>
{/* Filtros por estado */} {/* Filtros por estado */}
<div className="flex flex-wrap gap-2"> <div className="flex flex-wrap gap-2" data-tour="leads-filtros">
{FILTROS.map((f) => { {FILTROS.map((f) => {
const active = f.value === filtro; const active = f.value === filtro;
const count = f.value === 'todos' ? resumen.total : resumen.porEstado[f.value] ?? 0; const count = f.value === 'todos' ? resumen.total : resumen.porEstado[f.value] ?? 0;
@@ -89,7 +89,9 @@ export default async function PanelPage({
})} })}
</div> </div>
<LeadsView leads={leadsView} /> <div data-tour="leads-tabla">
<LeadsView leads={leadsView} />
</div>
</div> </div>
); );
} }

View File

@@ -93,6 +93,19 @@ export async function actualizarExtras(formData: FormData) {
revalidatePath('/panel/precios'); revalidatePath('/panel/precios');
} }
export async function actualizarBaremo(formData: FormData) {
const tenantId = await getTenantId();
const raw = formData.get('baremoMinimo');
const txt = typeof raw === 'string' ? raw.trim() : '';
// Vacío = sin baremo (null). Con valor = euros → céntimos.
const baremoMinimo = txt === '' ? null : eurosToCents(raw, 'baremo de rentabilidad');
await db
.update(pricingConfig)
.set({ baremoMinimo, updatedAt: new Date() })
.where(eq(pricingConfig.tenantId, tenantId));
revalidatePath('/panel/precios');
}
export async function actualizarEnvio(formData: FormData) { export async function actualizarEnvio(formData: FormData) {
const tenantId = await getTenantId(); const tenantId = await getTenantId();
const modo = formData.get('modo'); const modo = formData.get('modo');

View File

@@ -5,6 +5,7 @@ import {
borrarMaterial, borrarMaterial,
actualizarConfig, actualizarConfig,
actualizarExtras, actualizarExtras,
actualizarBaremo,
actualizarEnvio, actualizarEnvio,
importarCatalogoCsv, importarCatalogoCsv,
} from './actions'; } from './actions';
@@ -81,7 +82,7 @@ export default async function PreciosPage() {
</section> </section>
{/* Config general */} {/* Config general */}
<section className="bg-white rounded-xl border border-gray-200 p-6"> <section className="bg-white rounded-xl border border-gray-200 p-6" data-tour="precios-config">
<h2 className="font-bold text-black mb-4">Configuración general</h2> <h2 className="font-bold text-black mb-4">Configuración general</h2>
<form action={actualizarConfig} className="grid grid-cols-2 md:grid-cols-5 gap-3 items-end"> <form action={actualizarConfig} className="grid grid-cols-2 md:grid-cols-5 gap-3 items-end">
<label className="text-sm"> <label className="text-sm">
@@ -120,6 +121,34 @@ export default async function PreciosPage() {
</form> </form>
</section> </section>
{/* Baremo de rentabilidad */}
<section className="bg-white rounded-xl border border-gray-200 p-6" data-tour="precios-baremo">
<h2 className="font-bold text-black mb-1">Baremo de rentabilidad</h2>
<p className="text-sm text-gray-500 mb-4">
Importe mínimo de un trabajo para que te resulte rentable. Es solo orientativo para ti: en la
ficha de cada lead verás marcados en otro color los presupuestos que no lleguen a este valor.
No afecta a lo que ve el cliente ni a la conversación de los agentes. Déjalo vacío para no usar
baremo.
</p>
<form action={actualizarBaremo} className="flex flex-wrap items-end gap-3">
<label className="text-sm">
<span className="block text-xs text-gray-500 mb-1">Baremo mínimo ()</span>
<input
name="baremoMinimo"
type="number"
step="1"
min="0"
defaultValue={config.baremoMinimo != null ? config.baremoMinimo / 100 : ''}
placeholder="Sin baremo"
className="w-40 border border-gray-300 rounded-lg px-2 py-1.5"
/>
</label>
<button className="bg-primary-700 text-white rounded-lg px-4 py-2 text-sm font-medium">
Guardar baremo
</button>
</form>
</section>
{/* Extras fijos */} {/* Extras fijos */}
<section className="bg-white rounded-xl border border-gray-200 p-6"> <section className="bg-white rounded-xl border border-gray-200 p-6">
<h2 className="font-bold text-black mb-1">Extras fijos</h2> <h2 className="font-bold text-black mb-1">Extras fijos</h2>
@@ -256,7 +285,7 @@ export default async function PreciosPage() {
})} })}
{/* Import CSV */} {/* Import CSV */}
<section className="bg-white rounded-xl border border-gray-200 p-6"> <section className="bg-white rounded-xl border border-gray-200 p-6" data-tour="precios-catalogo">
<h2 className="font-bold text-black mb-2">Importar catálogo (CSV)</h2> <h2 className="font-bold text-black mb-2">Importar catálogo (CSV)</h2>
<p className="text-xs text-gray-500 mb-3"> <p className="text-xs text-gray-500 mb-3">
Cabecera: <code className="break-all">categoria,nombre,calidad,precio,unidad,descriptor_render,sku</code>. El Cabecera: <code className="break-all">categoria,nombre,calidad,precio,unidad,descriptor_render,sku</code>. El

View File

@@ -1,82 +1,295 @@
import Link from 'next/link'; import Link from 'next/link';
import { notFound } from 'next/navigation'; import { notFound } from 'next/navigation';
import { getPublicLead } from '@/lib/funnel/public-queries'; import { getPublicLead } from '@/lib/funnel/public-queries';
import { resolveTheme, themeStyle } from '@/lib/funnel/themes';
import TenantBrand from '@/components/funnel/TenantBrand'; import TenantBrand from '@/components/funnel/TenantBrand';
export const dynamic = 'force-dynamic'; export const dynamic = 'force-dynamic';
const BRAND = 'var(--brand, #0a0a0a)';
const BRAND_CONTRAST = 'var(--brand-contrast, #ffffff)';
function IconLlamada() {
return (
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path
d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);
}
function IconWhatsapp() {
return (
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path
d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);
}
function IconFormulario() {
return (
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path
d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M14 2v6h6M16 13H8M16 17H8M10 9H8"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);
}
const CANALES = [ const CANALES = [
{ {
slug: 'llamada', slug: 'llamada',
icon: '📞', icon: <IconLlamada />,
titulo: 'Que te llamemos', titulo: 'Que te llamemos',
descripcion: descripcion:
'Un asistente te llama y te hace unas preguntas rápidas. Lo más cómodo: no escribes nada.', 'Un asistente te llama y te hace unas preguntas rápidas. Lo más cómodo: no escribes nada.',
cta: 'Quiero que me llamen', cta: 'Quiero que me llamen',
badge: 'La más rápida',
}, },
{ {
slug: 'whatsapp', slug: 'whatsapp',
icon: '💬', icon: <IconWhatsapp />,
titulo: 'Por WhatsApp', titulo: 'Por WhatsApp',
descripcion: descripcion: 'Seguimos por chat a tu ritmo. Puedes mandar fotos y notas cuando quieras.',
'Seguimos por chat a tu ritmo. Puedes mandar fotos y notas cuando quieras.',
cta: 'Seguir por WhatsApp', cta: 'Seguir por WhatsApp',
badge: null,
}, },
{ {
slug: 'formulario', slug: 'formulario',
icon: '📝', icon: <IconFormulario />,
titulo: 'Rellenar un formulario', titulo: 'Rellenar un formulario',
descripcion: descripcion:
'Tú lo cuentas zona por zona y subes las fotos. Recibes el presupuesto al instante.', 'Tú lo cuentas zona por zona y subes las fotos. Recibes el presupuesto al instante.',
cta: 'Rellenar el formulario', cta: 'Rellenar el formulario',
badge: null,
}, },
] as const; ] as const;
const PASOS_DESPUES = [
{
titulo: 'Nos cuentas tu reforma a tu manera',
body: 'Fotos, medidas, gustos. Cuanto más nos cuentes, más se parecerá el resultado a lo que tienes en la cabeza.',
},
{
titulo: 'Render + presupuesto en minutos',
body: 'Ves tu espacio ya reformado en imágenes, con un presupuesto orientativo desglosado partida a partida.',
},
// El tercer paso interpola el nombre del reformista; se monta en el componente.
] as const;
function Stepper() {
const conectores = 'h-px flex-1 min-w-4';
return (
<ol className="flex items-center gap-2.5 sm:gap-3" aria-label="Progreso de tu solicitud">
<li className="flex items-center gap-2 shrink-0">
<span
className="w-6 h-6 rounded-full flex items-center justify-center shrink-0"
style={{ backgroundColor: BRAND, color: BRAND_CONTRAST }}
>
<svg width="12" height="12" viewBox="0 0 32 32" fill="none" aria-hidden="true">
<path
d="M6 16l7 7L26 9"
stroke="currentColor"
strokeWidth="4"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
</span>
<span className="hidden sm:inline text-xs font-semibold text-gray-600">Tus datos</span>
</li>
<li aria-hidden="true" className={conectores} style={{ backgroundColor: BRAND }} />
<li className="flex items-center gap-2 shrink-0" aria-current="step">
<span
className="w-6 h-6 rounded-full text-[11px] font-black flex items-center justify-center shrink-0"
style={{ backgroundColor: BRAND, color: BRAND_CONTRAST }}
>
2
</span>
<span className="text-xs font-bold text-black">Tu reforma</span>
</li>
<li aria-hidden="true" className={`${conectores} bg-gray-200`} />
<li className="flex items-center gap-2 shrink-0">
<span className="w-6 h-6 rounded-full bg-white border border-gray-300 text-[11px] font-bold text-gray-400 flex items-center justify-center shrink-0">
3
</span>
<span className="hidden sm:inline text-xs font-semibold text-gray-400">
Render + presupuesto
</span>
</li>
</ol>
);
}
export default async function ChooserPage({ params }: { params: Promise<{ id: string }> }) { export default async function ChooserPage({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params; const { id } = await params;
const data = await getPublicLead(id); const data = await getPublicLead(id);
if (!data) notFound(); if (!data) notFound();
const { lead, tenant } = data; const { lead, tenant } = data;
const theme = resolveTheme(tenant?.themePreset, tenant?.themeColor);
const nombrePila = lead.nombre.split(' ')[0];
const nombreReformista = tenant?.nombreEmpresa ?? 'el reformista';
const pasosDespues = [
...PASOS_DESPUES,
{
titulo: 'Visita gratuita para el presupuesto final',
body: `Si te convence, acuerdas una visita con ${nombreReformista}: ve la obra, la mide con detalle y te confirma el precio definitivo. Sin compromiso.`,
},
];
return ( return (
<> <div
className={theme.heading === 'serif' ? 'theme-serif' : undefined}
style={themeStyle(tenant?.themePreset, tenant?.themeColor)}
>
{tenant && <TenantBrand nombreEmpresa={tenant.nombreEmpresa} logoUrl={tenant.logoUrl} />} {tenant && <TenantBrand nombreEmpresa={tenant.nombreEmpresa} logoUrl={tenant.logoUrl} />}
<div className="container py-10 max-w-2xl flex flex-col gap-6">
<div className="flex flex-col gap-2">
<span className="text-xs font-semibold uppercase tracking-widest text-gray-400">
Elige cómo seguir
</span>
<h1 className="text-2xl font-black tracking-tight text-black">
¿Cómo prefieres contarnos tu reforma, {lead.nombre.split(' ')[0]}?
</h1>
<p className="text-sm text-gray-500 leading-relaxed">
eliges. Por cualquiera de las tres nos das lo que necesitamos para preparar tu render
y tu presupuesto.
</p>
</div>
<div className="flex flex-col gap-3"> <div className="relative overflow-hidden">
{CANALES.map((c) => ( {/* Halo sutil con el color de marca del reformista */}
<Link <div
key={c.slug} aria-hidden="true"
href={`/solicitud/${id}/${c.slug}`} className="absolute inset-x-0 top-0 h-80 pointer-events-none"
className="group bg-white border border-gray-200 rounded-xl p-5 shadow-sm flex items-center gap-4 transition-all hover:border-black hover:shadow-md" style={{
> background: `radial-gradient(60% 100% at 50% 0%, color-mix(in srgb, ${BRAND} 8%, transparent), transparent 70%)`,
<span className="text-3xl shrink-0" aria-hidden="true"> }}
{c.icon} />
</span>
<div className="flex flex-col gap-0.5 min-w-0"> <div className="container relative max-w-4xl py-10 md:py-14 flex flex-col gap-8 md:gap-10">
<span className="text-base font-bold text-black">{c.titulo}</span> <div className="motion-safe:animate-fade-up">
<span className="text-sm text-gray-500 leading-snug">{c.descripcion}</span> <Stepper />
<span className="text-sm font-semibold text-[color:var(--brand,#0a0a0a)] mt-1"> </div>
{c.cta}
<header
className="flex flex-col gap-3 max-w-2xl motion-safe:animate-fade-up"
style={{ animationDelay: '80ms' }}
>
<span className="text-xs font-semibold uppercase tracking-widest text-gray-400">
Elige cómo seguir
</span>
<h1 className="text-3xl md:text-4xl font-black tracking-tight text-black leading-[1.1] text-balance">
¿Cómo prefieres contarnos tu reforma, {nombrePila}?
</h1>
<p className="text-sm md:text-base text-gray-500 leading-relaxed">
eliges. Por cualquiera de las tres nos das lo que necesitamos para preparar tu
render y tu presupuesto.
</p>
</header>
<div className="grid gap-3 md:grid-cols-3 md:gap-4">
{CANALES.map((c, i) => (
<Link
key={c.slug}
href={`/solicitud/${id}/${c.slug}`}
className="group relative flex items-start gap-4 md:flex-col md:gap-5 bg-white border border-gray-200 rounded-2xl p-5 md:p-6 shadow-sm transition-all duration-250 hover:-translate-y-0.5 hover:border-[color:var(--brand,#0a0a0a)] hover:shadow-[0_16px_40px_-12px_rgba(0,0,0,0.18)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--brand,#0a0a0a)] focus-visible:ring-offset-2 motion-safe:animate-fade-up"
style={{ animationDelay: `${160 + i * 80}ms` }}
>
{c.badge && (
<span
className="absolute top-0 right-5 -translate-y-1/2 px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-widest"
style={{ backgroundColor: BRAND, color: BRAND_CONTRAST }}
>
{c.badge}
</span>
)}
<span
className="w-12 h-12 rounded-xl flex items-center justify-center shrink-0 transition-transform duration-250 group-hover:scale-105"
style={{ backgroundColor: BRAND, color: BRAND_CONTRAST }}
aria-hidden="true"
>
{c.icon}
</span> </span>
</div> <span className="flex flex-col gap-1.5 min-w-0 flex-1">
</Link> <h2 className="text-lg font-black tracking-tight text-black leading-snug">
))} {c.titulo}
</h2>
<span className="text-sm text-gray-500 leading-relaxed">{c.descripcion}</span>
<span
className="flex items-center gap-1.5 text-sm font-bold mt-2 md:mt-auto md:pt-4"
style={{ color: BRAND }}
>
{c.cta}
<svg
width="15"
height="15"
viewBox="0 0 16 16"
fill="none"
aria-hidden="true"
className="transition-transform duration-250 group-hover:translate-x-1"
>
<path
d="M2 8h12M10 4l4 4-4 4"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
</span>
</span>
</Link>
))}
</div>
<section
className="bg-white border border-gray-200 rounded-2xl p-6 md:p-8 shadow-sm motion-safe:animate-fade-up"
style={{ animationDelay: '420ms' }}
aria-labelledby="que-pasa-despues"
>
<h2
id="que-pasa-despues"
className="text-base md:text-lg font-black tracking-tight text-black"
>
Elijas lo que elijas, esto es lo que pasa después
</h2>
<ol className="relative mt-6 grid gap-6 md:grid-cols-3 md:gap-8">
{/* Línea que conecta los pasos en desktop */}
<div
aria-hidden="true"
className="hidden md:block absolute top-[15px] left-8 right-8 h-px bg-gray-200"
/>
{pasosDespues.map((paso, i) => (
<li key={paso.titulo} className="relative flex items-start gap-4 md:flex-col">
<span
className="relative w-8 h-8 rounded-full text-[13px] font-black flex items-center justify-center shrink-0 ring-4 ring-white"
style={{ backgroundColor: BRAND, color: BRAND_CONTRAST }}
aria-hidden="true"
>
{i + 1}
</span>
<div className="flex flex-col gap-1 min-w-0">
<h3 className="text-sm font-bold text-black leading-snug">{paso.titulo}</h3>
<p className="text-sm text-gray-500 leading-relaxed">{paso.body}</p>
</div>
</li>
))}
</ol>
</section>
</div> </div>
</div> </div>
</> </div>
); );
} }

View File

@@ -46,6 +46,7 @@ export interface PricingConfig {
factorZona: Record<string, number>; // provincia -> multiplicador factorZona: Record<string, number>; // provincia -> multiplicador
manoObra: Record<ManoObraKey, number>; // céntimos por m² de suelo manoObra: Record<ManoObraKey, number>; // céntimos por m² de suelo
extras?: ExtrasFijos; // importes fijos en céntimos extras?: ExtrasFijos; // importes fijos en céntimos
baremoMinimo?: number | null; // céntimos; trabajo mínimo rentable (informativo, no lo usan los agentes)
} }
export interface BudgetInputs { export interface BudgetInputs {

View File

@@ -116,6 +116,7 @@ export default function AppNav({ links }: { links: readonly AppNavLink[] }) {
<Link <Link
key={l.href} key={l.href}
href={l.href} href={l.href}
data-tour={`nav-${l.icon}`}
className={active === l.href ? 'text-primary-700 font-semibold' : 'text-gray-500 hover:text-primary-700'} className={active === l.href ? 'text-primary-700 font-semibold' : 'text-gray-500 hover:text-primary-700'}
> >
{l.label} {l.label}

View File

@@ -1,3 +1,6 @@
'use client';
import { useCallback, useEffect, useState } from 'react';
import type { PublicGaleriaFoto } from '@/lib/funnel/public-queries'; import type { PublicGaleriaFoto } from '@/lib/funnel/public-queries';
type GaleriaTrabajosProps = { type GaleriaTrabajosProps = {
@@ -5,11 +8,37 @@ type GaleriaTrabajosProps = {
nombreEmpresa: string; nombreEmpresa: string;
}; };
// Galería de trabajos del reformista en su landing pública. Solo se muestra si // Galería de trabajos del reformista en su landing pública. Solo se muestra si el reformista ha
// el reformista ha subido fotos desde su panel. // subido fotos desde su panel. Formato apaisado y, al pulsar una foto, se amplía en un lightbox
// con navegación entre todas las imágenes.
export default function GaleriaTrabajos({ fotos, nombreEmpresa }: GaleriaTrabajosProps) { export default function GaleriaTrabajos({ fotos, nombreEmpresa }: GaleriaTrabajosProps) {
const [idx, setIdx] = useState<number | null>(null);
const cerrar = useCallback(() => setIdx(null), []);
const mover = useCallback(
(d: number) => setIdx((cur) => (cur === null ? cur : (cur + d + fotos.length) % fotos.length)),
[fotos.length],
);
useEffect(() => {
if (idx === null) return;
const onKey = (e: KeyboardEvent) => {
if (e.key === 'Escape') cerrar();
else if (e.key === 'ArrowRight') mover(1);
else if (e.key === 'ArrowLeft') mover(-1);
};
document.addEventListener('keydown', onKey);
document.body.style.overflow = 'hidden';
return () => {
document.removeEventListener('keydown', onKey);
document.body.style.overflow = '';
};
}, [idx, cerrar, mover]);
if (fotos.length === 0) return null; if (fotos.length === 0) return null;
const actual = idx !== null ? fotos[idx] : null;
return ( return (
<section id="galeria" className="bg-gray-50 section" aria-label="Galería de trabajos"> <section id="galeria" className="bg-gray-50 section" aria-label="Galería de trabajos">
<div className="container"> <div className="container">
@@ -24,24 +53,31 @@ export default function GaleriaTrabajos({ fotos, nombreEmpresa }: GaleriaTrabajo
Reformas que ya hemos hecho Reformas que ya hemos hecho
</h2> </h2>
<p className="text-gray-500 mt-3 leading-relaxed"> <p className="text-gray-500 mt-3 leading-relaxed">
Una muestra real del trabajo de {nombreEmpresa}. Calidad de acabados, plazos cumplidos. Una muestra real del trabajo de {nombreEmpresa}. Toca cualquier imagen para verla en grande.
</p> </p>
</div> </div>
<div className="grid grid-cols-2 md:grid-cols-3 gap-3 md:gap-4"> <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 md:gap-4">
{fotos.map((f) => ( {fotos.map((f, i) => (
<figure <figure
key={f.id} key={f.id}
className="group relative aspect-[4/3] overflow-hidden rounded-xl bg-gray-100 border border-gray-200" className="group relative aspect-[3/2] overflow-hidden rounded-xl bg-gray-100 border border-gray-200"
> >
{/* eslint-disable-next-line @next/next/no-img-element */} <button
<img type="button"
src={f.url} onClick={() => setIdx(i)}
alt={f.titulo ?? `Reforma de ${nombreEmpresa}`} className="block h-full w-full cursor-zoom-in"
className="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" aria-label={`Ampliar ${f.titulo ?? `reforma de ${nombreEmpresa}`}`}
/> >
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={f.url}
alt={f.titulo ?? `Reforma de ${nombreEmpresa}`}
className="h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"
/>
</button>
{f.titulo && ( {f.titulo && (
<figcaption className="absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-3 text-white text-sm font-semibold opacity-0 group-hover:opacity-100 transition-opacity duration-300"> <figcaption className="pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-3 text-white text-sm font-semibold opacity-0 group-hover:opacity-100 transition-opacity duration-300">
{f.titulo} {f.titulo}
</figcaption> </figcaption>
)} )}
@@ -49,6 +85,67 @@ export default function GaleriaTrabajos({ fotos, nombreEmpresa }: GaleriaTrabajo
))} ))}
</div> </div>
</div> </div>
{actual && (
<div
className="fixed inset-0 z-[100] flex items-center justify-center bg-black/90 p-4 sm:p-8"
onClick={cerrar}
role="dialog"
aria-modal="true"
aria-label="Imagen ampliada"
>
<button
type="button"
onClick={cerrar}
aria-label="Cerrar"
className="absolute right-4 top-4 flex h-10 w-10 items-center justify-center rounded-full bg-white/15 text-2xl leading-none text-white hover:bg-white/30"
>
×
</button>
{fotos.length > 1 && (
<button
type="button"
onClick={(e) => {
e.stopPropagation();
mover(-1);
}}
aria-label="Anterior"
className="absolute left-3 top-1/2 flex h-11 w-11 -translate-y-1/2 items-center justify-center rounded-full bg-white/15 text-3xl leading-none text-white hover:bg-white/30 sm:left-6"
>
</button>
)}
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={actual.url}
alt={actual.titulo ?? `Reforma de ${nombreEmpresa}`}
onClick={(e) => e.stopPropagation()}
className="max-h-[86vh] max-w-[94vw] w-auto rounded-lg shadow-2xl"
/>
{fotos.length > 1 && (
<button
type="button"
onClick={(e) => {
e.stopPropagation();
mover(1);
}}
aria-label="Siguiente"
className="absolute right-3 top-1/2 flex h-11 w-11 -translate-y-1/2 items-center justify-center rounded-full bg-white/15 text-3xl leading-none text-white hover:bg-white/30 sm:right-6"
>
</button>
)}
{actual.titulo && (
<div className="pointer-events-none absolute inset-x-0 bottom-5 text-center text-sm font-medium text-white/85">
{actual.titulo}
</div>
)}
</div>
)}
</section> </section>
); );
} }

View File

@@ -0,0 +1,71 @@
'use client';
import { useEffect, useState } from 'react';
import { usePathname } from 'next/navigation';
import { driver, type DriveStep } from 'driver.js';
import 'driver.js/dist/driver.css';
import { tourForPath } from '@/lib/onboarding/panel-tour';
const SEEN_PREFIX = 'reformix_tour_v1_';
// Onboarding del panel con driver.js. Lanza el tour de la pestaña actual la primera vez que se
// visita (flag por pestaña en localStorage) y deja un botón flotante para repetirlo. Los pasos
// cuyo elemento no exista o esté oculto (p. ej. la nav de escritorio en móvil) se descartan.
export default function PanelTour() {
const pathname = usePathname();
const [hayTour, setHayTour] = useState(false);
useEffect(() => {
const tour = tourForPath(pathname);
setHayTour(Boolean(tour));
if (!tour) return;
if (localStorage.getItem(SEEN_PREFIX + tour.key) === '1') return;
// Espera a que el contenido de la página esté montado antes de resaltar.
const t = setTimeout(() => {
localStorage.setItem(SEEN_PREFIX + tour.key, '1');
lanzar(tour.steps);
}, 700);
return () => clearTimeout(t);
}, [pathname]);
function visibles(steps: DriveStep[]): DriveStep[] {
return steps.filter((s) => {
const sel = s.element;
if (!sel || typeof sel !== 'string') return true; // paso centrado (intro)
const el = document.querySelector(sel) as HTMLElement | null;
return !!el && el.offsetParent !== null;
});
}
function lanzar(steps: DriveStep[]) {
const pasos = visibles(steps);
if (pasos.length === 0) return;
driver({
showProgress: true,
overlayColor: '#0b1220',
nextBtnText: 'Siguiente',
prevBtnText: 'Atrás',
doneBtnText: 'Listo',
progressText: '{{current}} de {{total}}',
steps: pasos,
}).drive();
}
function repetir() {
const tour = tourForPath(pathname);
if (tour) lanzar(tour.steps);
}
if (!hayTour) return null;
return (
<button
type="button"
onClick={repetir}
className="fixed right-4 bottom-20 sm:bottom-4 z-40 inline-flex items-center gap-1.5 rounded-full bg-primary-700 px-4 py-2 text-sm font-semibold text-white shadow-lg hover:bg-primary-900"
aria-label="Ver el tour de esta sección"
>
<span aria-hidden="true"></span> Tour
</button>
);
}

View File

@@ -42,6 +42,7 @@ export async function getPricingConfigFor(tenantId: string): Promise<PricingConf
factorZona: {}, factorZona: {},
manoObra: { ...MANO_OBRA_DEFAULT }, manoObra: { ...MANO_OBRA_DEFAULT },
extras: { ...EXTRAS_DEFAULT }, extras: { ...EXTRAS_DEFAULT },
baremoMinimo: null,
}; };
} }
return { return {
@@ -49,6 +50,7 @@ export async function getPricingConfigFor(tenantId: string): Promise<PricingConf
factorZona: row.factorZona, factorZona: row.factorZona,
manoObra: { ...MANO_OBRA_DEFAULT, ...(row.manoObra as Record<ManoObraKey, number>) }, manoObra: { ...MANO_OBRA_DEFAULT, ...(row.manoObra as Record<ManoObraKey, number>) },
extras: { ...EXTRAS_DEFAULT, ...(row.extras ?? {}) }, extras: { ...EXTRAS_DEFAULT, ...(row.extras ?? {}) },
baremoMinimo: row.baremoMinimo ?? null,
}; };
} }

View File

@@ -396,6 +396,10 @@ export const pricingConfig = pgTable('pricing_config', {
.$type<{ tuberias: number; boletin: number; distribucion: number }>() .$type<{ tuberias: number; boletin: number; distribucion: number }>()
.notNull() .notNull()
.default({ tuberias: 0, boletin: 0, distribucion: 0 }), .default({ tuberias: 0, boletin: 0, distribucion: 0 }),
// Baremo de rentabilidad (céntimos): importe mínimo que el reformista considera rentable. Solo
// informativo en el panel (marca en otro color los leads por debajo); los agentes NO lo usan para
// decidir nada. Null = sin baremo configurado.
baremoMinimo: integer('baremo_minimo'),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(), updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
}); });

View File

@@ -291,13 +291,13 @@ const SEED_LEADS: SeedLead[] = [
const STAGE_ORDER = schema.pipelineStage.enumValues; const STAGE_ORDER = schema.pipelineStage.enumValues;
async function main() { async function main() {
const [existing] = await db // Guard de seguridad: solo sembramos si la base de datos está VACÍA (sin ningún tenant). Antes se
.select() // comprobaba un slug concreto ("reformas-ejemplo"); si ese tenant no estaba pero había otros
.from(schema.tenants) // (p. ej. una empresa creada por el reformista), el seed los TRUNCABA en cada deploy → pérdida de
.where(eq(schema.tenants.slug, 'reformas-ejemplo')) // datos. Ahora cualquier tenant existente protege toda la DB. SEED_FORCE=1 fuerza el reseed (BORRA TODO).
.limit(1); const [existing] = await db.select({ id: schema.tenants.id }).from(schema.tenants).limit(1);
if (existing && !process.env.SEED_FORCE) { if (existing && !process.env.SEED_FORCE) {
console.log('Ya hay datos (tenant "reformas-ejemplo"). Saltando seed. Usa SEED_FORCE=1 para forzar.'); console.log('La base de datos ya tiene datos (existe al menos un tenant). Saltando seed para no borrar nada. Usa SEED_FORCE=1 para forzar (¡BORRA TODO!).');
await client.end(); await client.end();
return; return;
} }

View File

@@ -0,0 +1,147 @@
import type { DriveStep } from 'driver.js';
// Pasos del onboarding del panel, por pestaña. El copy vive también en copy/COPY-GUIDE.md
// (sección "Onboarding del panel"). Los pasos cuyo elemento no exista o no esté visible se
// descartan en PanelTour (degrada con naturalidad en móvil o si una sección no aparece).
const PASOS_PANEL: DriveStep[] = [
{
popover: {
title: 'Tu panel de Reformix',
description:
'Te enseño en 30 segundos qué hay en cada sitio. Puedes saltártelo cuando quieras con la X.',
},
},
{
element: '[data-tour="nav-leads"]',
popover: {
title: 'Leads',
description:
'Aquí caen tus clientes con su presupuesto y su render ya preparados. Es tu día a día.',
side: 'bottom',
},
},
{
element: '[data-tour="nav-precios"]',
popover: {
title: 'Precios y baremo',
description:
'Tu tabla de precios, la mano de obra y el baremo de rentabilidad. De aquí salen los presupuestos.',
side: 'bottom',
},
},
{
element: '[data-tour="nav-galeria"]',
popover: { title: 'Galería', description: 'Tus fotos de trabajos para enseñar en la web.', side: 'bottom' },
},
{
element: '[data-tour="nav-opiniones"]',
popover: {
title: 'Opiniones',
description: 'Reseñas de tus clientes; las apruebas tú antes de publicarlas.',
side: 'bottom',
},
},
{
element: '[data-tour="nav-empresa"]',
popover: { title: 'Empresa', description: 'Tu marca, logo y datos de contacto.', side: 'bottom' },
},
{
element: '[data-tour="leads-filtros"]',
popover: {
title: 'Filtra por estado',
description: 'Nuevos, contactados, presupuestados… para centrarte en lo que toca ahora.',
side: 'bottom',
},
},
{
element: '[data-tour="leads-tabla"]',
popover: {
title: 'Tus leads',
description: 'Cada cliente con su estado y su presupuesto. Ábrelo para ver el detalle completo.',
side: 'top',
},
},
];
const PASOS_FICHA: DriveStep[] = [
{
element: '[data-tour="ficha-presupuesto"]',
popover: {
title: 'Presupuesto estimado',
description:
'Lo que costaría la reforma según tu catálogo. Si no llega a tu baremo, lo verás en rojo.',
side: 'bottom',
},
},
{
element: '[data-tour="ficha-estado"]',
popover: {
title: 'Estado del lead',
description: 'Avanza el lead por el funnel: contactado, presupuestado, ganado…',
side: 'bottom',
},
},
{
element: '[data-tour="ficha-render"]',
popover: {
title: 'Render de la reforma',
description:
'La imagen del “después” que ve tu cliente, generada a partir de su foto y sus gustos.',
side: 'top',
},
},
{
element: '[data-tour="ficha-desglose"]',
popover: {
title: 'Presupuesto desglosado',
description:
'Edita las partidas, recalcula desde el catálogo y envíaselo al cliente por WhatsApp.',
side: 'top',
},
},
];
const PASOS_PRECIOS: DriveStep[] = [
{
element: '[data-tour="precios-baremo"]',
popover: {
title: 'Baremo de rentabilidad',
description:
'El trabajo mínimo que te compensa. Solo te avisa a ti: marca en rojo los leads por debajo.',
side: 'bottom',
},
},
{
element: '[data-tour="precios-config"]',
popover: {
title: 'Mano de obra',
description: 'Tus precios de mano de obra por m². El motor los usa para calcular cada presupuesto.',
side: 'top',
},
},
{
element: '[data-tour="precios-catalogo"]',
popover: {
title: 'Tu catálogo',
description: 'Materiales y precios por calidad. Puedes importarlos en bloque por CSV.',
side: 'top',
},
},
];
export interface PanelTour {
key: string;
steps: DriveStep[];
}
// Devuelve el tour que corresponde a la ruta actual del panel, o null si esa ruta no tiene tour.
export function tourForPath(pathname: string): PanelTour | null {
if (pathname === '/panel') return { key: 'panel', steps: PASOS_PANEL };
if (pathname === '/panel/precios') return { key: 'precios', steps: PASOS_PRECIOS };
const m = pathname.match(/^\/panel\/([^/]+)\/?$/);
if (m && !['precios', 'galeria', 'opiniones', 'empresa'].includes(m[1])) {
return { key: 'ficha', steps: PASOS_FICHA };
}
return null;
}