+
+
-

-
-
-
- {notification.typeNotif}
-
-
-
- {
- messageNotif(notification.typeNotif)
- }
+ { MessageNotif(notification) }
-
);
};
diff --git a/Site Web/client/src/components/Post/NouveauDisplayPosts.js b/Site Web/client/src/components/Post/NouveauDisplayPosts.js
new file mode 100644
index 00000000..a95c213d
--- /dev/null
+++ b/Site Web/client/src/components/Post/NouveauDisplayPosts.js
@@ -0,0 +1,45 @@
+import React, { useEffect, useState } from 'react';
+import { useDispatch, useSelector } from 'react-redux';
+import { getPosts } from '../../actions/post.actions';
+import { isEmpty } from "../Utils";
+import Post from './PostNouvelleAffichage';
+
+const NouveauDisplayPosts = () => {
+ const [loadPost, setLoadPost] = useState(true);
+ const [count , setCount] = useState(5);
+ const dispatch = useDispatch();
+ const postsData = useSelector((state) => state.post.post);
+
+ const loadMore = () => {
+ if (window.innerHeight + document.documentElement.scrollTop + 1 > document.scrollingElement.scrollHeight){
+ setLoadPost(true);
+ }
+ }
+
+ useEffect(() => {
+ if (loadPost) {
+ dispatch(getPosts(count));
+ setLoadPost(false);
+ setCount(count + 5);
+ }
+ window.addEventListener('scroll', loadMore);
+ return () => window.removeEventListener('scroll',loadMore);
+ }, [loadPost,dispatch,count])
+
+ if (!loadPost) {
+ return
Loading...
;
+ }
+
+ return (
+
+
+ {!isEmpty(postsData[0]) &&
+ postsData.map((post) => {
+ return
+ })}
+
+
+ );
+};
+
+export default NouveauDisplayPosts;
\ No newline at end of file
diff --git a/Site Web/client/src/components/Post/Post.js b/Site Web/client/src/components/Post/Post.js
index c0899def..143ed619 100644
--- a/Site Web/client/src/components/Post/Post.js
+++ b/Site Web/client/src/components/Post/Post.js
@@ -6,6 +6,7 @@ import { dateParser, isEmpty } from '../Utils';
import ButtonLike from './ButtonLike';
import Comment from './Comment';
import Commentaire from '../../assets/img/commentaire.png';
+import MiniProfil from "../MiniProfil";
const LinkPreview = ({ link }) => {
const [preview, setPreview] = useState({ image: '', title: '', description: '' });
@@ -63,24 +64,8 @@ const Post = ( { post } ) => {
-

{
- if (user._id === post.postedId) return user.picture;
- else return null;
- }).join('')
- }/>
-
- {
- !isEmpty(usersData[0]) &&
- usersData.map((user) => {
- if(user._id === post.postedId) return user.pseudo;
- else return null;
- }).join('')
- }
-
- {post.postedId !== userData._id &&
- (
)}
+
+ {post.postedId !== userData._id && ()}
{dateParser(post.createdAt)}
diff --git a/Site Web/client/src/components/Routes/index.js b/Site Web/client/src/components/Routes/index.js
index 581b316a..254b0168 100644
--- a/Site Web/client/src/components/Routes/index.js
+++ b/Site Web/client/src/components/Routes/index.js
@@ -18,7 +18,7 @@ const index = () => {
} />
} />
{/* } /> */}
- } />
+ } />
}/>
diff --git a/Site Web/client/src/pages/Profil.js b/Site Web/client/src/pages/Profil.js
index 1bd20af5..ac383372 100644
--- a/Site Web/client/src/pages/Profil.js
+++ b/Site Web/client/src/pages/Profil.js
@@ -1,25 +1,36 @@
-import {React, useState} from 'react';
+import React,{useEffect, useState} from 'react';
+
import { useDispatch, useSelector } from 'react-redux';
+import { useParams } from 'react-router-dom'
import Navbar from '../components/Navbar';
-import { dateParser } from '../components/Utils';
+import {dateParser, isEmpty} from '../components/Utils';
import FollowHandler from '../components/UserProfil/FollowHandler';
-import LesPostPersonnels from '../components/UserProfil/NavigationProfil/PostsPersonnels';
-import LesDossierPersonnels from '../components/UserProfil/NavigationProfil/DossiersPersonnels';
-import LesPostsLikes from '../components/UserProfil/NavigationProfil/PostsLikes';
+import PostPersonnels from '../components/UserProfil/NavigationProfil/PostsPersonnels';
+import DossierPersonnels from '../components/UserProfil/NavigationProfil/DossiersPersonnels';
+import PostsLikes from '../components/UserProfil/NavigationProfil/PostsLikes';
+import MiniProfil from "../components/MiniProfil";
const Profil = () => {
- const userData = useSelector((state) => state.user.user);
- const usersData = useSelector((state) => state.users.users);
- const dispatch = useDispatch();
- const [followingPopup, setFollowingPopup] = useState(false);
- const [followerPopup, setFollowerPopup] = useState(false);
+ const { uid } = useParams();
+ const [userData, setUserData] = useState(null);
+
+ useEffect(() => {
+ async function fetchData() {
+ const response = await fetch(`${process.env.REACT_APP_API_URL}api/user/${uid}`);
+ const data = await response.json();
+ setUserData(data);
+ }
+ fetchData();
+ }, [uid]);
- const [dossierPersonnel,setdossierPersonnels ] = useState(true);
- const [postPersonnel,setpostPersonnels ] = useState(false);
- const [postLike,setpostLikes ] =useState(false);
+ const [followingPopup, setFollowingPopup] = useState(false);
+ const [followerPopup, setFollowerPopup] = useState(false);
+ const [dossierPersonnels,setdossierPersonnels ] = useState(false);
+ const [postPersonnels,setpostPersonnels ] = useState(true);
+ const [postLikes,setpostLikes ] = useState(false)
- const handleModalsProfil = (e) => {
+ const handleModals = (e) => {
if (e.target.id === "DossierPersonnels") {
setdossierPersonnels(true);
setpostPersonnels(false);
@@ -33,37 +44,39 @@ const Profil = () => {
setpostPersonnels(false);
setpostLikes(true);
}
- };
-
+ };
+ if (!userData) {
+ return Loading...
;
+ }
return (
<>
{/*
-
Compte créé le : {dateParser(userData.createdAt)}
+
Compte créé le : {dateParser(userData.createdAt)}
{userData.pseudo}
-
@{userData.pseudo}
+
@{userData.pseudo}
-
setFollowingPopup(true)} className="bloc-aboonnements-abonner">
-
{userData.following.length}
-
Abonnement
+
setFollowingPopup(true)} classNameName="bloc-aboonnements-abonner">
+
{userData.following.length}
+
Abonnement
-
setFollowerPopup(true)} className="bloc-aboonnements-abonner">
-
{userData.followers.length}
-
Abonnée
+
setFollowerPopup(true)} classNameName="bloc-aboonnements-abonner">
+
{userData.followers.length}
+
Abonnée
{followingPopup && (
-
-
+
+
Abonnements
-
setFollowingPopup(false)}>
+ setFollowingPopup(false)}>
✕
@@ -74,7 +87,7 @@ const Profil = () => {
-
{user.pseudo}
-
+
@@ -88,10 +101,10 @@ const Profil = () => {
)}
{followerPopup && (
-
-
+
+
Abonnés
-
setFollowerPopup(false)}>
+ setFollowerPopup(false)}>
✕
@@ -102,7 +115,7 @@ const Profil = () => {
-
{user.pseudo}
-
+
@@ -125,24 +138,24 @@ const Profil = () => {
-
-

+
+
-
-
{userData.pseudo}
+
+
{userData.pseudo}
{/* suuu
*/}
-
-
Suivre +
+
-
-
setFollowingPopup(true)}>
+
+
setFollowingPopup(true)}>
{userData.following.length}
- Abonnements
+ Abonnements
-
setFollowerPopup(true)}>
+
setFollowerPopup(true)}>
{userData.followers.length}
- Abonnés
+ Abonnés
{followingPopup && (
@@ -153,50 +166,42 @@ const Profil = () => {
✕
- {usersData.map((user) => {
- for (let i = 0; i < userData.following.length; i++) {
- if (user._id === userData.following[i]) {
- return (
- -
-
- {user.pseudo}
-
-
-
-
- );
- }
+ {
+ userData.following.map((follower, i) => {
+ return (
+ -
+
+
+
+
+
+ )
+ })
}
- return null;
- })}
- )}
+ )}
{followerPopup && (
-
-
+
+
Abonnés
-
setFollowerPopup(false)}>
+ setFollowerPopup(false)}>
✕
- {usersData.map((user) => {
- for (let i = 0; i < userData.followers.length; i++) {
- if (user._id === userData.followers[i]) {
- return (
- -
-
- {user.pseudo}
-
-
-
-
- );
- }
+ {
+ userData.followers.map((follower, i) => {
+ return (
+ -
+
+
+
+
+
+ )
+ })
}
- return null;
- })}
@@ -204,54 +209,55 @@ const Profil = () => {
-
-
-
-