feat: add multi-tenant client management for admins

- Add tenants API endpoints (list, get, create)
- Add tenant middleware override via X-View-Tenant header
- Add TenantSelector dropdown component in header
- Add tenant view store with persistence
- Add Clientes management page
- Update all navigation layouts with Clientes link for admins

Admins can now:
- View list of all clients
- Create new clients with automatic schema setup
- Switch between viewing different clients' data
- See which client they are currently viewing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Consultoria AS
2026-01-22 03:55:44 +00:00
parent 6e3e69005b
commit 0c10c887d2
16 changed files with 768 additions and 6 deletions

View File

@@ -13,6 +13,7 @@ import {
Calendar,
Bell,
Users,
Building2,
} from 'lucide-react';
import { useAuthStore } from '@/stores/auth-store';
import { logout } from '@/lib/api/auth';
@@ -29,6 +30,10 @@ const navigation = [
{ name: 'Configuracion', href: '/configuracion', icon: Settings },
];
const adminNavigation = [
{ name: 'Clientes', href: '/clientes', icon: Building2 },
];
export function Sidebar() {
const pathname = usePathname();
const router = useRouter();
@@ -45,6 +50,10 @@ export function Sidebar() {
}
};
const allNavigation = user?.role === 'admin'
? [...navigation.slice(0, -1), ...adminNavigation, navigation[navigation.length - 1]]
: navigation;
return (
<aside className="fixed left-0 top-0 z-40 h-screen w-64 border-r bg-card">
<div className="flex h-full flex-col">
@@ -60,7 +69,7 @@ export function Sidebar() {
{/* Navigation */}
<nav className="flex-1 space-y-1 px-3 py-4">
{navigation.map((item) => {
{allNavigation.map((item) => {
const isActive = pathname === item.href || pathname.startsWith(`${item.href}/`);
return (
<Link