# All files / components/DragGroups DragGroupDropArea.js

28.57% Statements 2/7
100% Branches 0/0
0% Functions 0/3
33.33% Lines 2/6

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45

    1x

    1x

     import React from 'react';
    import PropTypes from 'prop-types';
    import { DropTarget } from 'react-dnd';
    import DragGroupDropAreaContent from './styles/DragGroupDropAreaContent';

    class DragGroupDropArea extends React.Component {
      static propTypes = {
        itemType: PropTypes.string.isRequired,
        groupIndex: PropTypes.number.isRequired,
        Content: PropTypes.func,
      };

      static defaultProps = {
        Content: DragGroupDropAreaContent,
      };

      render() {
        const { connectDropTarget, Content, canDrop, isOver } = this.props;
        return connectDropTarget(
          <div>
            <Content canDrop={canDrop} isOver={isOver} />
          </div>,
        );
      }
    }

    const dropSource = {
      drop(props) {
        return {
          type: 'group',
          groupIndex: props.groupIndex,
        };
      },
    };

    const collect = (connect, monitor) => ({
      connectDropTarget: connect.dropTarget(),
      canDrop: monitor.canDrop(),
      isOver: monitor.isOver(),
    });

    export default DropTarget(props => props.itemType, dropSource, collect)(
      DragGroupDropArea,
    );