edition commanataire
continuous-integration/drone/push Build encountered an error Details

master
Bastien OLLIER 2 years ago
parent d04eb1f126
commit 7f5a9ba841

@ -7,7 +7,8 @@ import { UidContext } from '../AppContext';
const ActionComment = ( { commentaire , postId}) => {
const [createur, setCreateur] = useState(false);
const [edit, setEdit] = useState(false);
const [message,setMessage] = useState('');
const [message,setMessage] = useState(commentaire.text);
const uid = useContext(UidContext);
const dispatch = useDispatch();
@ -15,13 +16,14 @@ const ActionComment = ( { commentaire , postId}) => {
e.preventDefault();
if(message){
dispatch(editComment(postId, commentaire._id, message));
setMessage('');
setEdit(false);
}
};
const handleDelete = () => {
dispatch(deleteComment(postId, commentaire._id));
setMessage('commantaire suprimer');
setEdit(false);
};
useEffect(() => {
@ -36,6 +38,9 @@ const ActionComment = ( { commentaire , postId}) => {
}, [uid, commentaire.commenterId]);
return (
<>
<p>{message}</p>
<div className="edit-comment">
{createur && edit === false && (
<span onClick={() => setEdit(!edit)}>
@ -66,6 +71,7 @@ const ActionComment = ( { commentaire , postId}) => {
)}
</div>
</>
);
};

@ -50,7 +50,6 @@ const Comment = ({ post }) => {
<span>{timestampParser(comment.timestamp)}</span>
</div>
<div className="content-com">
<p>{comment.text}</p>
<ActionComment commentaire={comment} postId={post._id} />
</div>

Loading…
Cancel
Save