diff --git a/src/components/ConversationView/index.tsx b/src/components/ConversationView/index.tsx index 59dc0b6..4f79dda 100644 --- a/src/components/ConversationView/index.tsx +++ b/src/components/ConversationView/index.tsx @@ -18,6 +18,7 @@ import MessageView from "./MessageView"; import MessageTextarea from "./MessageTextarea"; import DataStorageBanner from "../DataStorageBanner"; import ProductHuntBanner from "../ProductHuntBanner"; +import QuotaOverflowBanner from "../QuotaOverflowBanner"; // The maximum number of tokens that can be sent to the OpenAI API. // reference: https://platform.openai.com/docs/api-reference/completions/create#completions/create-max_tokens @@ -105,7 +106,7 @@ const ConversationView = () => { }, [currentConversation, connectionStore.currentConnectionCtx]); const sendMessageToCurrentConversation = async () => { - const currentConversation = conversationStore.getConversationById(conversationStore.getState().currentConversationId) + const currentConversation = conversationStore.getConversationById(conversationStore.getState().currentConversationId); if (!currentConversation) { return; } @@ -220,6 +221,7 @@ const ConversationView = () => { >
+
diff --git a/src/components/QuotaOverflowBanner.tsx b/src/components/QuotaOverflowBanner.tsx new file mode 100644 index 0000000..2ab69d4 --- /dev/null +++ b/src/components/QuotaOverflowBanner.tsx @@ -0,0 +1,41 @@ +import { useTranslation } from "react-i18next"; +import { useLocalStorage } from "react-use"; +import Icon from "./Icon"; +import SettingModal from "./SettingModal"; +import { useState } from "react"; + +interface Props { + className?: string; +} + +const QuotaOverflowBanner = (props: Props) => { + const { className } = props; + const { t } = useTranslation(); + const [hideBanner, setHideBanner] = useLocalStorage("hide-quota-overflow-banner", false); + const [showSettingModal, setShowSettingModal] = useState(false); + const show = !hideBanner; + + return ( + <> +
+
+ {t("banner.quota-overflow")}{" "} + +
+ +
+ + {showSettingModal && setShowSettingModal(false)} />} + + ); +}; + +export default QuotaOverflowBanner; diff --git a/src/locales/en.json b/src/locales/en.json index 89c58e9..2a6ceb6 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -72,6 +72,8 @@ "banner": { "data-storage": "Connection settings are stored in your local browser", "non-select-sql-warning": "The current statement may be non-SELECT SQL, which will result in a database schema or data change. Make sure you know what you are doing.", - "product-hunt": "๐Ÿš€๐Ÿš€๐Ÿš€ We just launched on Product Hunt, please give us a vote! ๐Ÿš€๐Ÿš€๐Ÿš€" + "product-hunt": "๐Ÿš€๐Ÿš€๐Ÿš€ We just launched on Product Hunt, please give us a vote! ๐Ÿš€๐Ÿš€๐Ÿš€", + "quota-overflow": "Our quota is full and we are applying for additional credits. Please wait a moment.", + "use-my-key": "Use my key" } } diff --git a/src/locales/zh.json b/src/locales/zh.json index 8ee4895..f770b57 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -72,6 +72,8 @@ "banner": { "data-storage": "่ฟžๆŽฅ่ฎพ็ฝฎๅญ˜ๅ‚จๅœจๆ‚จ็š„ๆœฌๅœฐๆต่งˆๅ™จไธญ", "non-select-sql-warning": "ๅฝ“ๅ‰่ฏญๅฅๅฏ่ƒฝๆ˜ฏ้ž SELECT SQL๏ผŒ่ฟ™ๅฐ†ๅฏผ่‡ดๆ•ฐๆฎๅบ“ๆจกๅผๆˆ–ๆ•ฐๆฎๅ˜ๅŒ–ใ€‚", - "product-hunt": "๐Ÿš€๐Ÿš€๐Ÿš€ ๆˆ‘ไปฌๅˆšๅœจ Product Hunt ๅ‘ๅธƒ, ๆฅ็ป™ๆˆ‘ไปฌ็‚นไธช่ตž! ๐Ÿš€๐Ÿš€๐Ÿš€" + "product-hunt": "๐Ÿš€๐Ÿš€๐Ÿš€ ๆˆ‘ไปฌๅˆšๅœจ Product Hunt ๅ‘ๅธƒ, ๆฅ็ป™ๆˆ‘ไปฌ็‚นไธช่ตž! ๐Ÿš€๐Ÿš€๐Ÿš€", + "quota-overflow": "ๆˆ‘ไปฌ็š„ OpenAI ้ขๅบฆๅทฒๆปก๏ผŒๆญฃๅœจ็”ณ่ฏท้ขๅค–็š„้ขๅบฆใ€‚่ฏท็จๅ€™ๅ†ๆฅใ€‚", + "use-my-key": "็”จๆˆ‘่‡ชๅทฑ็š„ Key" } }