From 86af77c92b873c050d5e867ab33b708aeb1563c0 Mon Sep 17 00:00:00 2001 From: tanweer919 Date: Mon, 13 Jul 2026 02:57:51 +0530 Subject: [PATCH] feat(dashboard): real user in sidebar + sign-out; strip demo/mock hints - Sidebar footer now shows the ACE identity (was static 'James Carter') with a Sign-out menu; topbar user gets a Sign-out dropdown too. Both call useAuth().logout. - Remove all visible 'Demo:' hints from login + register and the 'Demo mode' subtitle. --- src/app/dashboard/dashboard.css | 5 +++ src/components/dashboard/sidebar.tsx | 44 +++++++++++++++++++---- src/components/dashboard/topbar.tsx | 46 ++++++++++++++++++------- src/components/portal/login-flow.tsx | 8 ----- src/components/portal/register-flow.tsx | 1 - 5 files changed, 76 insertions(+), 28 deletions(-) diff --git a/src/app/dashboard/dashboard.css b/src/app/dashboard/dashboard.css index 4697180..f78702e 100644 --- a/src/app/dashboard/dashboard.css +++ b/src/app/dashboard/dashboard.css @@ -106,6 +106,11 @@ .sb-user .av { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; flex: 0 0 30px; } .sb-user .nm { font-size: 12.5px; font-weight: 600; } .sb-user .rl { font-size: 11px; color: var(--faint); } + .sb-user .nm, .sb-user .rl { max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .sb-user-menu { position: absolute; bottom: 56px; left: 12px; right: 12px; z-index: 30; padding: 6px; border-radius: 12px; border: 1px solid var(--border-2); background: var(--panel); box-shadow: var(--shadow), 0 8px 30px -12px rgba(0,0,0,0.55); animation: ds-rise 0.14s ease; } + .sb-user-menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px; background: none; color: var(--text-2); font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; text-align: left; } + .sb-user-menu button:hover { background: var(--panel-2); } + .sb-user-menu button.danger { color: var(--red, #ef4444); } /* ---- main ---- */ .dash-main { flex: 1; min-width: 0; display: flex; flex-direction: column; } diff --git a/src/components/dashboard/sidebar.tsx b/src/components/dashboard/sidebar.tsx index c4d40fd..2da6680 100644 --- a/src/components/dashboard/sidebar.tsx +++ b/src/components/dashboard/sidebar.tsx @@ -1,9 +1,16 @@ "use client"; -import { ChevronsUpDown } from "lucide-react"; +import { useState } from "react"; +import { useRouter } from "next/navigation"; +import { ChevronsUpDown, LogOut } from "lucide-react"; +import { useAuth } from "@abe-kap/appshell-sdk/react"; import { Icon } from "./ui"; import { user } from "./account-data"; +function initialsOf(name: string): string { + return name.split(/\s+/).filter(Boolean).slice(0, 2).map((p) => p[0]).join("").toUpperCase() || "?"; +} + export type NavItem = { key: string; label: string; icon: string; subtitle?: string }; export type NavGroup = { title: string; items: NavItem[] }; @@ -61,6 +68,21 @@ export const NAV_GROUPS: NavGroup[] = [ export const NAV_ITEMS: NavItem[] = NAV_GROUPS.flatMap((g) => g.items); export function Sidebar({ active, onSelect }: { active: string; onSelect: (k: string) => void }) { + const router = useRouter(); + const { user: me, logout } = useAuth(); + const [menuOpen, setMenuOpen] = useState(false); + // Real signed-in identity from the App Context Envelope; fall back to the static + // demo user only when the Shell isn't wired. + const name = me?.displayName || user.name; + const initials = me ? initialsOf(me.displayName) : user.initials; + const secondary = me?.email || user.role; + + async function signOut() { + setMenuOpen(false); + try { await logout(); } catch { /* ignore — proceed to portal either way */ } + router.replace("/portal/login"); + } + return (