"use client"; import Link from "next/link"; import { useModules, refreshModules } from "@/lib/store"; import { displayName, envOf, getModuleMeta, getStatusInfo, moduleUrl, sectionOf, SECTIONS, type ModuleState, } from "@/lib/sam"; export default function Home() { const { data, error } = useModules(); const loading = data === null && error === null; const fetchModules = refreshModules; const modules = data?.modules ?? []; const backend = data?.backend; const bySection: Record = {}; modules.forEach((m) => { const s = sectionOf(m.name, m.category); if (!bySection[s]) bySection[s] = []; bySection[s].push(m); }); const renderModuleCard = (m: ModuleState) => { const meta = getModuleMeta(m.name); const status = getStatusInfo(m); const env = envOf(m.branch); const url = moduleUrl(m); const name = displayName(m.name); return (
{name}
{status.label} · :{m.port} · {m.branch} {env.label}
); }; return ( <>
SAM

Sistema SAM

Aplicaciones

Tablero IT Nuevo Módulo
Portal de integración
{loading && (

Cargando módulos...

)} {error && (
Error: {error}
)} {!loading && !error && (
{modules.length === 0 && (

No hay módulos integrados. ¡Sube tu primer proyecto!

Subir Proyecto
)} {SECTIONS.map((section) => { const list = bySection[section.id] ?? []; const isReview = section.id === "otras-apps"; if (!isReview && list.length === 0) return null; return (
{" "} {section.title} {list.length > 0 && ( {list.length} módulo {list.length !== 1 ? "s" : ""} )}
{list.map(renderModuleCard)} {isReview && backend && ( <>
API Backend {backend.container ? "Activo" : "Detenido"} · {backend.branch}
Gestionar Módulos Subir / actualizar proyectos
)}
); })}
)}
); }