Add task and note create option in comand menu (#1115)

* add task and note create option in comand menu

* Re-run CIs

---------

Co-authored-by: Weiko <corentin@twenty.com>
Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
This commit is contained in:
Sunil Kumar Behera
2023-08-10 02:39:32 +05:30
committed by GitHub
parent 22b4bffcde
commit 4a388b8ed5
8 changed files with 223 additions and 39 deletions

View File

@ -1,14 +1,18 @@
import { useRecoilState } from 'recoil';
import { useRecoilState, useSetRecoilState } from 'recoil';
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope';
import { commandMenuCommands } from '../constants/commandMenuCommands';
import { commandMenuCommand } from '../states/commandMenuCommandsState';
import { isCommandMenuOpenedState } from '../states/isCommandMenuOpenedState';
import { Command } from '../types/Command';
export function useCommandMenu() {
const [, setIsCommandMenuOpenedState] = useRecoilState(
isCommandMenuOpenedState,
);
const setCommands = useSetRecoilState(commandMenuCommand);
const {
setHotkeyScopeAndMemorizePreviousScope,
goBackToPreviousHotkeyScope,
@ -24,8 +28,18 @@ export function useCommandMenu() {
goBackToPreviousHotkeyScope();
}
function addToCommandMenu(addCommand: Command[]) {
setCommands((prev) => [...prev, ...addCommand]);
}
function setToIntitialCommandMenu() {
setCommands(commandMenuCommands);
}
return {
openCommandMenu,
closeCommandMenu,
addToCommandMenu,
setToIntitialCommandMenu,
};
}