diff --git a/src/components/ListAPI.tsx b/src/components/ListAPI.tsx index 1c55037..c3cc4c2 100644 --- a/src/components/ListAPI.tsx +++ b/src/components/ListAPI.tsx @@ -1,16 +1,14 @@ -import React from "react"; -import { ChatStore, TemplateAPI, TemplateChatStore } from "@/types/chatstore"; +import React, { useContext } from "react"; +import { + ChatStore, + TemplateAPI, + TemplateChatStore, + TemplateTools, +} from "@/types/chatstore"; import { Tr } from "@/translate"; -import { - NavigationMenuContent, - NavigationMenuItem, - NavigationMenuLink, - NavigationMenuTrigger, -} from "@/components/ui/navigation-menu"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; -import { useContext } from "react"; import { AppChatStoreContext, AppContext } from "@/pages/App"; import { NavigationMenu, @@ -83,63 +81,53 @@ function APIsDropdownList({ API = templateAPIsImageGen; } + const [open, setOpen] = React.useState(false); + return ( - - - {shortLabel} - - {label}{" "} - {API.find( - (t: TemplateAPI) => - chatStore[apiField as keyof ChatStore] === t.endpoint && - chatStore[keyField as keyof ChatStore] === t.key - )?.name && - `: ${ - API.find( - (t: TemplateAPI) => - chatStore[apiField as keyof ChatStore] === t.endpoint && - chatStore[keyField as keyof ChatStore] === t.key - )?.name - }`} - - - - - - + + ))} + + + + + + ); } @@ -198,7 +186,7 @@ function ToolsDropdownList() { Clear tools )} - {ctx.templateTools.map((t, index) => ( + {ctx.templateTools.map((t: TemplateTools, index: number) => ( { // Update chatStore with the selected template - if (chatStore.history.length > 0 || chatStore.systemMessageContent) { + if ( + chatStore.history.length > 0 || + chatStore.systemMessageContent + ) { console.log("you clicked", t.name); const confirm = window.confirm( "This will replace the current chat history. Are you sure? " @@ -264,7 +255,9 @@ function ChatTemplateDropdownList() { setChatStore({ ...newChatStore({ ...chatStore, - ...{ use_this_history: t.history ?? chatStore.history }, + ...{ + use_this_history: t.history ?? chatStore.history, + }, ...t, }), }); @@ -289,42 +282,38 @@ const APIListMenu: React.FC = () => {
{ctx.templateTools.length > 0 && } {ctx.templates.length > 0 && } - - - {ctx.templateAPIs.length > 0 && ( - - )} - {ctx.templateAPIsWhisper.length > 0 && ( - - )} - {ctx.templateAPIsTTS.length > 0 && ( - - )} - {ctx.templateAPIsImageGen.length > 0 && ( - - )} - - + {ctx.templateAPIs.length > 0 && ( + + )} + {ctx.templateAPIsWhisper.length > 0 && ( + + )} + {ctx.templateAPIsTTS.length > 0 && ( + + )} + {ctx.templateAPIsImageGen.length > 0 && ( + + )}
); };