import Link from "next/link";
import { auth } from "../../lib/auth";
import { leerCuenta, esGuid } from "../../lib/cuentasServer";
import { hoyManagua } from "../../lib/plan";
import { esAsistente } from "../../lib/authz";
import { resolveOwnerId } from "../../lib/queries";
import { money, registroUrl, DYN } from "../../lib/constants";
import LoginPrompt from "../../components/LoginPrompt";
import ErrorNotice from "../../components/ErrorNotice";
import NuevaActividadBoton from "../../components/actividades/NuevaActividadBoton";
import GestionarActividad from "../../components/actividades/GestionarActividad";
export const dynamic = "force-dynamic";
const fecha = (iso) => (iso ? `${iso.slice(8, 10)}/${iso.slice(5, 7)}/${iso.slice(0, 4)}` : "—");
// Fecha de Nicaragua (UTC-6) de un instante ISO.
const diaLocal = (iso) => (iso ? new Date(new Date(iso).getTime() - 6 * 3600 * 1000).toISOString().slice(0, 10) : null);
export default async function CuentaPage({ params }) {
const session = await auth();
if (!session?.email) return
Cuenta no válida. Volver a Cuentas
No encontré esa cuenta. Volver a Cuentas
No tienes acceso a esta cuenta: solo puedes ver las cuentas de las que eres propietario. Volver a Cuentas
← Cuentas
| {k} | {v || "—"} |
|---|
| Oportunidad | Tipo | Forecast | MRR est. | Cierre est. | Propietario |
|---|---|---|---|---|---|
| {o.nombre} | {o.tipo || "—"} | {o.forecast || "—"} | {money(o.valor)} | {fecha(o.cierre)} | {o.propietario || "—"} |
Sin oportunidades abiertas.
}| Nombre | Cargo | Correo | Teléfono |
|---|---|---|---|
| {k.nombre} | {k.cargo || "—"} | {k.correo || "—"} | {k.movil || "—"} |
Sin contactos activos registrados.
}De la cuenta y de sus oportunidades abiertas. Haz clic en una abierta para gestionarla.
{c.actividades.length ? (| Tipo | Asunto | Referente | Fecha | Estado | Propietario |
|---|---|---|---|---|---|
| {a.tipo === "Cita" ? "Visita" : a.tipo} |
{a.estado === "abierta" ? (
|
{a.referente || "—"} | {fecha(diaLocal(a.scheduledend || a.scheduledstart))} | {a.estado} | {a.owner || "—"} |
Sin actividades registradas.
}