import Link from "next/link";
import { auth } from "../lib/auth";
import { ownerFilter } from "../lib/authz";
import { getPipeline, getClosed } from "../lib/queries";
import LoginPrompt from "../components/LoginPrompt";
import ErrorNotice from "../components/ErrorNotice";
import { DYN, ACT_COLOR, money2 } from "../lib/constants";
export const dynamic = "force-dynamic";
function currentMonth() {
const d = new Date();
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}`;
}
const SETS = [
{ key: "pipe", label: "Tubería activa" },
{ key: "ganadas", label: "Ganadas" },
{ key: "perdidas", label: "Perdidas" },
];
export default async function DetallePage({ searchParams }) {
const session = await auth();
if (!session?.email) return
{rows.length} oportunidades{detSet !== "pipe" ? ` (${mes})` : ""} · clic en el nombre abre la oportunidad en Dynamics 365.
{sorted.length === 0 ? (No hay oportunidades para este filtro.
) : (| Cliente | Oportunidad | Seg. | {!scope.locked &&Ejecutivo | } {detSet === "pipe" ? ( <>Plan cierre | Fase actual | Actividad | MRR est. | Forecast | > ) : ( <>Tipo | MRR | Cierre | > )}
|---|---|---|---|---|---|---|---|---|---|---|---|
| {o.cliente || "—"} | {o.name} | {o.segmento === "Cartera Activa" ? "CA" : "CN"} | {!scope.locked &&{o.owner} | } {detSet === "pipe" ? ( <>{(o.plan || "").replace(" - ", " ")} | {o.faseActual || "—"} | ● {o.actividad} | {money2(o.est)} | {money2(o.fc)} | > ) : ( <>{o.tipo} | {money2(o.actual)} | {o.actualClose || "—"} | > )}