import { ChatStore, TemplateAPI } from "@/types/chatstore"; import { Tr } from "@/translate"; import { NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, } from "@/components/ui/navigation-menu"; import { Button } from "./components/ui/button"; import { cn } from "@/lib/utils"; import { useContext } from "react"; import { AppContext } from "./pages/App"; interface Props { label: string; apiField: string; keyField: string; } export function ListAPIs({ label, apiField, keyField }: Props) { const ctx = useContext(AppContext); if (ctx === null) return <>; return ( {label}{" "} {ctx.templateAPIs.find( (t) => ctx.chatStore[apiField as keyof ChatStore] === t.endpoint && ctx.chatStore[keyField as keyof ChatStore] === t.key )?.name && `: ${ ctx.templateAPIs.find( (t) => ctx.chatStore[apiField as keyof ChatStore] === t.endpoint && ctx.chatStore[keyField as keyof ChatStore] === t.key )?.name }`} ); }