import React, { useState, FormEvent, useContext } from "react"; import { Text, PageSection, TextContent, Divider, Wizard, AlertVariant, } from "@patternfly/react-core"; import { HttpClientContext } from "../../http-service/HttpClientContext"; import { Step1 } from "./Step1"; import { Step2 } from "./Step2"; import { ClientRepresentation } from "../../model/client-model"; import { AlertPanel } from "../../components/alert/AlertPanel"; import { useAlerts } from "../../components/alert/Alerts"; export const NewClientForm = () => { const httpClient = useContext(HttpClientContext)!; const [client, setClient] = useState({ protocol: "", clientId: "", name: "", description: "", publicClient: false, authorizationServicesEnabled: false, }); const [add, alerts, hide] = useAlerts(); const save = async () => { try { await httpClient.doPost("/admin/realms/master/clients", client); add("Client created", AlertVariant.success); } catch (error) { add(`Could not create client: '${error}'`, AlertVariant.danger); } }; const handleInputChange = ( value: string | boolean, event: FormEvent ) => { const target = event.target; const name = (target as HTMLInputElement).name; setClient({ ...client, [name]: value, }); }; const title = "Create client"; return ( <> {title} , }, { name: "Capability config", component: , nextButtonText: "Save", }, ]} onSave={save} /> ); };