diff --git a/Site Web/client/src/actions/post.actions.js b/Site Web/client/src/actions/post.actions.js
index 46940b94..e42b12df 100644
--- a/Site Web/client/src/actions/post.actions.js
+++ b/Site Web/client/src/actions/post.actions.js
@@ -7,7 +7,22 @@ export const getPosts = (num) => {
return axios
.get(`${process.env.REACT_APP_API_URL}api/post/`)
.then((res) => {
- const array = res.data.slice(0, num);
+ let array = res.data.slice(0, num);
+ dispatch(setPostData(array));
+ })
+ .catch((err) => console.log(err))
+ }
+}
+
+export const getPostsDisc = (num) => {
+ return (dispatch) => {
+ return axios
+ .get(`${process.env.REACT_APP_API_URL}api/post/`)
+ .then((res) => {
+ console.log("test");
+ let array = res.data.sort((a, b) => b.likers.length - a.likers.length);
+ array = array.slice(0, num);
+ console.log(array);
dispatch(setPostData(array));
})
.catch((err) => console.log(err))
diff --git a/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js b/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js
index 62bc15f3..fe05ce31 100644
--- a/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js
+++ b/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js
@@ -105,7 +105,7 @@ const ConfigurationDuProfil = ()=>{
@@ -119,7 +119,7 @@ const ConfigurationDuProfil = ()=>{
diff --git a/Site Web/client/src/components/Post/ActionComment.js b/Site Web/client/src/components/Post/ActionComment.js
index 5bb8c085..1b22a76c 100644
--- a/Site Web/client/src/components/Post/ActionComment.js
+++ b/Site Web/client/src/components/Post/ActionComment.js
@@ -1,6 +1,6 @@
import React, { useContext, useEffect, useState } from 'react';
import { useDispatch } from 'react-redux';
-import { deleteComment } from '../../actions/post.actions';
+import { deleteComment, editComment } from '../../actions/post.actions';
import { UidContext } from '../AppContext';
@@ -14,46 +14,48 @@ const ActionComment = ( { commentaire , postId}) => {
const handleEdit = (e) => {
e.preventDefault();
if(message){
- //dispatch();
+ dispatch(editComment(postId, commentaire._id, message));
setMessage('');
setEdit(false);
}
};
const handleDelete = () => {
- //dispatch(deleteComment(postId, commentaire._id))
+ dispatch(deleteComment(postId, commentaire._id));
};
useEffect(() => {
const verifCreateur = () => {
- if(uid === commentaire.commenterId){
+ if(uid === commentaire.commentId){
setCreateur(true);
}
}
+ console.log(commentaire);
verifCreateur();
+ console.log(createur);
}, [uid, commentaire.commenterId]);
return (
-
+
{createur && edit === false && (
setEdit(!edit)}>
-
+
)}
{createur && edit && (