11import { useState } from "react" ;
22import _CommandPalette , { filterItems , getItemIndex } from "react-cmdk" ;
33import "react-cmdk/dist/cmdk.css" ;
4+ import { useNavigate } from "react-router-dom" ;
45import dayjs from "@core/util/date/dayjs" ;
56import { moreCommandPaletteItems } from "@web/common/constants/more.cmd.constants" ;
7+ import { getNavigationCommandItems } from "@web/common/constants/navigation.cmd.constants" ;
68import { VIEW_SHORTCUTS } from "@web/common/constants/shortcuts.constants" ;
79import { useAuthCmdItems } from "@web/common/hooks/useAuthCmdItems" ;
810import { useGoogleCmdItems } from "@web/common/hooks/useGoogleCmdItems" ;
911import { useLogoutCmdItems } from "@web/common/hooks/useLogoutCmdItems" ;
10- import { pressKey } from "@web/common/utils/dom/event-emitter.util" ;
1112import { resolveDefaultExport } from "@web/common/utils/resolve-default-export.util" ;
1213import { selectIsCmdPaletteOpen } from "@web/ducks/settings/selectors/settings.selectors" ;
1314import { settingsSlice } from "@web/ducks/settings/slices/settings.slice" ;
@@ -25,6 +26,7 @@ interface DayCmdPaletteProps {
2526
2627export const DayCmdPalette = ( { onGoToToday } : DayCmdPaletteProps ) => {
2728 const dispatch = useAppDispatch ( ) ;
29+ const navigate = useNavigate ( ) ;
2830 const open = useAppSelector ( selectIsCmdPaletteOpen ) ;
2931 const [ page ] = useState < "root" > ( "root" ) ;
3032 const [ search , setSearch ] = useState ( "" ) ;
@@ -38,19 +40,21 @@ export const DayCmdPalette = ({ onGoToToday }: DayCmdPaletteProps) => {
3840 {
3941 heading : "Navigation" ,
4042 id : "navigation" ,
41- items : [
42- {
43- id : "go-to-now" ,
44- children : `Go to Now [${ VIEW_SHORTCUTS . now . key } ]` ,
45- icon : "ClockIcon" ,
46- onClick : ( ) => pressKey ( VIEW_SHORTCUTS . now . key ) ,
43+ items : getNavigationCommandItems ( {
44+ currentView : "day" ,
45+ onGoToToday : ( ) => {
46+ onGoToToday ?.( ) ;
4747 } ,
48- {
49- id : "go-to-week" ,
50- children : `Go to Week [${ VIEW_SHORTCUTS . week . key } ]` ,
51- icon : "CalendarIcon" ,
52- onClick : ( ) => pressKey ( VIEW_SHORTCUTS . week . key ) ,
48+ onNavigateToView : ( viewName ) => {
49+ navigate ( VIEW_SHORTCUTS [ viewName ] . route ) ;
5350 } ,
51+ today,
52+ } ) ,
53+ } ,
54+ {
55+ heading : "Common Tasks" ,
56+ id : "general" ,
57+ items : [
5458 {
5559 id : "create-event" ,
5660 children : "Create event" ,
@@ -63,14 +67,6 @@ export const DayCmdPalette = ({ onGoToToday }: DayCmdPaletteProps) => {
6367 icon : "PencilSquareIcon" ,
6468 onClick : ( ) => queueMicrotask ( openEventFormEditEvent ) ,
6569 } ,
66- {
67- id : "today" ,
68- children : `Go to Today (${ today . format ( "dddd, MMMM D" ) } ) [t]` ,
69- icon : "ArrowUturnDownIcon" ,
70- onClick : ( ) => {
71- onGoToToday ?.( ) ;
72- } ,
73- } ,
7470 ] ,
7571 } ,
7672 {
0 commit comments