import React from 'react';
import { ActionButton } from './ActionButton';
import { ActionPopover } from './ActionPopover';
import { ActionSubItemPrivate } from './ActionSubItemProps';
import { ButtonProps } from '@wix/design-system';

export function ActionControl(props: {
  actionItem: ActionSubItemPrivate;
  size?: ButtonProps['size'];
  priority?: ButtonProps['priority'];
  fullWidth?: ButtonProps['fullWidth'];
  onPopoverClick?: () => void;
}) {
  const {
    actionItem: { subItems },
  } = props;

  return subItems ? <ActionPopover {...props} /> : <ActionButton {...props} />;
}
