import React from "react"; import { useTranslation } from "react-i18next"; import { FormGroup, PageSection, Switch } from "@patternfly/react-core"; import { FormAccess } from "../components/form-access/FormAccess"; import { HelpItem } from "../components/help-enabler/HelpItem"; import { FormPanel } from "../components/scroll-form/FormPanel"; import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation"; import { Controller, useForm } from "react-hook-form"; type RealmSettingsLoginTabProps = { save: (realm: RealmRepresentation) => void; realm: RealmRepresentation; refresh: () => void; }; export const RealmSettingsLoginTab = ({ save, realm, refresh, }: RealmSettingsLoginTabProps) => { const { t } = useTranslation("realm-settings"); const form = useForm({ mode: "onChange" }); const updateSwitchValue = ( onChange: (newValue: boolean) => void, value: boolean, name: string ) => { save({ ...realm, [name as keyof typeof realm]: value }); onChange(value); refresh(); }; return ( } hasNoPaddingTop > ( { updateSwitchValue(onChange, value, "registrationAllowed"); }} /> )} /> } hasNoPaddingTop > ( { updateSwitchValue(onChange, value, "resetPasswordAllowed"); }} /> )} /> } hasNoPaddingTop > ( { updateSwitchValue(onChange, value, "rememberMe"); }} /> )} /> } hasNoPaddingTop > ( { updateSwitchValue( onChange, value, "registrationEmailAsUsername" ); }} /> )} /> } hasNoPaddingTop > ( { updateSwitchValue(onChange, value, "loginWithEmailAllowed"); }} /> )} /> } hasNoPaddingTop > ( { updateSwitchValue( onChange, value, "duplicateEmailsAllowed" ); }} isDisabled={ form.getValues().loginWithEmailAllowed || form.getValues().registrationEmailAsUsername } /> )} /> } hasNoPaddingTop > ( { updateSwitchValue(onChange, value, "verifyEmail"); }} /> )} /> ); };