import { useItemFieldContextMenu } from "../ItemFieldContextMenu"
import { Container } from "./Container"
import { useCopy } from "./hooks"

export const TextView: React.FC<{ value: string }> = ({ value }) => {
  const { onRightClick, ContextMenuContainer, Item } = useItemFieldContextMenu()
  const onCopy = useCopy(value)

  return (
    <>
      <Container onContextMenu={onRightClick} onClick={onCopy}>
        {value}
      </Container>
      <ContextMenuContainer>
        <Item onClick={onCopy}>Copier</Item>
      </ContextMenuContainer>
    </>
  )
}
