import React, { useState, useEffect } from "react"; import { useParams } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { PageSection } from "@patternfly/react-core"; import { ListEmptyState } from "../components/list-empty-state/ListEmptyState"; import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable"; import { boolFormatter, emptyFormatter } from "../util"; import { useAdminClient } from "../context/auth/AdminClient"; import UserRepresentation from "keycloak-admin/lib/defs/userRepresentation"; export const UsersInRoleTab = () => { const { t } = useTranslation("roles"); const [users, setUsers] = useState([]); const { id } = useParams<{ id: string }>(); const adminClient = useAdminClient(); const loader = async () => { const role = await adminClient.roles.findOneById({ id: id }); const usersWithRole = await adminClient.roles.findUsersWithRole({ name: role.name!, }); setUsers(usersWithRole); return usersWithRole; }; useEffect(() => { loader(); }, []); return ( <> {users.length == 0 ? ( ) : ( )} ); };