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:
@@ -14,6 +14,7 @@ import {
|
||||
Bell,
|
||||
Users,
|
||||
ChevronDown,
|
||||
Building2,
|
||||
} from 'lucide-react';
|
||||
import { useAuthStore } from '@/stores/auth-store';
|
||||
import { logout } from '@/lib/api/auth';
|
||||
@@ -31,12 +32,20 @@ const navigation = [
|
||||
{ name: 'Config', href: '/configuracion', icon: Settings },
|
||||
];
|
||||
|
||||
const adminNavigation = [
|
||||
{ name: 'Clientes', href: '/clientes', icon: Building2 },
|
||||
];
|
||||
|
||||
export function TopNav() {
|
||||
const pathname = usePathname();
|
||||
const router = useRouter();
|
||||
const { user, logout: clearAuth } = useAuthStore();
|
||||
const [userMenuOpen, setUserMenuOpen] = useState(false);
|
||||
|
||||
const allNavigation = user?.role === 'admin'
|
||||
? [...navigation.slice(0, -1), ...adminNavigation, navigation[navigation.length - 1]]
|
||||
: navigation;
|
||||
|
||||
const handleLogout = async () => {
|
||||
try {
|
||||
await logout();
|
||||
@@ -61,7 +70,7 @@ export function TopNav() {
|
||||
|
||||
{/* Navigation */}
|
||||
<nav className="flex-1 flex items-center gap-1">
|
||||
{navigation.map((item) => {
|
||||
{allNavigation.map((item) => {
|
||||
const isActive = pathname === item.href || pathname.startsWith(`${item.href}/`);
|
||||
return (
|
||||
<Link
|
||||
|
||||
Reference in New Issue
Block a user