/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ import React from "react"; import { useHistory } from "react-router-dom"; import { useForm } from "react-hook-form"; import BackendService from "../services/BackendService"; import TextField from "../components/TextField"; import Button from "../components/Button"; import Breadcrumbs from "../components/Breadcrumbs"; import { useSettings } from "../hooks"; import { useTranslation } from "react-i18next"; interface FormValues { name: string; topicAreaId: string; description: string; } function CreateTopicArea() { const history = useHistory(); const { register, errors, handleSubmit } = useForm(); const { settings } = useSettings(); const { t } = useTranslation(); const onSubmit = async (values: FormValues) => { const topicarea = await BackendService.createTopicArea(values.name); history.push("/admin/settings/topicarea", { alert: { type: "success", message: t("SettingsTopicAreaNameCreateSuccess", { name: `${topicarea.name}`, topicAreaName: `${settings.topicAreaLabels.singular.toLowerCase()}`, }), }, }); }; const onCancel = () => { history.push("/admin/settings/topicarea"); }; return ( <>

{t("CreateNewTopicArea")}


); } export default CreateTopicArea;