import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { Controller, UseFormMethods } from "react-hook-form"; import { FormGroup, Select, SelectOption, SelectVariant, TextInput, ValidatedOptions, } from "@patternfly/react-core"; import { HelpItem } from "../../components/help-enabler/HelpItem"; import _ from "lodash"; import type IdentityProviderMapperRepresentation from "@keycloak/keycloak-admin-client/lib/defs/identityProviderMapperRepresentation"; import type { IdentityProviderAddMapperParams } from "../routes/AddMapper"; import { useParams } from "react-router-dom"; import type { IdPMapperRepresentationWithAttributes } from "./AddMapper"; type AddMapperFormProps = { mapperTypes?: Record; mapperType: string; id: string; updateMapperType: (mapperType: string) => void; form: UseFormMethods; formValues: IdPMapperRepresentationWithAttributes; isSocialIdP: boolean; }; export const AddMapperForm = ({ mapperTypes, mapperType, form, id, updateMapperType, formValues, isSocialIdP, }: AddMapperFormProps) => { const { t } = useTranslation("identity-providers"); const { control, register, errors } = form; const [mapperTypeOpen, setMapperTypeOpen] = useState(false); const syncModes = ["inherit", "import", "legacy", "force"]; const [syncModeOpen, setSyncModeOpen] = useState(false); const { providerId } = useParams(); return ( <> } fieldId="kc-name" isRequired validated={ errors.name ? ValidatedOptions.error : ValidatedOptions.default } helperTextInvalid={t("common:required")} > } fieldId="syncMode" > ( )} /> } fieldId="identityProviderMapper" > ( )} /> ); };