Files
Horux360/apps/web/lib/hooks/use-tenants.ts
Consultoria AS 0c10c887d2 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>
2026-01-22 03:55:44 +00:00

21 lines
543 B
TypeScript

import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { getTenants, createTenant, type CreateTenantData } from '@/lib/api/tenants';
export function useTenants() {
return useQuery({
queryKey: ['tenants'],
queryFn: getTenants,
});
}
export function useCreateTenant() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (data: CreateTenantData) => createTenant(data),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['tenants'] });
},
});
}