import React, { useState, useContext } 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 { HttpClientContext } from "../../context/http-service/HttpClientContext"; import { GeneralSettings } from "./GeneralSettings"; import { CapabilityConfig } from "./CapabilityConfig"; import { ClientRepresentation } from "../models/client-model"; import { useAlerts } from "../../components/alert/Alerts"; import { RealmContext } from "../../context/realm-context/RealmContext"; import { ViewHeader } from "../../components/view-header/ViewHeader"; export const NewClientForm = () => { const { t } = useTranslation("clients"); const httpClient = useContext(HttpClientContext)!; const { realm } = useContext(RealmContext); 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 httpClient.doPost(`/admin/realms/${realm}/clients`, 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={