From 6d9d6ac1ab9c4e3cc4dcf6cccf191d41d4a37953 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Sun, 10 Mar 2019 19:02:26 +0200 Subject: [PATCH] Multiple fixes, Init Topic UI --- app/src/components/NewPost.js | 175 ++++++++++++++++ app/src/components/Post.js | 193 ++++++++++++++++++ app/src/components/PostList.js | 66 ++++++ app/src/components/Topic.js | 3 +- app/src/components/TopicList.js | 16 +- app/src/containers/BoardContainer.js | 23 ++- app/src/containers/NavBarContainer.js | 4 + app/src/containers/TopicContainer.js | 156 ++++++++++++++ .../TransactionsMonitorContainer.js | 5 + app/src/redux/actions/userInterfaceActions.js | 10 + app/src/redux/reducers/rootReducer.js | 4 +- .../redux/reducers/userInterfaceReducer.js | 20 ++ app/src/router/routes.js | 3 + 13 files changed, 661 insertions(+), 17 deletions(-) create mode 100644 app/src/components/NewPost.js create mode 100644 app/src/components/Post.js create mode 100644 app/src/components/PostList.js create mode 100644 app/src/containers/TopicContainer.js create mode 100644 app/src/redux/actions/userInterfaceActions.js create mode 100644 app/src/redux/reducers/userInterfaceReducer.js diff --git a/app/src/components/NewPost.js b/app/src/components/NewPost.js new file mode 100644 index 0000000..59d79bc --- /dev/null +++ b/app/src/components/NewPost.js @@ -0,0 +1,175 @@ +import React, { Component } from 'react'; +import { connect } from 'react-redux'; + +import { Grid, Form, TextArea, Button, Icon, Divider } from 'semantic-ui-react' + +import TimeAgo from 'react-timeago'; +import UserAvatar from 'react-user-avatar'; +import ReactMarkdown from 'react-markdown'; + +/*import { createPost } from '../redux/actions/transactionsMonitorActions';*/ + +class NewPost extends Component { + constructor(props, context) { + super(props); + + this.handleInputChange = this.handleInputChange.bind(this); + this.handlePreviewToggle = this.handlePreviewToggle.bind(this); + this.validateAndPost = this.validateAndPost.bind(this); + + this.newPostOuterRef = React.createRef(); + + this.state = { + postSubjectInput: this.props.subject ? this.props.subject : "", + postContentInput: '', + postSubjectInputEmptySubmit: false, + postContentInputEmptySubmit: false, + previewEnabled: false, + previewDate: "" + }; + } + + async validateAndPost() { + if (this.state.postSubjectInput === '' || this.state.postContentInput === ''){ + this.setState({ + postSubjectInputEmptySubmit: this.state.postSubjectInput === '', + postContentInputEmptySubmit: this.state.postContentInput === '' + }); + return; + } + + /*this.props.store.dispatch( + createPost(this.props.topicID, + { + postSubject: this.state.postSubjectInput, + postMessage: this.state.postContentInput + } + ) + );*/ + this.props.onPostCreated(); + } + + handleInputChange(event) { + this.setState({[event.target.name]: event.target.value}); + } + + handlePreviewToggle() { + this.setState((prevState, props) => ({ + previewEnabled: !prevState.previewEnabled, + previewDate: this.getDate() + })); + } + + getDate() { + const currentdate = new Date(); + return ((currentdate.getMonth() + 1) + " " + + currentdate.getDate() + ", " + + currentdate.getFullYear() + ", " + + currentdate.getHours() + ":" + + currentdate.getMinutes() + ":" + + currentdate.getSeconds()); + } + + render() { + return ( +
+ + #{this.props.postIndex} + + + + + + + +
+
+ {this.props.user.username} + + {this.state.previewEnabled && + + } + +
+
+ + {this.state.previewEnabled && + ("Subject: " + this.state.postSubjectInput) + } + +
+
+
+ +
+
+ +