diff --git a/package.json b/package.json index 9ae83f1..3cbdabd 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "react": "^15.5.4", "react-bootstrap": "^0.31.0", "react-dom": "^15.5.4", + "react-dropzone": "^3.13.2", "react-tap-event-plugin": "^2.0.1", "socket.io": "^2.0.1" }, diff --git a/src/App.js b/src/App.js index 8e609b6..65cb28a 100644 --- a/src/App.js +++ b/src/App.js @@ -10,7 +10,7 @@ import { getGpsCord } from './lib/gps.js'; import { Tabs, Tab, Panel } from 'react-bootstrap'; const io = require('socket.io-client'); -// const SERVER_URL = 'http://localhost:8000'; +//const SERVER_URL = 'http://localhost:8000'; const SERVER_URL = 'https://circle-chat.herokuapp.com'; // For deployment diff --git a/src/component/Chat.js b/src/component/Chat.js index 0a51dae..4e114e0 100644 --- a/src/component/Chat.js +++ b/src/component/Chat.js @@ -1,5 +1,6 @@ import React, { Component } from 'react'; import './Chat.css'; +import ChatPanel from './ChatPanel.js'; class Chat extends Component { constructor(props) { @@ -8,10 +9,8 @@ class Chat extends Component { msg: '', chatMsgs: [] }; - this.handleChange = this.handleChange.bind(this); - this.sendMsg = this.sendMsg.bind(this); this.socket = this.props.socket; - this.socket.on('chat', function(sid, userName, iconName, msg){ + this.socket.on('chat', (sid, userName, iconName, msg) => { this.setState({ chatMsgs: [...this.state.chatMsgs, { sid, @@ -19,27 +18,23 @@ class Chat extends Component { iconName, text: msg, }]}); - }.bind(this)); + }); } - handleChange(event) { + + handleChange = event => { this.setState({msg: event.target.value}); } - sendMsg() { + + sendMsg = () => { console.log(this.props.id, this.state.msg) this.socket.emit('chat', this.props.id, this.props.userName, this.props.iconName, this.state.msg); this.setState({msg: ''}); } + render() { return (
- +
{ + // TODO: need to send image to server + this.setState({images: [...this.state.images, file[0]]}) + //this.props.socket.emit('chat', this.props.id, this.props.userName, this.props.iconName, file[0]); + } + + render() { + // TODO: need to migrate to chatMsgs + const style = { + height: '100px', + width: '100px', + }; + return ( + +
    + {this.props.chatMsgs.map((msg, i) => +
  • + portrait + {msg.userName}: {msg.text} +
  • )} +
+
    + {this.state.images.map((img, i) => +
  • i
  • + )} +
+
+ ); + } +} + +export default ChatPanel; \ No newline at end of file