import { Button, ButtonVariant, Form, FormGroup, Modal, ModalVariant, TextContent, ValidatedOptions, } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; import { useForm } from "react-hook-form"; import { emailRegexPattern } from "../util"; import { useAdminClient } from "../context/auth/AdminClient"; import { useWhoAmI } from "../context/whoami/WhoAmI"; import { KeycloakTextInput } from "../components/keycloak-text-input/KeycloakTextInput"; import type { EmailRegistrationCallback } from "./EmailTab"; type AddUserEmailModalProps = { callback: EmailRegistrationCallback; }; type AddUserEmailForm = { email: string; }; export const AddUserEmailModal = ({ callback }: AddUserEmailModalProps) => { const { t } = useTranslation("groups"); const { adminClient } = useAdminClient(); const { whoAmI } = useWhoAmI(); const { register, handleSubmit, watch, formState: { errors }, } = useForm({ defaultValues: { email: "" }, }); const watchEmailInput = watch("email", ""); const cancel = () => callback(false); const proceed = () => callback(true); const save = async (formData: AddUserEmailForm) => { await adminClient.users.update({ id: whoAmI.getUserId() }, formData); proceed(); }; return ( {t("common:testConnection")} , , ]} > {t("realm-settings:provideEmail")}
); };