From 924e2fa10c2058ca18acd403e7bab5876ad52855 Mon Sep 17 00:00:00 2001 From: Noan07 <84435602+Noan07@users.noreply.github.com> Date: Mon, 16 Jan 2023 18:55:05 +0100 Subject: [PATCH] ajout post --- Site Web/client/src/actions/post.actions.js | 17 +- .../Configurations/ConfigurationDuProfil.js | 4 +- .../src/components/Post/ActionComment.js | 22 +-- .../client/src/components/Post/Comment.js | 147 +++++++----------- .../src/components/Post/DisplayPosts.js | 11 +- .../components/UserProfil/SuggestFriends.js | 13 +- Site Web/client/src/pages/Discover.js | 2 +- Site Web/client/src/pages/Home.js | 2 +- Site Web/controllers/post.controller.js | 4 +- 9 files changed, 106 insertions(+), 116 deletions(-) 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 = ()=>{