bot-selector.tsx (1969B)
1 import { ChevronDown, Crown } from "lucide-react"; 2 import { Button } from "../ui/button"; 3 import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "../ui/dropdown-menu"; 4 import CreateBotModal from "../modals/create-bot"; 5 import Link from "next/link"; 6 import { ListResponse } from "@/lib/api"; 7 import { Skeleton } from "../ui/skeleton"; 8 9 export default function BotSelector({ 10 selectedTeam, 11 listData 12 }: { 13 selectedTeam?: string; 14 listData: ListResponse | undefined; 15 }) { 16 if (!listData) { 17 return <Skeleton className="h-10 w-64" />; 18 } 19 20 const bots = listData.bots; 21 return ( 22 <DropdownMenu> 23 <DropdownMenuTrigger asChild> 24 <Button variant="outline" className="hidden md:flex border-purple-500 text-purple-400 hover:bg-purple-950"> 25 <Crown className="mr-2 h-4 w-4" /> 26 {bots.find((bot) => bot.id === selectedTeam)?.displayName || "Select a Bot"} 27 <ChevronDown className="ml-2 h-4 w-4" /> 28 </Button> 29 </DropdownMenuTrigger> 30 <DropdownMenuContent className="w-56 bg-gray-900 border-gray-800"> 31 <DropdownMenuLabel>Your Bots</DropdownMenuLabel> 32 <DropdownMenuSeparator className="bg-gray-800" /> 33 {bots.map((bot) => ( 34 <Link key={bot.id} href={{ 35 query: { team: bot.id }, 36 }}> 37 <DropdownMenuItem 38 className={selectedTeam === bot.id ? "bg-gray-800" : ""} 39 > 40 {bot.displayName} 41 </DropdownMenuItem> 42 </Link> 43 ))} 44 <DropdownMenuSeparator className="bg-gray-800" /> 45 <CreateBotModal /> 46 </DropdownMenuContent> 47 </DropdownMenu> 48 ) 49 }