import { useEffect, useState } from "react";
import { useLocation } from "wouter";
import { Building2, ChevronLeft, ChevronRight, Plus, Search } from "lucide-react";
import { can, type RoleDef } from "@/lib/admin/adminAccess";
import { describeDirectoryError, listRoles } from "@/lib/admin/adminDirectory";
import { drawableLogo, getTenants, queryTenants, type DirectoryTenant } from "@/lib/admin/adminTenants";
import { formatSize } from "@/lib/format";
import { proxiedImageUrl } from "@/lib/text/html";
import { plural, t } from "@/lib/i18n";
import { Empty, Spinner } from "@/ui/misc";
import { usePermissions } from "./usePermissions";
import { TenantSheet } from "./TenantSheet";
const PAGE_SIZE = 50;
/**
* Tenants: separate organizations on one server, each with its own people,
* domains and limits.
*
* The section is offered to whoever may read tenants. The INBUXA mail server
* has one edition with tenants in it, so there is no edition check and no
* notice here, unlike public ihasmail.
*/
export function TenantsAdmin({ selectedId }: { selectedId?: string }) {
return ;
}
function EnterpriseTenants({ selectedId }: { selectedId?: string }) {
const [, navigate] = useLocation();
const perms = usePermissions();
const [text, setText] = useState("");
const [query, setQuery] = useState("");
const [position, setPosition] = useState(0);
const [page, setPage] = useState<{ tenants: DirectoryTenant[]; total: number } | null>(null);
const [error, setError] = useState(null);
const [reload, setReload] = useState(0);
const [roles, setRoles] = useState