Conectar funnel B2C real sin claves: captura → fotos → presupuesto

El formulario de la landing ahora crea un lead real en BD y redirige a
/solicitud/[id]/fotos, donde el cliente sube fotos y datos de la reforma.
El orquestador simula los pasos de IA (pre-llamada, llamada, render) y
calcula el presupuesto DE VERDAD con el catálogo del reformista, dejando
el lead listo en el panel con render y desglose.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Carlos Narro
2026-05-31 14:29:21 +02:00
parent b95c588efe
commit b582f3ac33
10 changed files with 733 additions and 19 deletions

View File

@@ -6,8 +6,7 @@ import { getCurrentTenantId as getTenantId } from '@/lib/auth/current-user';
export type EnvioMode = (typeof tenants.envioPresupuesto.enumValues)[number];
export async function getEnvioMode(): Promise<EnvioMode> {
const tenantId = await getTenantId();
export async function getEnvioModeFor(tenantId: string): Promise<EnvioMode> {
const [row] = await db
.select({ modo: tenants.envioPresupuesto })
.from(tenants)
@@ -16,6 +15,10 @@ export async function getEnvioMode(): Promise<EnvioMode> {
return row?.modo ?? 'automatico';
}
export async function getEnvioMode(): Promise<EnvioMode> {
return getEnvioModeFor(await getTenantId());
}
const MANO_OBRA_DEFAULT: Record<ManoObraKey, number> = {
demolicion: 0,
fontaneria: 0,
@@ -23,8 +26,7 @@ const MANO_OBRA_DEFAULT: Record<ManoObraKey, number> = {
mano_de_obra: 0,
};
export async function getPricingConfig(): Promise<PricingConfig> {
const tenantId = await getTenantId();
export async function getPricingConfigFor(tenantId: string): Promise<PricingConfig> {
const [row] = await db
.select()
.from(pricingConfig)
@@ -41,8 +43,11 @@ export async function getPricingConfig(): Promise<PricingConfig> {
};
}
export async function getCatalog(): Promise<CatalogItem[]> {
const tenantId = await getTenantId();
export async function getPricingConfig(): Promise<PricingConfig> {
return getPricingConfigFor(await getTenantId());
}
export async function getCatalogFor(tenantId: string): Promise<CatalogItem[]> {
const rows = await db.select().from(catalogItems).where(eq(catalogItems.tenantId, tenantId));
return rows.map((r) => ({
id: r.id,
@@ -57,4 +62,8 @@ export async function getCatalog(): Promise<CatalogItem[]> {
}));
}
export async function getCatalog(): Promise<CatalogItem[]> {
return getCatalogFor(await getTenantId());
}
export { getTenantId };