import { Dispatch, FC, SetStateAction } from "react";

import { eventContextMenu } from "shared/lib/slickgrid";

import Styled from "../ContextMenu.style";

export const ButtonGroup: FC<IProps> = ({ setIsOpened }) => {
	const table = eventContextMenu.table;

	function group() {
		if (!table) return;
		table.grouping = { isGrouped: true };
		setIsOpened(false);
	}

	if (table?.grouping.isGrouped !== false) return null;

	return (
		<Styled.Li onClick={group}>
			<Styled.Icon className={"sgi sgi-link"}></Styled.Icon>
			Group
		</Styled.Li>
	);
};

interface IProps {
	setIsOpened: Dispatch<SetStateAction<boolean>>;
}
