-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommentsList.js
68 lines (60 loc) · 1.82 KB
/
CommentsList.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React, { useState } from "react";
import MyVerticallyCenteredModal from "./MyVerticallyCenteredModal";
const CommentsList = ({ comments }) => {
const [modalShow, setModalShow] = useState(false);
const [modalInputComment, setModalInputComment] = useState("");
//const [username,setUsername] = useState('');
//console.log(comments);
const handleCloseModal = () => {
setModalShow(false);
};
const handleCommentChange = (event) => {
setModalInputComment(event.target.value);
};
const updateComment = async () => {
//console.handleCommentChange("update");
// const res = await fetch(`/api/articles/${articleName}/update-comment`,{
// method:'put',
// body:JSON.stringify({text:commentText}),
// headers: {
// 'Content-Type':'application/json',
// }
// })
// const body = await res.json();
// setArticleInfo(body);
// setCommentText('');
// handleCloseModal();
};
return (
<>
<div>
{comments.map((item, key) => (
<div className="comment" key={key}>
<h4>{item.username}</h4>
<p>{item.text}</p>
{/* <Button
variant="outline-primary btn-sm mx-3"
onClick={() => handleShowModal()}
>
Update
</Button> */}
{/* <Button
variant="outline-danger btn-sm"
onClick={deleteComment(key)}
>
Delete
</Button> */}
</div>
))}
<MyVerticallyCenteredModal
show={modalShow}
modalInputComment={modalInputComment}
handleCommentChange={handleCommentChange}
handleCloseModal={handleCloseModal}
updateComment={updateComment}
/>
</div>
</>
);
};
export default CommentsList;