Rev 7386 | AutorÃa | Ultima modificación | Ver Log |
import React, { useState } from 'react'import CommentTemplate from './CommentTemplate'const CommentSection = ({ owner_url, owner_image, comments, comments_link_add }) => {const [commentState, setCommentState] = useState(comments)const handleSubmit = (e) => {e.preventDefault()axios.post(comments_link_add).then(({ data }) => {if (!data.success) {return console.log("Error de envio")}setCommentState([...commentState, data.data])}).catch((err) => console.log(err))}return (<><div className="d-flex mb-3"><div className="avatar avatar-xs me-2"><a href={owner_url}><imgclassName="avatar-img rounded-circle"src={owner_image}alt="user avatar image"/></a></div><form className="w-100" onSubmit={(e) => handleSubmit(e)}><inputclassName="form-control pe-4 bg-light"type='text'placeholder="Escribe un comentario"value={commentState}onChange={(e) => setCommentState(e.target.value)}/></form></div><ul className="comment-wrap list-unstyled">{commentState.map((comment) =><li className="comment-item"><CommentTemplatekey={comment.unique}feed_comment={comment}/></li>)}</ul></>)}export default CommentSection