import { useState, useEffect, useRef } from "react"; import { useAuth } from "@/hooks/use-auth"; import { useLocation } from "wouter"; import { Loader2, ArrowLeft, Building2, RefreshCw, LayoutDashboard, ShoppingCart, Package, DollarSign, FileText, Users, ClipboardList, Settings, Receipt, Truck, CreditCard, BarChart3, ShoppingBag, Utensils, ChevronLeft, ChevronRight, Shield, Database, Wrench, Bell, Tag, Video, FileCheck, Upload, Lock, Send, Store } from "lucide-react"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { ScrollArea } from "@/components/ui/scroll-area"; interface ModuleItem { id: string; name: string; icon: React.ReactNode; route: string; color?: string; adminOnly?: boolean; } const modules: ModuleItem[] = [ { id: "dashboard", name: "Dashboard", icon: , route: "/home", color: "text-blue-500" }, { id: "pdv", name: "PDV", icon: , route: "/frontbox", color: "text-green-500" }, { id: "vendas", name: "Vendas", icon: , route: "/vendas", color: "text-emerald-500" }, { id: "produtos", name: "Produtos", icon: , route: "/produtos", color: "text-amber-500" }, { id: "estoque", name: "Estoque", icon: , route: "/estoque", color: "text-orange-500" }, { id: "clientes", name: "Clientes", icon: , route: "/clientes", color: "text-purple-500" }, { id: "fornecedores", name: "Fornecedores", icon: , route: "/fornecedores", color: "text-indigo-500" }, { id: "contas-receber", name: "Contas a Receber", icon: , route: "/conta-receber", color: "text-green-600" }, { id: "contas-pagar", name: "Contas a Pagar", icon: , route: "/conta-pagar", color: "text-red-500" }, { id: "nfe", name: "NF-e", icon: , route: "/nfe", color: "text-cyan-500" }, { id: "nfce", name: "NFC-e", icon: , route: "/nfce", color: "text-teal-500" }, { id: "pedidos", name: "Pedidos", icon: , route: "/pedidos-delivery", color: "text-pink-500" }, { id: "cardapio", name: "Cardápio Digital", icon: , route: "/cardapio", color: "text-yellow-500" }, { id: "relatorios", name: "Relatórios", icon: , route: "/relatorios", color: "text-blue-400" }, ]; const adminModules: ModuleItem[] = [ { id: "ibpt", name: "IBPT", icon: , route: "/ibpt", color: "text-blue-600", adminOnly: true }, { id: "ticket", name: "Ticket", icon: , route: "/ticket-super", color: "text-green-600", adminOnly: true }, { id: "config", name: "Configuração", icon: , route: "/configuracao-super", color: "text-slate-500", adminOnly: true }, { id: "notificacoes", name: "Notificações", icon: , route: "/notificacao-super", color: "text-amber-500", adminOnly: true }, { id: "etiquetas", name: "Padrões de Etiqueta", icon: , route: "/padroes-etiqueta", color: "text-purple-500", adminOnly: true }, { id: "videos", name: "Vídeos de Suporte", icon: , route: "/video-suporte", color: "text-red-500", adminOnly: true }, { id: "relatorios-adm", name: "Relatórios", icon: , route: "/relatorios-adm", color: "text-indigo-500", adminOnly: true }, { id: "contrato-config", name: "Config. Contrato", icon: , route: "/contrato-config", color: "text-teal-500", adminOnly: true }, { id: "contratos", name: "Lista de Contratos", icon: , route: "/contrato-config-list", color: "text-cyan-500", adminOnly: true }, { id: "controle-acesso", name: "Controle de Acesso", icon: , route: "/controle-acesso", color: "text-rose-500", adminOnly: true }, { id: "empresas", name: "Empresas", icon: , route: "/empresas", color: "text-violet-500", adminOnly: true }, { id: "usuarios", name: "Usuários", icon: , route: "/usuarios", color: "text-pink-500", adminOnly: true }, { id: "emissoes", name: "Emissões", icon: , route: "/nfe", color: "text-orange-500", adminOnly: true }, { id: "marketplace", name: "Delivery/Marketplace", icon: , route: "/config-marketplace", color: "text-emerald-500", adminOnly: true }, ]; export default function Plus() { const { user } = useAuth(); const [, setLocation] = useLocation(); const [loading, setLoading] = useState(true); const [currentRoute, setCurrentRoute] = useState("/home"); const [sidebarCollapsed, setSidebarCollapsed] = useState(false); const [activeModule, setActiveModule] = useState("dashboard"); const iframeRef = useRef(null); const isAdmin = user?.role === 'admin' || (user as any)?.tenantType === 'master'; const visibleModules = isAdmin ? [...modules, ...adminModules] : modules; const iframeSrc = `/plus/auto-login?redirect=${encodeURIComponent(currentRoute)}&embedded=1`; const handleIframeLoad = () => { setLoading(false); }; const handleRefresh = () => { setLoading(true); if (iframeRef.current) { iframeRef.current.src = iframeRef.current.src; } }; const navigateToModule = (module: ModuleItem) => { setActiveModule(module.id); setCurrentRoute(module.route); setLoading(true); if (iframeRef.current) { iframeRef.current.src = `/plus/auto-login?redirect=${encodeURIComponent(module.route)}&embedded=1`; } }; return ( {/* Header - Tema Claro */} setLocation("/")} className="text-slate-600 hover:bg-slate-100 hover:text-slate-900" data-testid="button-back-suite" > Voltar ao Suite Arcádia Plus ERP Completo {/* Main Content */} {/* Sidebar - Tema Claro */} setSidebarCollapsed(!sidebarCollapsed)} className="text-slate-400 hover:text-slate-900 hover:bg-slate-100 h-7 w-7 p-0" > {sidebarCollapsed ? : } {modules.map((module) => ( navigateToModule(module)} className={cn( "w-full justify-start gap-3 text-left transition-colors", sidebarCollapsed ? "px-2" : "px-3", activeModule === module.id ? "bg-blue-50 text-blue-600 hover:bg-blue-100" : "text-slate-600 hover:text-slate-900 hover:bg-slate-100" )} data-testid={`button-module-${module.id}`} title={sidebarCollapsed ? module.name : undefined} > {module.icon} {!sidebarCollapsed && {module.name}} ))} {isAdmin && ( <> {!sidebarCollapsed && ( Retaguarda )} {adminModules.map((module) => ( navigateToModule(module)} className={cn( "w-full justify-start gap-3 text-left transition-colors", sidebarCollapsed ? "px-2" : "px-3", activeModule === module.id ? "bg-violet-50 text-violet-600 hover:bg-violet-100" : "text-slate-600 hover:text-slate-900 hover:bg-slate-100" )} data-testid={`button-module-${module.id}`} title={sidebarCollapsed ? module.name : undefined} > {module.icon} {!sidebarCollapsed && {module.name}} ))} > )} {/* Iframe Container */} {loading && ( Carregando {modules.find(m => m.id === activeModule)?.name || 'módulo'}... Arcádia Plus ERP )} ); }
Arcádia Plus ERP