From fd18ac5cd96f76a39de57bb6a877d3f0faf7c528 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 20 Jun 2018 10:15:31 +0300 Subject: refactoring --- vnext/src/components/Message.js | 9 ++------- vnext/src/components/MessageInput.js | 26 ++++++++++++++++++++++++++ vnext/src/components/Thread.js | 36 ++++++++++++++++-------------------- vnext/src/components/Types.js | 7 +++++++ 4 files changed, 51 insertions(+), 27 deletions(-) create mode 100644 vnext/src/components/MessageInput.js (limited to 'vnext/src/components') diff --git a/vnext/src/components/Message.js b/vnext/src/components/Message.js index e03935ce..8e060aa8 100644 --- a/vnext/src/components/Message.js +++ b/vnext/src/components/Message.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { Link } from 'react-router-dom'; import moment from 'moment'; -import { UserType } from './Types'; +import { UserType, MessageType } from './Types'; import Icon from './Icon'; import Avatar from './Avatar'; @@ -104,12 +104,7 @@ function Tags(props) { } Message.propTypes = { - data: PropTypes.shape({ - mid: PropTypes.number.isRequired, - user: UserType, - timestamp: PropTypes.string.isRequired, - body: PropTypes.string - }), + data: MessageType, children: PropTypes.node }; diff --git a/vnext/src/components/MessageInput.js b/vnext/src/components/MessageInput.js new file mode 100644 index 00000000..2a7eab1d --- /dev/null +++ b/vnext/src/components/MessageInput.js @@ -0,0 +1,26 @@ +import React from 'react'; + +import { MessageType } from './Types'; + +export default class MessageInput extends React.Component { + constructor(props) { + super(props) + } + render() { + const msg = this.props.data; + return ( +
+ ) + } +} + +MessageInput.propTypes = { + data: MessageType +}; \ No newline at end of file diff --git a/vnext/src/components/Thread.js b/vnext/src/components/Thread.js index 4cf36747..6830a821 100644 --- a/vnext/src/components/Thread.js +++ b/vnext/src/components/Thread.js @@ -4,6 +4,7 @@ import * as qs from 'query-string'; import moment from 'moment'; import Message from './Message'; +import MessageInput from './MessageInput'; import Spinner from './Spinner'; import Avatar from './Avatar'; @@ -60,25 +61,8 @@ export default class Thread extends React.Component { { this.loaded() ? (