From e13e630cd6e4fc0b1ff92098a28a770794c7bb9a Mon Sep 17 00:00:00 2001 From: gabrhr <73925454+gabrhr@users.noreply.github.com> Date: Wed, 20 Apr 2022 10:19:29 -0500 Subject: =?UTF-8?q?A=C3=B1adir=20plantilla?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Base para front --- front/odiparpack/app/components/Chat/ChatRoom.js | 106 +++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 front/odiparpack/app/components/Chat/ChatRoom.js (limited to 'front/odiparpack/app/components/Chat/ChatRoom.js') diff --git a/front/odiparpack/app/components/Chat/ChatRoom.js b/front/odiparpack/app/components/Chat/ChatRoom.js new file mode 100644 index 0000000..9abef89 --- /dev/null +++ b/front/odiparpack/app/components/Chat/ChatRoom.js @@ -0,0 +1,106 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { withStyles } from '@material-ui/core/styles'; +import classNames from 'classnames'; +import Send from '@material-ui/icons/Send'; +import dummyContents from 'ba-api/dummyContents'; +import Type from 'ba-styles/Typography.scss'; +import { Avatar, Typography, Paper, Tooltip, IconButton } from '@material-ui/core'; +import MessageField from './MessageField'; +import styles from './chatStyle-jss'; + + +class ChatRoom extends React.Component { + constructor() { + super(); + this.state = { message: '' }; + this.handleWrite = this.handleWrite.bind(this); + } + + handleWrite = (e, value) => { + this.setState({ message: value }); + }; + + resetInput = () => { + const ctn = document.getElementById('roomContainer'); + this.setState({ message: '' }); + this._field.setState({ value: '' }); + setTimeout(() => { + ctn.scrollTo(0, ctn.scrollHeight); + }, 300); + } + + sendMessageByEnter = (event, message) => { + if (event.key === 'Enter' && event.target.value !== '') { + this.props.sendMessage(message.__html); + this.resetInput(); + } + } + + sendMessage = message => { + this.props.sendMessage(message.__html); + this.resetInput(); + } + + render() { + const html = { __html: this.state.message }; + const { + classes, + dataChat, + chatSelected, + dataContact, + showMobileDetail, + } = this.props; + const { message } = this.state; + const getChat = dataArray => dataArray.map(data => { + const renderHTML = { __html: data.get('message') }; + return ( +
+