import { notFound } from 'next/navigation';
import { getPublicLead } from '@/lib/funnel/public-queries';
import CanalWhatsapp from '@/components/funnel/CanalWhatsapp';
import TenantBrand from '@/components/funnel/TenantBrand';

export const dynamic = 'force-dynamic';

export default async function WhatsappPage({ params }: { params: Promise<{ id: string }> }) {
  const { id } = await params;
  const data = await getPublicLead(id);
  if (!data) notFound();

  const { lead, tenant } = data;

  return (
    <>
      {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">
            Por WhatsApp
          </span>
          <h1 className="text-2xl font-black tracking-tight text-black">Seguimos por WhatsApp</h1>
        </div>

        <div className="bg-white border border-gray-200 rounded-xl p-6 md:p-8 shadow-sm">
          <CanalWhatsapp leadId={id} nombre={lead.nombre} telefono={lead.telefono} />
        </div>
      </div>
    </>
  );
}
