import { InvitationsManager } from '@/components/admin/invitations/invitations-manager';
import { UserList } from '@/components/admin/users/user-list';
import { PageHeader } from '@/components/shared/page-header';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';

/**
 * "People with access" surface - covers BOTH currently-active CRM users
 * and pending invitations. Previously these lived on separate routes
 * (/admin/users + /admin/invitations); merged 2026-05-21 so admins land
 * on one page and tab between states. The standalone /admin/invitations
 * route now redirects here for back-compat with bookmarks.
 */
export default function UserManagementPage() {
  return (
    <div className="space-y-6">
      <PageHeader
        title="Users"
        description="Active CRM users and pending invitations. Switch tabs to manage invitations."
      />
      <Tabs defaultValue="active" className="space-y-4">
        <TabsList>
          <TabsTrigger value="active">Active users</TabsTrigger>
          <TabsTrigger value="invitations">Invitations</TabsTrigger>
        </TabsList>
        <TabsContent value="active">
          <UserList />
        </TabsContent>
        <TabsContent value="invitations">
          <InvitationsManager />
        </TabsContent>
      </Tabs>
    </div>
  );
}
