import React, { useState } from "react"; import { useHistory } from "react-router-dom"; import { PageSection, Wizard, AlertVariant, WizardFooter, WizardContextConsumer, Button, } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; import { useForm } from "react-hook-form"; import { GeneralSettings } from "./GeneralSettings"; import { CapabilityConfig } from "./CapabilityConfig"; import { useAlerts } from "../../components/alert/Alerts"; import { ViewHeader } from "../../components/view-header/ViewHeader"; import ClientRepresentation from "keycloak-admin/lib/defs/clientRepresentation"; import { useAdminClient } from "../../context/auth/AdminClient"; export const NewClientForm = () => { const { t } = useTranslation("clients"); const adminClient = useAdminClient(); const history = useHistory(); const [client, setClient] = useState({ protocol: "", clientId: "", name: "", description: "", publicClient: false, authorizationServicesEnabled: false, serviceAccountsEnabled: false, implicitFlowEnabled: false, directAccessGrantsEnabled: false, standardFlowEnabled: false, }); const { addAlert } = useAlerts(); const methods = useForm({ defaultValues: client }); const save = async () => { try { await adminClient.clients.create({ ...client }); addAlert(t("createSuccess"), AlertVariant.success); } catch (error) { addAlert(t("createError", { error }), AlertVariant.danger); } }; const Footer = () => ( {({ activeStep, onNext, onBack, onClose }) => { return ( <> ); }} ); const title = t("createClient"); return ( <> history.push("/clients")} navAriaLabel={`${title} steps`} mainAriaLabel={`${title} content`} steps={[ { name: t("generalSettings"), component: , }, { name: t("capabilityConfig"), component: , }, ]} footer={