From bdcaa35b98ecca88c31134b290ebe527bb9f9c1b Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Sat, 4 Mar 2023 23:45:45 +0800 Subject: [PATCH] ui: error message --- .../Chat/ChatContent/ChatContent.tsx | 24 ++++++++++++------- src/hooks/useSubmit.ts | 3 --- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/Chat/ChatContent/ChatContent.tsx b/src/components/Chat/ChatContent/ChatContent.tsx index ece04b4..aea9de5 100644 --- a/src/components/Chat/ChatContent/ChatContent.tsx +++ b/src/components/Chat/ChatContent/ChatContent.tsx @@ -6,13 +6,15 @@ import ScrollToBottomButton from './ScrollToBottomButton'; import ChatTitle from './ChatTitle'; import Message from './Message'; import NewMessageButton from './Message/NewMessageButton'; +import CrossIcon from '@icon/CrossIcon'; import useSubmit from '@hooks/useSubmit'; const ChatContent = () => { - const [messages, inputRole] = useStore((state) => [ + const [messages, inputRole, setError] = useStore((state) => [ state.messages, state.inputRole, + state.setError, ]); const { handleSubmit, error } = useSubmit(); @@ -39,8 +41,18 @@ const ChatContent = () => { {error !== '' && ( -
- {error} +
+
+ {error} +
+
{ + setError(''); + }} + > + +
)} @@ -53,12 +65,6 @@ const ChatContent = () => { > Submit - {/* */}
diff --git a/src/hooks/useSubmit.ts b/src/hooks/useSubmit.ts index 4b9a822..7980ef5 100644 --- a/src/hooks/useSubmit.ts +++ b/src/hooks/useSubmit.ts @@ -77,9 +77,6 @@ const useSubmit = () => { const err = (e as Error).message; console.log(err); setError(err); - setTimeout(() => { - setError(''); - }, 10000); } setGenerating(false); };