From 94186633a544b9ffa019e5b6a7fc13d387a87e1d Mon Sep 17 00:00:00 2001 From: Aaron Cooper Date: Wed, 31 Jan 2024 08:00:32 +0000 Subject: [PATCH] . --- Source/Topica.UI/package.json | 3 +- .../Topica.UI/src/Components/CreateTopic.tsx | 34 ++++++++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Source/Topica.UI/package.json b/Source/Topica.UI/package.json index 6e0a893..4172da9 100644 --- a/Source/Topica.UI/package.json +++ b/Source/Topica.UI/package.json @@ -5,7 +5,8 @@ "type": "module", "scripts": { "dev": "vite", - "build": "tsc && vite build", + "build": "vite build", + "build:withlintcheck": "tsc && vite build", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "preview": "vite preview", "clean": "npx rimraf node_modules" diff --git a/Source/Topica.UI/src/Components/CreateTopic.tsx b/Source/Topica.UI/src/Components/CreateTopic.tsx index 3e2c0e1..85de0b0 100644 --- a/Source/Topica.UI/src/Components/CreateTopic.tsx +++ b/Source/Topica.UI/src/Components/CreateTopic.tsx @@ -1,23 +1,35 @@ -import { TopicMeta } from "@topica/client"; import { Button, Form, Input, Modal } from "antd"; import React, { useState } from "react"; import { topicsApi } from "../api/api"; import { useRequest } from "ahooks"; -export const CreateTopic: React.FunctionComponent = (props) => { +export const CreateTopic: React.FunctionComponent = () => { const [open, setOpen] = useState(false); const [form] = Form.useForm(); - const [addButtonText, setAddButtonText] = useState<"Add"|"Add Another">("Add") - const {data, error, refresh: sendRequest} = useRequest(() => topicsApi.createTopic({ topicId: form.getFieldValue("id") }), {manual:true}); + const [addButtonText, setAddButtonText] = useState<"Add" | "Add Another">( + "Add" + ); + const { + data, + error, + refresh: sendRequest, + } = useRequest( + () => topicsApi.createTopic({ topicId: form.getFieldValue("id") }), + { manual: true } + ); +function handleClose(){ + setOpen(false); + form.resetFields(); +} + function handleSubmit() { form .validateFields({ validateOnly: true }) - .then((id) => { + .then(() => { sendRequest(); - setAddButtonText("Add Another") + setAddButtonText("Add Another"); }) - .catch((error) => { - }); + .catch(() => {}); } return ( <> @@ -28,8 +40,12 @@ export const CreateTopic: React.FunctionComponent = (props) => { open={open} title="Create Topic" centered + afterClose={handleClose} + closable + onCancel={handleClose} + maskClosable={true} footer={[ - , + , ,