"""Navigation model and renderer for the ClientFlow admin UI."""
from __future__ import annotations
from dataclasses import dataclass
from app.admin_ui.components import esc
@dataclass(frozen=True)
class NavItem:
key: str
url: str
icon: str
label: str
area: str = "primary"
PRIMARY_NAV_ITEMS: tuple[NavItem, ...] = (
NavItem("overview", "/", "bi-speedometer2", "Dashboard"),
NavItem("operations", "/operations", "bi-check2-square", "Centro de trabalho"),
NavItem("reconciliation", "/reconciliation", "bi-diagram-3", "Reconciliação"),
NavItem("opportunities", "/opportunities", "bi-funnel", "Oportunidades"),
NavItem("forecast", "/forecast", "bi-graph-up-arrow", "Metas e previsão"),
NavItem("customers", "/customers", "bi-people", "Clientes"),
NavItem("products", "/products", "bi-box-seam", "Produtos"),
NavItem("orders", "/orders", "bi-truck", "Encomendas"),
NavItem("finance", "/finance", "bi-file-earmark-text", "Financeiro"),
NavItem("integrations", "/integrations", "bi-puzzle", "Integrações"),
)
ADMIN_NAV_ITEMS: tuple[NavItem, ...] = (
NavItem("tasks", "/tasks", "bi-list-check", "Tasks", "admin"),
NavItem("communications", "/communications", "bi-envelope", "Comunicações", "admin"),
NavItem("outbox", "/outbox", "bi-send", "Outbox", "admin"),
NavItem("events", "/events", "bi-activity", "Eventos", "admin"),
NavItem("runs", "/runs", "bi-cpu", "Runs", "admin"),
NavItem("queues", "/queues", "bi-diagram-3", "Filas", "admin"),
NavItem("system", "/system/health", "bi-heart-pulse", "System health", "admin"),
NavItem("settings", "/settings", "bi-gear", "Configuração", "admin"),
)
ADMIN_ACTIVE_KEYS = frozenset(item.key for item in ADMIN_NAV_ITEMS)
def _render_items(items: tuple[NavItem, ...], active: str) -> str:
links = ""
for item in items:
css = "cf-nav-link active" if item.key == active else "cf-nav-link"
links += f"""
{esc(item.label)}
"""
return links
def nav(active: str = "") -> str:
"""Render the operator-first navigation introduced in v4.7.
Primary navigation stays focused on daily work. Technical pages remain
available under Admin, without removing their public URLs.
"""
active = active or "overview"
admin_active = " active" if active in ADMIN_ACTIVE_KEYS else ""
admin_open = " open" if active in ADMIN_ACTIVE_KEYS else ""
primary_links = _render_items(PRIMARY_NAV_ITEMS, active)
admin_links = _render_items(ADMIN_NAV_ITEMS, active)
return f"""
"""