import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation"; import type RoleRepresentation from "@keycloak/keycloak-admin-client/lib/defs/roleRepresentation"; import { AlertVariant, Tab, Tabs, TabTitleText } from "@patternfly/react-core"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import { adminClient } from "../admin-client"; import { useAlerts } from "../components/alert/Alerts"; import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner"; import { RoleMapping } from "../components/role-mapping/RoleMapping"; import { useRealm } from "../context/realm-context/RealmContext"; import { useFetch } from "../utils/useFetch"; import { DefaultsGroupsTab } from "./DefaultGroupsTab"; export const UserRegistration = () => { const { t } = useTranslation(); const [realm, setRealm] = useState(); const [activeTab, setActiveTab] = useState(10); const [key, setKey] = useState(0); const { addAlert, addError } = useAlerts(); const { realm: realmName } = useRealm(); useFetch( () => adminClient.realms.findOne({ realm: realmName }), setRealm, [], ); if (!realm) { return ; } const addComposites = async (composites: RoleRepresentation[]) => { const compositeArray = composites; try { await adminClient.roles.createComposite( { roleId: realm.defaultRole!.id!, realm: realmName }, compositeArray, ); setKey(key + 1); addAlert(t("addAssociatedRolesSuccess"), AlertVariant.success); } catch (error) { addError("addAssociatedRolesError", error); } }; return ( setActiveTab(key as number)} > {t("defaultRoles")}} > addComposites(rows.map((r) => r.role))} /> {t("defaultGroups")}} > ); };