import { Button, Box, Group, Stack, Text, Progress, HoverCard, Image, createStyles } from '@mantine/core'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import ReactMarkdown from 'react-markdown'; import { Option, ContextMenuProps } from '../../../../typings'; import { fetchNui } from '../../../../utils/fetchNui'; const openMenu = (id: string | undefined) => { fetchNui('openContext', { id: id, back: false }); }; const clickContext = (id: string) => { fetchNui('clickContext', id); }; const useStyles = createStyles((theme, params: { disabled?: boolean }) => ({ inner: { justifyContent: 'flex-start', }, label: { width: '100%', color: params.disabled ? theme.colors.dark[3] : theme.colors.dark[0], whiteSpace: 'pre-wrap', }, description: { color: params.disabled ? theme.colors.dark[3] : theme.colors.dark[2], }, dropdown: { padding: 10, color: theme.colors.dark[0], fontSize: 14, maxWidth: 256, width: 'fit-content', border: 'none', }, })); const ContextButton: React.FC<{ option: [string, Option]; }> = ({ option }) => { const button = option[1]; const buttonKey = option[0]; const { classes } = useStyles({ disabled: button.disabled }); return ( <> {button.image && } {Array.isArray(button.metadata) ? ( button.metadata.map( (metadata: string | { label: string; value?: any; progress?: number }, index: number) => ( <> {typeof metadata === 'string' ? `${metadata}` : `${metadata.label}: ${metadata?.value ?? ''}`} {typeof metadata === 'object' && metadata.progress !== undefined && ( )} ) ) ) : ( <> {typeof button.metadata === 'object' && Object.entries(button.metadata).map((metadata: { [key: string]: any }, index) => ( {metadata[0]}: {metadata[1]} ))} )} ); }; export default ContextButton;