import { useEffect, useState } from "react"; import { Search } from "lucide-react"; import { Dialog, DialogContent, DialogDescription, DialogTitle, } from "@/components/ui/dialog"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@/components/ui/command"; import { SidebarMenuButton } from "@/components/ui/sidebar"; import { searchableFeatures, featureSearchScore, } from "@/lib/feature-navigation"; import type { PageId } from "@/contexts/navigation-context"; export function FeatureSearch({ isPro, onNavigate, }: { isPro: boolean; onNavigate: (page: PageId) => void; }) { const [open, setOpen] = useState(false); useEffect(() => { const shortcut = (event: KeyboardEvent) => { if ( event.key.toLowerCase() === "k" && (event.metaKey || event.ctrlKey) && !event.altKey && !event.repeat ) { event.preventDefault(); setOpen((previous) => !previous); } }; document.addEventListener("keydown", shortcut); return () => document.removeEventListener("keydown", shortcut); }, []); return ( <> setOpen(true)} aria-label="Find a feature" className="border bg-background" > Find a feature Search Swift Commerce features by name or task. No matching features. Try a name such as registration or tracking. {searchableFeatures(isPro).map((feature) => ( { setOpen(false); onNavigate(feature.pageId); }} className="gap-3 py-3" > ))} ); }