-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathCommentUser.js
46 lines (40 loc) · 1.6 KB
/
CommentUser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* eslint-disable prefer-template,react/jsx-indent */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { todeleteCommentAPI } from '../CommentActions';
import styles from '../PostComments.css';
import postStyles from '../../PostListItem/PostListItem.css';
export class UserComment extends Component {
// console.log(this.props.comment)
// state = {
// author: '',
// text: '',
// }
toeditComment = () => {
alert('NOT WORKING YET ');
}
render() {
const { author, dateAdded, text, cuid } = this.props.comment;
const commentTime = new Date().getHours() + ':' + new Date().getMinutes() + ':' + new Date().getSeconds();
return (
<div className={`${styles['form-user-comment']}`} key={cuid}>
<div className={`${styles['comment-info']}`}>
<span className={`${styles['comment-author']}`}>{`${author}`}</span>
<span className={`${styles['comment-date']}`}>{`${new Date(dateAdded).toLocaleDateString()} ${commentTime}`}</span>
</div>
<div className={`${styles['comment-content']}`}>
{/* {!this.editComment && <p>{text}</p>}
{this.editComment && <textarea defaultValue={text} />}*/}
<p>{text}</p>
</div>
<p className={postStyles['post-action']}><span onClick={() => this.toeditComment()}>Edit</span><span onClick={() => todeleteCommentAPI(cuid, this.props.dispatch)}>Destroy</span></p>
</div>
);
}
}
UserComment.propTypes = {
comment: PropTypes.object.isRequired,
dispatch: PropTypes.func.isRequired,
};
export default connect()(UserComment);