feat: indice estilo lanzador sam.norteamericano.cl, sidebar solo en IT + rewrite it.sam

This commit is contained in:
Nurfog committed 2026-09-08 17:10:44 -03:00
1 parent af638d4154
commit 347d8510b4
3 files changed
+74 -40

No files matched your search

+41 -38
View File
@@ -1,9 +1,7 @@
"use client";
import Link from "next/link";
import SamShell from "@/components/SamShell";
import TableroView from "@/components/TableroView";
import { useModules, refreshModules, useSiteSection } from "@/lib/store";
import { useModules, refreshModules } from "@/lib/store";
import {
displayName,
envOf,
@@ -14,35 +12,14 @@ import {
sectionOf,
SECTIONS,
type ModuleState,
type RefApp,
} from "@/lib/sam";
const sectionMenu = [
...SECTIONS.map((s) => ({ label: s.title, icon: s.icon, href: `/#${s.id}` })),
{ label: "Tablero IT", icon: "bx-pie-chart-alt-2", href: "/tablero" },
];
export default function Home() {
const { data, error } = useModules();
const site = useSiteSection();
const loading = data === null && error === null;
const fetchModules = refreshModules;
// it.sam.devops... aterriza directo en el tablero
if (site === "it") {
return (
<SamShell
brand="IT"
subtitle="Tablero de gestión"
menu={sectionMenu}
activeHref="/tablero"
topUser="SAM"
backHref="/"
>
<TableroView />
</SamShell>
);
}
const modules = data?.modules ?? [];
const backend = data?.backend;
@@ -107,13 +84,7 @@ export default function Home() {
);
};
const renderRefCard = (app: {
name: string;
title: string;
icon: string;
bg: string;
url: string;
}) => (
const renderRefCard = (app: RefApp) => (
<div className="col-md-6" key={`ref-${app.name}`}>
<div className="app-card p-2">
<table className="table table-borderless mb-0 align-middle">
@@ -150,12 +121,41 @@ export default function Home() {
);
return (
<SamShell
brand="SAM"
subtitle="Sistema de Administración de Matrículas"
menu={sectionMenu}
topUser="SAM"
<>
<div className="sidenav">
<div className="row text-light login-main-text">
<div className="col-12 text-center">
<div
className="mx-auto d-flex align-items-center justify-content-center bg-white rounded-3 overflow-hidden"
style={{ width: 80, height: 80 }}
>
<img src="/logo-sam.png" alt="SAM" style={{ width: 64, height: 64, objectFit: "contain" }} />
</div>
</div>
<div className="col-12 text-center mt-3">
<h1 className="fw-bold fs-2">Sistema SAM</h1>
</div>
<div className="col-12 text-center">
<h4 className="fw-semibold opacity-75">Aplicaciones</h4>
</div>
<div className="col-12 text-center mt-4 d-flex flex-column gap-2 align-items-center">
<Link href="/tablero" className="btn btn-light btn-sm px-4">
<i className="bx bx-pie-chart-alt-2 me-1" /> Tablero IT
</Link>
<Link href="/upload" className="btn btn-outline-light btn-sm px-4">
<i className="bx bx-plus me-1" /> Nuevo Módulo
</Link>
</div>
<div className="col-12 text-center mt-3">
<small className="opacity-50">Portal de integración</small>
</div>
</div>
</div>
<div className="main">
<div className="row" id="modulos">
<div className="col-lg-1" />
<div className="col-lg-10 mt-4">
{loading && (
<div className="text-center py-5">
<div className="spinner-border text-primary" role="status" />
@@ -293,6 +293,9 @@ export default function Home() {
</div>
</div>
)}
</SamShell>
</div>
</div>
</div>
</>
);
}
+16 -2
View File
@@ -2,17 +2,31 @@
import SamShell from "@/components/SamShell";
import TableroView from "@/components/TableroView";
import { useModules } from "@/lib/store";
import { displayName, getModuleMeta } from "@/lib/sam";
// App IT: sidebar con todas sus opciones (resumen, aplicaciones,
// tableros por módulo y gestión). Se sirve en /tablero y en
// it.sam.devops.norteamericano.cl
export default function Tablero() {
const { data } = useModules();
const modules = data?.modules ?? [];
const menu = [
{ label: "Resumen", icon: "bx-grid-alt", href: "#resumen" },
{ label: "Aplicaciones", icon: "bx-layer", href: "/" },
...modules.map((m) => ({
label: displayName(m.name),
icon: getModuleMeta(m.name).icon,
href: `/m/${m.name}`,
})),
{ label: "Nuevo Módulo", icon: "bx-plus", href: "/upload" },
];
export default function Tablero() {
return (
<SamShell
brand="IT"
subtitle="Tablero de gestión"
subtitle="Gestión de aplicaciones"
menu={menu}
activeHref="#resumen"
topUser="SAM"
+17
View File
@@ -0,0 +1,17 @@
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
// it.sam.devops... muestra el tablero IT manteniendo la URL.
export function middleware(req: NextRequest) {
const host = (req.headers.get("host") || "").toLowerCase();
if (host.startsWith("it.sam.") && req.nextUrl.pathname === "/") {
const url = req.nextUrl.clone();
url.pathname = "/tablero";
return NextResponse.rewrite(url);
}
return NextResponse.next();
}
export const config = {
matcher: ["/"],
};