107 lines
4.5 KiB
JavaScript
107 lines
4.5 KiB
JavaScript
|
|
import { DYN, ACT_COLOR, money, money2 } from "../../lib/constants";
|
||
|
|
|
||
|
|
const PLAN_LETRA = {
|
||
|
|
"Plan A - En firma": "A", "Plan B - En Negociación": "B", "Plan C - En seguimiento": "C",
|
||
|
|
"Plan D - Recalificar": "D", "Sin plan de cierre": "—",
|
||
|
|
};
|
||
|
|
const nomCorto = (n) => {
|
||
|
|
const p = (n || "").split(" ");
|
||
|
|
return p.length > 2 ? `${p[0]} ${p[p.length - 2]}` : n || "";
|
||
|
|
};
|
||
|
|
function cierreVencido(o) {
|
||
|
|
return !!o.close && o.close < new Date().toISOString().slice(0, 10);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Tabla de tubería para el layout split23 (2/3 der.): columna Cliente/Oportunidad fija, scroll
|
||
|
|
// horizontal — mismo tratamiento que `tablePipe(arr,tipo,split=true,...)` del sitio HTML
|
||
|
|
// (assets/js/tables.js). Sin agrupado por actividad agendada todavía (necesita datos de
|
||
|
|
// Actividades, que esta app aún no consulta) y sin clic-para-agendar.
|
||
|
|
export default function TablaPipe({ arr, tipo }) {
|
||
|
|
const colFc = tipo === "fc";
|
||
|
|
const sorted = [...arr].sort((a, b) => b.est - a.est);
|
||
|
|
return (
|
||
|
|
<div className="tw split">
|
||
|
|
<div className="ts">
|
||
|
|
<table className="fix">
|
||
|
|
<colgroup>
|
||
|
|
<col style={{ width: "20%" }} />
|
||
|
|
<col style={{ width: "64px" }} />
|
||
|
|
<col style={{ width: "32px" }} />
|
||
|
|
<col style={{ width: "8.5%" }} />
|
||
|
|
<col style={{ width: "8.5%" }} />
|
||
|
|
<col style={{ width: "8.5%" }} />
|
||
|
|
<col style={{ width: "36px" }} />
|
||
|
|
<col style={{ width: "70px" }} />
|
||
|
|
<col style={{ width: "9%" }} />
|
||
|
|
<col style={{ width: "8.5%" }} />
|
||
|
|
{colFc && <col style={{ width: "7.5%" }} />}
|
||
|
|
<col style={{ width: "7%" }} />
|
||
|
|
</colgroup>
|
||
|
|
<thead>
|
||
|
|
<tr>
|
||
|
|
<th>Cliente / Oportunidad</th>
|
||
|
|
<th>Segmento</th>
|
||
|
|
<th title="Plan de cierre">Plan</th>
|
||
|
|
<th>Línea</th>
|
||
|
|
<th>Competidor</th>
|
||
|
|
<th>Fase</th>
|
||
|
|
<th className="num" title="Días en la fase actual">Días</th>
|
||
|
|
<th>Actividad</th>
|
||
|
|
<th>Ejecutivo</th>
|
||
|
|
<th className="num">MRR est.</th>
|
||
|
|
{colFc && <th className="num">Forecast</th>}
|
||
|
|
<th>Cierre</th>
|
||
|
|
</tr>
|
||
|
|
</thead>
|
||
|
|
<tbody>
|
||
|
|
{sorted.map((o) => (
|
||
|
|
<tr key={o.id}>
|
||
|
|
<td className="dual-cel">
|
||
|
|
{o.actFecha && (
|
||
|
|
<span title={`Actividad agendada para el ${o.actFecha}`}>📅 </span>
|
||
|
|
)}
|
||
|
|
<a className="opp" href={`${DYN}${o.id}`} target="_blank" rel="noopener" title={o.name}>
|
||
|
|
{o.name}
|
||
|
|
</a>
|
||
|
|
<span className="sub" title={o.cliente || ""}>{o.cliente || "—"}</span>
|
||
|
|
</td>
|
||
|
|
<td>
|
||
|
|
<span className={`pill ${o.segmento === "Cartera Activa" ? "cartera" : "nuevo"}`} title={o.segmento}>
|
||
|
|
{o.segmento === "Cartera Activa" ? "CA" : "CN"}
|
||
|
|
</span>
|
||
|
|
</td>
|
||
|
|
<td>
|
||
|
|
<span className={`plan-b p${PLAN_LETRA[o.plan] || "x"}`} title={o.plan || "Sin plan de cierre"}>
|
||
|
|
{PLAN_LETRA[o.plan] || "—"}
|
||
|
|
</span>
|
||
|
|
</td>
|
||
|
|
<td className="elip" title={o.linea || ""}>{o.linea || "—"}</td>
|
||
|
|
<td className="elip" title={o.competidor || ""}>
|
||
|
|
{o.competidor === "Sin registrar" ? "—" : o.competidor || "—"}
|
||
|
|
</td>
|
||
|
|
<td className="elip" title={o.faseActual || ""}>{o.faseActual || "—"}</td>
|
||
|
|
<td className="num">{o.diasEnFase == null ? "—" : o.diasEnFase}</td>
|
||
|
|
<td style={{ textAlign: "center" }}>
|
||
|
|
<span
|
||
|
|
style={{ color: ACT_COLOR[o.actividad] || "#9db4c9", fontWeight: 700 }}
|
||
|
|
title={`${o.actividad}${o.estanc ? " · estancada" : ""}`}
|
||
|
|
>
|
||
|
|
●
|
||
|
|
</span>
|
||
|
|
</td>
|
||
|
|
<td className="elip" title={o.owner}>{nomCorto(o.owner)}</td>
|
||
|
|
<td className="num">{money(o.est)}</td>
|
||
|
|
{colFc && <td className="num">{money(o.fc)}</td>}
|
||
|
|
<td className={`num${cierreVencido(o) ? " venc" : ""}`} title={cierreVencido(o) ? "Fecha de cierre vencida al corte" : ""}>
|
||
|
|
{o.close ? o.close.slice(5) : "—"}
|
||
|
|
{cierreVencido(o) ? " ⚠" : ""}
|
||
|
|
</td>
|
||
|
|
</tr>
|
||
|
|
))}
|
||
|
|
</tbody>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|