mirror of
https://github.com/deiucanta/chatpad.git
synced 2026-03-11 09:04:31 +00:00
fix: show notification if api key missing
This commit is contained in:
parent
066c697438
commit
d07b23cdbf
2 changed files with 19 additions and 1 deletions
|
|
@ -32,6 +32,7 @@ import { SettingsModal } from "./SettingsModal";
|
|||
import { config } from "../utils/config";
|
||||
import { ChatContext, ChatsContext, PromptsContext, SettingsContext } from "../hooks/contexts";
|
||||
import { ChatHeader } from "./ChatHeader";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
|
|
@ -236,6 +237,15 @@ export function Layout() {
|
|||
fullWidth
|
||||
leftIcon={<IconPlus size={20} />}
|
||||
onClick={async () => {
|
||||
if (!settings?.openAiApiKey) {
|
||||
notifications.show({
|
||||
title: "Error",
|
||||
color: "red",
|
||||
message: "OpenAI API Key is not defined. Please set your API Key",
|
||||
});
|
||||
return;
|
||||
};
|
||||
|
||||
const item = await detaDB.chats.put({
|
||||
description: "New Chat",
|
||||
totalTokens: 0,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { Chat, detaDB, generateKey } from "../db";
|
|||
import { DeletePromptModal } from "./DeletePromptModal";
|
||||
import { EditPromptModal } from "./EditPromptModal";
|
||||
import { useChats, usePrompts, useSettings } from "../hooks/contexts";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
|
||||
export function Prompts({
|
||||
onPlay,
|
||||
|
|
@ -82,7 +83,14 @@ export function Prompts({
|
|||
<ActionIcon
|
||||
size="lg"
|
||||
onClick={async () => {
|
||||
if (!settings?.openAiApiKey) return;
|
||||
if (!settings?.openAiApiKey) {
|
||||
notifications.show({
|
||||
title: "Error",
|
||||
color: "red",
|
||||
message: "OpenAI API Key is not defined. Please set your API Key",
|
||||
});
|
||||
return;
|
||||
};
|
||||
|
||||
const item = await detaDB.chats.put({
|
||||
description: prompt.title ? `New ${prompt.title} Chat` : "New Chat",
|
||||
|
|
|
|||
Loading…
Reference in a new issue