Darius BERTRAND 2 years ago
commit e9d0a05382

@ -7,7 +7,8 @@ import { UidContext } from '../AppContext';
const ActionComment = ( { commentaire , postId}) => { const ActionComment = ( { commentaire , postId}) => {
const [createur, setCreateur] = useState(false); const [createur, setCreateur] = useState(false);
const [edit, setEdit] = useState(false); const [edit, setEdit] = useState(false);
const [message,setMessage] = useState(''); const [message,setMessage] = useState(commentaire.text);
const uid = useContext(UidContext); const uid = useContext(UidContext);
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -15,13 +16,14 @@ const ActionComment = ( { commentaire , postId}) => {
e.preventDefault(); e.preventDefault();
if(message){ if(message){
dispatch(editComment(postId, commentaire._id, message)); dispatch(editComment(postId, commentaire._id, message));
setMessage('');
setEdit(false); setEdit(false);
} }
}; };
const handleDelete = () => { const handleDelete = () => {
dispatch(deleteComment(postId, commentaire._id)); dispatch(deleteComment(postId, commentaire._id));
setMessage('commantaire suprimer');
setEdit(false);
}; };
useEffect(() => { useEffect(() => {
@ -36,6 +38,9 @@ const ActionComment = ( { commentaire , postId}) => {
}, [uid, commentaire.commenterId]); }, [uid, commentaire.commenterId]);
return ( return (
<>
<p>{message}</p>
<div className="edit-comment"> <div className="edit-comment">
{createur && edit === false && ( {createur && edit === false && (
<span onClick={() => setEdit(!edit)}> <span onClick={() => setEdit(!edit)}>
@ -47,14 +52,14 @@ const ActionComment = ( { commentaire , postId}) => {
className="edit-comment-form"> className="edit-comment-form">
<div className="top-edit-com"> <div className="top-edit-com">
<label htmlFor='text' onClick={() => setEdit(!edit)}>Annuler</label> <label htmlFor='text' onClick={() => setEdit(!edit)}>Annuler</label>
<div className="btn"> <div className="btn">
<span onClick={() => { <span onClick={() => {
if(window.confirm("Etes-vous sur de supprimer ce commentaire ?")){ if(window.confirm("Etes-vous sur de supprimer ce commentaire ?")){
handleDelete(); handleDelete();
} }
}}> }}>
<i className="fas fa-trash-alt"></i> <i className="fas fa-trash-alt"></i>
</span> </span>
</div> </div>
</div> </div>
@ -66,6 +71,7 @@ const ActionComment = ( { commentaire , postId}) => {
)} )}
</div> </div>
</>
); );
}; };

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

@ -46,7 +46,12 @@ const PostNouvelleAffichage = ( { post } ) => {
useEffect(() => { useEffect(() => {
!isEmpty(usersData[0]) && setIsLoading(false) try {
!isEmpty(usersData[0]) && setIsLoading(false)
}
catch (error){
}
}) })

@ -66,18 +66,19 @@ const SuggestFriends = () => {
} }
}, [userData, usersData, change]) }, [userData, usersData, change])
return ( try {
return (
<div className="recoDiv"> <div className="recoDiv">
<div className="reco"> <div className="reco">
<span>Vous pourriez suivre</span> <span>Vous pourriez suivre</span>
<hr/> <hr/>
{chargement ? ( {chargement ? (
<i className='fas fa-spinner fa-pulse'></i> <i className='fas fa-spinner fa-pulse'></i>
) : ( ) : (
<div className="ListReco" > <div className="ListReco">
{friends && friends.map((user) => { {friends && friends.map((user) => {
for(let i = 0; i < usersData.length; i++){ for (let i = 0; i < usersData.length; i++) {
if(user === usersData[i]._id){ if (user === usersData[i]._id) {
return ( return (
<div className="UtiReco" key={user}> <div className="UtiReco" key={user}>
<div> <div>
@ -96,7 +97,11 @@ const SuggestFriends = () => {
)} )}
</div> </div>
</div> </div>
); );
}
catch (error){
return <div>Loading...</div>
}
}; };
export default SuggestFriends; export default SuggestFriends;
Loading…
Cancel
Save