-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathCommentItem.js
More file actions
55 lines (51 loc) · 1.23 KB
/
CommentItem.js
File metadata and controls
55 lines (51 loc) · 1.23 KB
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
47
48
49
50
51
52
53
54
55
import React from 'react';
import PropTypes from 'prop-types';
import Moment from 'react-moment';
import styles from './CommentItem.css';
function CommentItem(props) {
return (
<div
className={`${styles['comment-single']}`}
key={props.data.cuid}
>
<h3>{props.data.name}</h3>
<div
className={`${styles['comment-data']}`}
>
<span
className={`${styles['comment-date']}`}
>
<Moment format="DD.MM.YY HH:mm">
{props.data.date}
</Moment>
</span>
<span
className={`${styles['comment-text']}`}
>
{props.data.text}
</span>
<button
className={`${styles['btn-edit']}`}
>
Edit
</button>
<button
className={`${styles['btn-delete']}`}
onClick={() => props.handleDelete(props.data.cuid)}
>
x
</button>
</div>
</div>
);
}
CommentItem.propTypes = {
data: PropTypes.shape({
name: PropTypes.string.isRequired,
text: PropTypes.string.isRequired,
date: PropTypes.string.isRequired,
cuid: PropTypes.string.isRequired,
}),
handleDelete: PropTypes.func.isRequired,
};
export default CommentItem;