-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1465 from mito-ds/upgrade-msg-redesign
Added alert block for nicer error messages
- Loading branch information
Showing
5 changed files
with
68 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import ErrorIcon from '../../../icons/ErrorIcon'; | ||
|
||
|
||
interface IAlertBlockProps { | ||
content: string; | ||
mitoAIConnectionErrorType: string | null; | ||
} | ||
|
||
const AlertBlock: React.FC<IAlertBlockProps> = ({ content, mitoAIConnectionErrorType }) => { | ||
const [message, setMessage] = useState<string | JSX.Element>(""); | ||
|
||
useEffect(() => { | ||
if (mitoAIConnectionErrorType === "mito_server_free_tier_limit_reached") { | ||
const message = ( | ||
<p> | ||
You've reached the free tier limit for Mito AI. <a href="https://www.trymito.io/plans" target="_blank">Upgrade to Pro for unlimited uses</a> or supply your own OpenAI API key. | ||
</p> | ||
); | ||
setMessage(message); | ||
} | ||
else { | ||
setMessage(content); | ||
} | ||
}, [content]); | ||
|
||
return ( | ||
<div className="chat-message-alert"> | ||
<span style={{ marginRight: '4px' }}><ErrorIcon /></span> | ||
{message} | ||
</div> | ||
); | ||
}; | ||
|
||
export default AlertBlock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters