import React from 'react'
import ScrollContainer from 'react-indiana-drag-scroll'
import useWheelScrollWhileHovering from './useWheelScrollWhileHovering'

type Props = {
  scrollEnabled: boolean
}

const TableScrollContainer: React.FC<Props> = ({ children, scrollEnabled }) => {
  const scrollRef = useWheelScrollWhileHovering()

  return (
    <ScrollContainer
      vertical={false}
      horizontal={scrollEnabled}
      innerRef={scrollRef}
    >
      {children}
    </ScrollContainer>
  )
}

export default TableScrollContainer
