@@ -20,6 +20,8 @@ import { useRouter } from "next/navigation";
2020import type { ReactNode } from "react" ;
2121import { useEffect , useMemo } from "react" ;
2222
23+ import dayjs from "@calcom/dayjs" ;
24+
2325type ShortcutArrayType = {
2426 shortcuts ?: string [ ] ;
2527} ;
@@ -231,7 +233,7 @@ function useEventTypesAction(): void {
231233 const router = useRouter ( ) ;
232234 const { data } = trpc . viewer . eventTypes . getEventTypesFromGroup . useInfiniteQuery (
233235 {
234- limit : 10 ,
236+ limit : 100 ,
235237 group : { teamId : null , parentId : null } ,
236238 } ,
237239 {
@@ -259,7 +261,46 @@ function useEventTypesAction(): void {
259261 actions = eventTypeActions ;
260262 }
261263
262- useRegisterActions ( actions ) ;
264+ useRegisterActions ( actions , [ data ] ) ;
265+ }
266+
267+ function useUpcomingBookingsAction ( ) : void {
268+ const router = useRouter ( ) ;
269+
270+ const { data } = trpc . viewer . bookings . get . useQuery (
271+ {
272+ filters : {
273+ status : "upcoming" ,
274+ afterStartDate : dayjs ( ) . startOf ( "day" ) . toISOString ( ) ,
275+ } ,
276+ limit : 100 ,
277+ } ,
278+ {
279+ refetchOnWindowFocus : false ,
280+ staleTime : 5 * 60 * 1000 ,
281+ }
282+ ) ;
283+
284+ const bookingActions : Action [ ] = useMemo ( ( ) => {
285+ if ( ! data ?. bookings ) return [ ] ;
286+
287+ return data . bookings . map ( ( booking ) => {
288+ const startTime = dayjs ( booking . startTime ) ;
289+ const formattedDate = startTime . format ( "MMM D" ) ;
290+ const formattedTime = startTime . format ( "h:mm A" ) ;
291+ const attendeeNames = ( booking . attendees ?? [ ] ) . map ( ( a ) => a . name ) . join ( " " ) ;
292+
293+ return {
294+ id : `booking-${ booking . uid } ` ,
295+ name : `${ booking . title } - ${ formattedDate } ${ formattedTime } ` ,
296+ section : { name : "upcoming" , priority : 1 } ,
297+ keywords : `booking ${ booking . title } ${ attendeeNames } ` ,
298+ perform : ( ) => router . push ( `/booking/${ booking . uid } ` ) ,
299+ } ;
300+ } ) ;
301+ } , [ data ?. bookings , router ] ) ;
302+
303+ useRegisterActions ( bookingActions , [ bookingActions ] ) ;
263304}
264305
265306const KBarRoot = ( { children } : { children : ReactNode } ) : JSX . Element => {
@@ -279,6 +320,7 @@ function CommandKey(): JSX.Element {
279320const KBarContent = ( ) : JSX . Element => {
280321 const { t } = useLocale ( ) ;
281322 useEventTypesAction ( ) ;
323+ useUpcomingBookingsAction ( ) ;
282324
283325 return (
284326 < KBarPortal >
0 commit comments