feat(frontend): app do tenant, dashboard ao vivo, fluxo de login multi-tenant
Corrige um gap real: o login sempre mandava pra /platform mesmo pra usuarios sem role de plataforma, sem nunca chamar /auth/tenants ou select-tenant. Agora POST /api/post-login decide o destino server-side (plataforma / tenant unico / seletor com >1 tenant) antes de redirecionar, trocando o access token quando necessario sem nunca expor token ao client. Adiciona GET /reports/dashboard (secao 162) e a tela /app correspondente — chamadas/agentes/TME/TMA/rates ao vivo, "consumo do plano" e "valor estimado" seguindo a mesma disciplina de honestidade (null > numero inventado) do dashboard de plataforma. Shell (sidebar/topbar/drawer mobile) extraido pra components/shell, compartilhado entre os menus Platform e Tenant (secao 168-169) via wrappers client-only por area — corrige de quebra um erro real de serializacao RSC (passar NavSection[] com icones como prop de Server Component pra Client Component quebra: "Functions cannot be passed directly to Client Components"). Testado ponta a ponta com um tenant semeado (Acme Call Center): login → /app direto, platform admin barrado de /app e vice-versa, dashboard com numeros reais (zeros honestos), drawer mobile, dark mode. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EWHKmcVJtstQFErbZ1AanY
This commit is contained in:
55
apps/frontend/src/components/shell/mobile-nav-drawer.tsx
Normal file
55
apps/frontend/src/components/shell/mobile-nav-drawer.tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import Image from "next/image";
|
||||
import * as Dialog from "@radix-ui/react-dialog";
|
||||
import { Menu, X } from "lucide-react";
|
||||
import { NavList } from "./nav-list";
|
||||
import type { NavSection } from "./nav-types";
|
||||
|
||||
/** Drawer de navegação pra telas abaixo de `lg` (secao 175: notebook/
|
||||
* tablet são prioridade, mas o próprio celular do agente precisa
|
||||
* funcionar) — a sidebar fixa de 256px não cabe num viewport de celular.
|
||||
* Radix Dialog dá foco preso + Escape + clique fora de graça (secao 176:
|
||||
* navegação completa por teclado). */
|
||||
export function MobileNavDrawer({ items }: { items: NavSection[] }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<Dialog.Root open={open} onOpenChange={setOpen}>
|
||||
<Dialog.Trigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
aria-label="Abrir menu de navegação"
|
||||
className="flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring lg:hidden"
|
||||
>
|
||||
<Menu className="h-5 w-5" aria-hidden />
|
||||
</button>
|
||||
</Dialog.Trigger>
|
||||
<Dialog.Portal>
|
||||
<Dialog.Overlay className="fixed inset-0 z-40 bg-[hsl(224_45%_11%)]/50 opacity-0 backdrop-blur-[1px] transition-opacity duration-200 data-[state=open]:opacity-100" />
|
||||
<Dialog.Content
|
||||
className="fixed inset-y-0 left-0 z-50 flex w-72 max-w-[85vw] -translate-x-full flex-col bg-surface shadow-pop outline-none transition-transform duration-200 ease-out data-[state=open]:translate-x-0"
|
||||
aria-describedby={undefined}
|
||||
>
|
||||
<Dialog.Title className="sr-only">Navegação</Dialog.Title>
|
||||
<div className="flex h-16 items-center justify-between border-b border-border px-4">
|
||||
<Image src="/branding/b2blogo.png" alt="B2BCall" width={110} height={27} />
|
||||
<Dialog.Close asChild>
|
||||
<button
|
||||
type="button"
|
||||
aria-label="Fechar menu"
|
||||
className="flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
||||
>
|
||||
<X className="h-4 w-4" aria-hidden />
|
||||
</button>
|
||||
</Dialog.Close>
|
||||
</div>
|
||||
<nav className="flex-1 overflow-y-auto px-2 py-3" aria-label="Navegação principal">
|
||||
<NavList items={items} onNavigate={() => setOpen(false)} />
|
||||
</nav>
|
||||
</Dialog.Content>
|
||||
</Dialog.Portal>
|
||||
</Dialog.Root>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user