ui: error message

This commit is contained in:
Jing Hua 2023-03-04 23:45:45 +08:00
parent b9a8f05176
commit bdcaa35b98
2 changed files with 15 additions and 12 deletions

View file

@ -6,13 +6,15 @@ import ScrollToBottomButton from './ScrollToBottomButton';
import ChatTitle from './ChatTitle'; import ChatTitle from './ChatTitle';
import Message from './Message'; import Message from './Message';
import NewMessageButton from './Message/NewMessageButton'; import NewMessageButton from './Message/NewMessageButton';
import CrossIcon from '@icon/CrossIcon';
import useSubmit from '@hooks/useSubmit'; import useSubmit from '@hooks/useSubmit';
const ChatContent = () => { const ChatContent = () => {
const [messages, inputRole] = useStore((state) => [ const [messages, inputRole, setError] = useStore((state) => [
state.messages, state.messages,
state.inputRole, state.inputRole,
state.setError,
]); ]);
const { handleSubmit, error } = useSubmit(); const { handleSubmit, error } = useSubmit();
@ -39,9 +41,19 @@ const ChatContent = () => {
<Message role={inputRole} content='' messageIndex={-1} sticky /> <Message role={inputRole} content='' messageIndex={-1} sticky />
{error !== '' && ( {error !== '' && (
<div className='bg-red-600/50 p-2 rounded-sm w-3/5 mt-3 text-gray-900 dark:text-gray-300 text-sm break-words'> <div className='relative bg-red-600/50 p-2 rounded-sm w-3/5 mt-3'>
<div className='text-gray-900 dark:text-gray-300 text-sm break-words'>
{error} {error}
</div> </div>
<div
className='text-white absolute top-1 right-1 cursor-pointer'
onClick={() => {
setError('');
}}
>
<CrossIcon />
</div>
</div>
)} )}
<div className='text-center mt-6 flex justify-center gap-2'> <div className='text-center mt-6 flex justify-center gap-2'>
@ -53,12 +65,6 @@ const ChatContent = () => {
> >
Submit Submit
</button> </button>
{/* <button className='btn btn-neutral border-0 md:border mt-2'>
<div className='flex items-center justify-center gap-2'>
<RefreshIcon />
Regenerate response
</div>
</button> */}
</div> </div>
<div className='w-full h-32 md:h-48 flex-shrink-0'></div> <div className='w-full h-32 md:h-48 flex-shrink-0'></div>
</div> </div>

View file

@ -77,9 +77,6 @@ const useSubmit = () => {
const err = (e as Error).message; const err = (e as Error).message;
console.log(err); console.log(err);
setError(err); setError(err);
setTimeout(() => {
setError('');
}, 10000);
} }
setGenerating(false); setGenerating(false);
}; };