import { AlertVariant, Button, ButtonVariant, Form, FormGroup, Modal, } from "@patternfly/react-core"; import { useForm } from "react-hook-form-v7"; import { useTranslation } from "react-i18next"; import { useAlerts } from "../../components/alert/Alerts"; import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput"; import { useAdminClient } from "../../context/auth/AdminClient"; type FormFields = { node: string; }; type AddHostDialogProps = { clientId: string; isOpen: boolean; onAdded: (host: string) => void; onClose: () => void; }; export const AddHostDialog = ({ clientId: id, isOpen, onAdded, onClose, }: AddHostDialogProps) => { const { t } = useTranslation("clients"); const { register, handleSubmit, formState: { isDirty, isValid }, } = useForm(); const { adminClient } = useAdminClient(); const { addAlert, addError } = useAlerts(); async function onSubmit({ node }: FormFields) { try { await adminClient.clients.addClusterNode({ id, node, }); onAdded(node); addAlert(t("addedNodeSuccess"), AlertVariant.success); } catch (error) { addError("clients:addedNodeFail", error); } onClose(); } return ( {t("common:save")} , , ]} >
); };