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 type { ClientQuery } from "@keycloak/keycloak-admin-client/lib/resources/clients"; import { useAdminClient, useFetch } from "../../../context/auth/AdminClient"; import { HelpItem } from "../../../components/help-enabler/HelpItem"; import type { ComponentProps } from "./components"; import { convertToHyphens } from "../../../util"; export const ClientSelectComponent = ({ name, label, helpText, defaultValue, }: ComponentProps) => { const { t } = useTranslation("client-scopes"); const { control } = useFormContext(); const [open, setOpen] = useState(false); const [clients, setClients] = useState(); const [search, setSearch] = useState(""); const adminClient = useAdminClient(); useFetch( () => { const params: ClientQuery = { max: 20, }; if (search) { params.clientId = search; params.search = true; } return adminClient.clients.find(params); }, (clients) => setClients( clients.map((option) => ( )) ), [search] ); return ( } fieldId={name!} > ( )} /> ); };