import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { Controller, useFormContext } from "react-hook-form"; import { FormGroup, Select, SelectOption, SelectVariant, } from "@patternfly/react-core"; import { useAdminClient, useFetch } from "../../context/auth/AdminClient"; import { HelpItem } from "../../components/help-enabler/HelpItem"; type Scope = { id: string; name: string; }; export const ScopePicker = ({ clientId }: { clientId: string }) => { const { t } = useTranslation("clients"); const { control } = useFormContext(); const [open, setOpen] = useState(false); const [scopes, setScopes] = useState(); const [search, setSearch] = useState(""); const adminClient = useAdminClient(); useFetch( () => { const params = { id: clientId, first: 0, max: 20, deep: false, name: search, }; return adminClient.clients.listAllScopes(params); }, (scopes) => setScopes( scopes.map((option) => ( {option.name} )) ), [search] ); return ( } fieldId="scopes" > ( )} /> ); };