import React, { Component } from "react"; import { Link } from "react-router-dom"; import { Space, Breadcrumb, Card, PageHeader } from "antd"; import { ApiKey, CreateApiKeyRequest, CreateApiKeyResponse } from "@chirpstack/chirpstack-api-grpc-web/api/internal_pb"; import { Tenant } from "@chirpstack/chirpstack-api-grpc-web/api/tenant_pb"; import ApiKeyForm from "./ApiKeyForm"; import ApiKeyToken from "./ApiKeyToken"; import InternalStore from "../../stores/InternalStore"; interface IState { createApiKeyResponse?: CreateApiKeyResponse; } interface IProps { tenant: Tenant; } class CreateTenantApiKey extends Component { constructor(props: IProps) { super(props); this.state = {}; } onFinish = (obj: ApiKey) => { obj.setTenantId(this.props.tenant.getId()); let req = new CreateApiKeyRequest(); req.setApiKey(obj); InternalStore.createApiKey(req, (resp: CreateApiKeyResponse) => { this.setState({ createApiKeyResponse: resp, }); }); }; render() { const apiKey = new ApiKey(); return ( ( Tenants {this.props.tenant.getName()} API Keys Add )} title="Add API key" /> {!this.state.createApiKeyResponse && } {this.state.createApiKeyResponse && } ); } } export default CreateTenantApiKey;