Files
twenty/packages/twenty-front/src/modules/command-menu/components/CommandMenuItem.tsx
T
6264d509bd Migrate to twenty-ui - navigation/menu-item (#8213)
This PR was created by [GitStart](https://gitstart.com/) to address the
requirements from this ticket:
[TWNTY-7536](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-7536).

 --- 

### Description

Migrate all menu items components to twenty ui and update imports.

```typescript
MenuItem
MenuItemAvata
MenuItemCommand
MenuItemCommandHotKeys
MenuItemDraggable
MenuItemMultiSelect
MenuItemMultiSelectAvatar
MenuItemMultiSelectTag
MenuItemNavigate
MenuItemSelect
MenuItemSelectAvatar
MenuItemSelectColor
MenuItemSelectTag
MenuItemSuggestion
MenuItemToggle
```

\
Also migrate all other dependent components and utilities like
`Checkbox` & `Toggle`\
\
Fixes twentyhq/private-issues#82

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: gitstart-twenty <140154534+gitstart-twenty@users.noreply.github.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-11-07 16:51:39 +00:00

48 lines
1.1 KiB
TypeScript

import { isNonEmptyString } from '@sniptt/guards';
import { useRecoilValue } from 'recoil';
import { IconArrowUpRight, IconComponent, MenuItemCommand } from 'twenty-ui';
import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';
import { useCommandMenu } from '../hooks/useCommandMenu';
export type CommandMenuItemProps = {
label: string;
to?: string;
id: string;
onClick?: () => void;
Icon?: IconComponent;
firstHotKey?: string;
secondHotKey?: string;
};
export const CommandMenuItem = ({
label,
to,
id,
onClick,
Icon,
firstHotKey,
secondHotKey,
}: CommandMenuItemProps) => {
const { onItemClick } = useCommandMenu();
if (isNonEmptyString(to) && !Icon) {
Icon = IconArrowUpRight;
}
const { isSelectedItemIdSelector } = useSelectableList();
const isSelectedItemId = useRecoilValue(isSelectedItemIdSelector(id));
return (
<MenuItemCommand
LeftIcon={Icon}
text={label}
firstHotKey={firstHotKey}
secondHotKey={secondHotKey}
onClick={() => onItemClick(onClick, to)}
isSelected={isSelectedItemId}
/>
);
};