import React from 'react'; import { ReactNode } from 'react'; import { useNavigate } from 'react-router-dom'; import { IconArrowUpRight } from '@/ui/icon'; import { useCommandMenu } from '../hooks/useCommandMenu'; import { StyledIconAndLabelContainer, StyledIconContainer, StyledMenuItem, StyledShortCut, StyledShortcutsContainer, } from './CommandMenuStyles'; export type OwnProps = { label: string; to?: string; onClick?: () => void; icon?: ReactNode; shortcuts?: Array; }; export function CommandMenuItem({ label, to, onClick, icon, shortcuts, }: OwnProps) { const navigate = useNavigate(); const { closeCommandMenu } = useCommandMenu(); if (to && !icon) { icon = ; } const onItemClick = () => { closeCommandMenu(); if (onClick) { onClick(); return; } if (to) { navigate(to); return; } }; return ( {icon} {label} {shortcuts && shortcuts.map((shortcut, index) => { const prefix = index > 0 ? 'then' : ''; return ( {prefix} {shortcut} ); })} ); }