import { KBarProvider, KBarPortal, KBarPositioner, KBarAnimator, KBarSearch, KBarResults, useMatches, useKBar, } from "kbar"; import { useRouter } from "next/router"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { isMac } from "@calcom/lib/isMac"; import { Tooltip } from "@calcom/ui"; import { Icon } from "@calcom/ui/Icon"; type shortcutArrayType = { shortcuts?: string[]; }; export const KBarRoot = ({ children }: { children: React.ReactNode }) => { const router = useRouter(); // grab link to events // quick nested actions would be extremely useful const actions = [ // { // id: "toggle-idle", // name: "Test Function", // section: "Status", // shortcut: ["t", "f"], // keywords: "set yourself away bookings", // perform: () => alert("Hello World"), // }, { id: "workflows", name: "Workflows", section: "Workflows", shortcut: ["w", "f"], keywords: "workflows automation", perform: () => router.push("/workflows"), }, { id: "event-types", name: "Event Types", section: "Event Types", shortcut: ["e", "t"], keywords: "event types", perform: () => router.push("/event-types"), }, { id: "app-store", name: "App Store", section: "Apps", shortcut: ["a", "s"], keywords: "app store", perform: () => router.push("/apps"), }, { id: "upcoming-bookings", name: "Upcoming Bookings", section: "Bookings", shortcut: ["u", "b"], keywords: "upcoming bookings", perform: () => router.push("/bookings/upcoming"), }, { id: "recurring-bookings", name: "Recurring Bookings", section: "Bookings", shortcut: ["r", "b"], keywords: "recurring bookings", perform: () => router.push("/bookings/recurring"), }, { id: "past-bookings", name: "Past Bookings", section: "Bookings", shortcut: ["p", "b"], keywords: "past bookings", perform: () => router.push("/bookings/past"), }, { id: "cancelled-bookings", name: "Cancelled Bookings", section: "Bookings", shortcut: ["c", "b"], keywords: "cancelled bookings", perform: () => router.push("/bookings/cancelled"), }, { id: "schedule", name: "Schedule", section: "Availability", shortcut: ["s", "a"], keywords: "schedule availability", perform: () => router.push("/availability"), }, { id: "profile", name: "Profile", section: "Profile Settings", shortcut: ["p", "s"], keywords: "setting profile", perform: () => router.push("/settings/profile"), }, { id: "avatar", name: "Change Avatar", section: "Profile Settings", shortcut: ["c", "a"], keywords: "remove change modify avatar", perform: () => router.push("/settings/profile"), }, { id: "timezone", name: "Change Timezone", section: "Profile Settings", shortcut: ["c", "t"], keywords: "change modify timezone", perform: () => router.push("/settings/profile"), }, { id: "brand-color", name: "Change Brand Color", section: "Profile Settings", shortcut: ["b", "c"], keywords: "change modify brand color", perform: () => router.push("/settings/profile"), }, { id: "teams", name: "Teams", shortcut: ["t", "s"], keywords: "add manage modify team", perform: () => router.push("/settings/teams"), }, { id: "password", name: "Change Password", section: "Security Settings", shortcut: ["c", "p"], keywords: "change modify password", perform: () => router.push("/settings/security"), }, { id: "two-factor", name: "Two Factor Authentication", section: "Security Settings", shortcut: ["t", "f", "a"], keywords: "two factor authentication", perform: () => router.push("/settings/security"), }, { id: "impersonation", name: "User Impersonation", section: "Security Settings", shortcut: ["u", "i"], keywords: "user impersonation", perform: () => router.push("/settings/security"), }, { id: "webhooks", name: "Webhook", section: "Developer Settings", shortcut: ["w", "h"], keywords: "webhook automation", perform: () => router.push("/settings/developer"), }, { id: "api-keys", name: "API Keys", section: "Developer Settings", shortcut: ["a", "p", "i"], keywords: "api keys", perform: () => router.push("/settings/developer"), }, { id: "billing", name: "View and Manage Billing", section: "Billing", shortcut: ["m", "b"], keywords: "billing view manage", perform: () => router.push("/settings/billing"), }, ]; return {children}; }; export const KBarContent = () => { const { t } = useLocale(); return ( {t("navigate")} {t("open")} {isMac ? : "CTRL"} + K {t("close")} ); }; export const KBarTrigger = () => { const { query } = useKBar(); return ( <> > ); }; const DisplayShortcuts = (item: shortcutArrayType) => { const shortcuts = item.shortcuts; return ( {shortcuts?.map((shortcut) => { return ( {shortcut} ); })} ); }; function RenderResults() { const { results } = useMatches(); return ( typeof item === "string" ? ( {item} ) : ( {item.name} ) } /> ); }