import { useRecoilState } from 'recoil';
import { usePreviousHotkeysScope } from '@/hotkeys/hooks/internal/usePreviousHotkeysScope';
import { useScopedHotkeys } from '@/hotkeys/hooks/useScopedHotkeys';
import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysScope';
import { isCommandMenuOpenedState } from '../states/isCommandMenuOpened';
import { CommandMenuItem } from './CommandMenuItem';
import {
StyledDialog,
StyledEmpty,
StyledGroup,
StyledInput,
StyledList,
} from './CommandMenuStyles';
export function CommandMenu() {
const [open, setOpen] = useRecoilState(isCommandMenuOpenedState);
useScopedHotkeys(
'ctrl+k,meta+k',
() => {
handleOpenChange(!open);
},
InternalHotkeysScope.CommandMenu,
[setOpen, open, handleOpenChange],
);
const {
setHotkeysScopeAndMemorizePreviousScope,
goBackToPreviousHotkeysScope,
} = usePreviousHotkeysScope();
function handleOpenChange(newOpenState: boolean) {
if (newOpenState) {
setOpen(true);
setHotkeysScopeAndMemorizePreviousScope(InternalHotkeysScope.CommandMenu);
} else {
setOpen(false);
goBackToPreviousHotkeysScope();
}
}
/*
TODO: Allow performing actions on page through CommandBar
import { useMatch, useResolvedPath } from 'react-router-dom';
import { IconBuildingSkyscraper, IconUser } from '@/ui/icons';
const createSection = (
}
shortcuts={
!!useMatch({
path: useResolvedPath('/people').pathname,
end: true,
})
? ['C']
: []
}
/>
}
shortcuts={
!!useMatch({
path: useResolvedPath('/companies').pathname,
end: true,
})
? ['C']
: []
}
/>
);*/
return (
No results found.
);
}