ppt-tool/frontend/app/admin/components/AdminSidebar.tsx
Vadym Samoilenko d3d1667a79 Phase 2: Admin panel, analytics, storage, template pipeline, multi-provider LLM
- Fix admin sidebar: remove duplicate Teams, add Storage nav item
- Analytics: client-scoped queries, super_admin sees all (including NULL client_id)
- Storage management: list/download/delete presentations with file metadata
- Settings page with brand config router
- AI usage tracking: new AIUsageModel, ai_usage_service, analytics endpoint
- Master deck → template bridge: _register_as_template creates TemplateModel
  + PresentationLayoutCodeModel so parsed layouts appear in template picker
- Multi-provider LLM vision in parser: Anthropic/Google/OpenAI with asyncio.to_thread
- Fix PPTX upload 400: accept by .pptx extension (browser sends octet-stream)
- Fix reparse FK violation: presentation_id=None for parse_master_deck jobs
- Worker job_timeout increased to 1800s for LLM-heavy master deck parsing
- PYTHONUNBUFFERED=1 in docker-compose worker for real-time log output
- Auth: clientId in /me response, dev-login cookie improvements
- Frontend: auth slice clientId, master-deck thumbnails, storage page

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 23:39:34 +00:00

78 lines
2.8 KiB
TypeScript

'use client';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { useSelector } from 'react-redux';
import { RootState } from '@/store/store';
import { Separator } from '@/components/ui/separator';
import {
Users,
Building2,
HardDrive,
FileText,
BarChart3,
Settings,
ArrowLeft,
} from 'lucide-react';
interface NavItem {
label: string;
href: string;
icon: React.ReactNode;
roles: string[];
}
const NAV_ITEMS: NavItem[] = [
{ label: 'Users', href: '/admin/users', icon: <Users className="w-4 h-4" />, roles: ['super_admin'] },
{ label: 'Clients', href: '/admin/clients', icon: <Building2 className="w-4 h-4" />, roles: ['super_admin', 'client_admin'] },
{ label: 'Storage', href: '/admin/storage', icon: <HardDrive className="w-4 h-4" />, roles: ['super_admin', 'client_admin'] },
{ label: 'Audit Log', href: '/admin/audit', icon: <FileText className="w-4 h-4" />, roles: ['super_admin', 'client_admin'] },
{ label: 'Analytics', href: '/admin/analytics', icon: <BarChart3 className="w-4 h-4" />, roles: ['super_admin', 'client_admin'] },
{ label: 'Settings', href: '/admin/settings', icon: <Settings className="w-4 h-4" />, roles: ['super_admin'] },
];
export default function AdminSidebar() {
const pathname = usePathname();
const user = useSelector((state: RootState) => state.auth.user);
const role = user?.role || 'user';
const visibleItems = NAV_ITEMS.filter((item) => item.roles.includes(role));
return (
<aside className="w-60 min-h-screen bg-white border-r border-gray-200 flex flex-col">
<div className="p-4">
<Link href="/dashboard" className="flex items-center gap-2 text-sm text-gray-500 hover:text-gray-700 mb-4">
<ArrowLeft className="w-4 h-4" />
Back to Dashboard
</Link>
<h2 className="text-lg font-semibold text-gray-900 font-inter">Admin Panel</h2>
<p className="text-xs text-gray-500 mt-1">Manage your organization</p>
</div>
<Separator />
<nav className="flex-1 p-2">
{visibleItems.map((item) => {
const isActive = pathname === item.href || pathname.startsWith(item.href + '/');
return (
<Link
key={item.href + item.label}
href={item.href}
className={`flex items-center gap-3 px-3 py-2 rounded-md text-sm font-medium transition-colors ${
isActive
? 'bg-[#5146E5]/10 text-[#5146E5]'
: 'text-gray-700 hover:bg-gray-100'
}`}
>
{item.icon}
{item.label}
</Link>
);
})}
</nav>
<div className="p-4 border-t border-gray-200">
<div className="text-xs text-gray-400">
Signed in as <span className="font-medium text-gray-600">{user?.email}</span>
</div>
</div>
</aside>
);
}