import type ScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/scopeRepresentation"; import { FormGroup, Select, SelectOption, SelectVariant, } from "@patternfly/react-core"; import { useState } from "react"; import { Controller, useFormContext } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { HelpItem } from "ui-shared"; import { adminClient } from "../../admin-client"; import { useFetch } from "../../utils/useFetch"; type Scope = { id: string; name: string; }; export const ScopePicker = ({ clientId }: { clientId: string }) => { const { t } = useTranslation(); const { control } = useFormContext(); const [open, setOpen] = useState(false); const [scopes, setScopes] = useState(); const [search, setSearch] = useState(""); useFetch( () => { const params = { id: clientId, first: 0, max: 20, deep: false, name: search, }; return adminClient.clients.listAllScopes(params); }, setScopes, [search], ); const renderScopes = (scopes?: ScopeRepresentation[]) => scopes?.map((option) => ( {option.name} )); return ( } fieldId="scopes" > ( )} /> ); };