diff --git a/Site Web/client/src/actions/user.actions.js b/Site Web/client/src/actions/user.actions.js index c208c591..aa0a1414 100644 --- a/Site Web/client/src/actions/user.actions.js +++ b/Site Web/client/src/actions/user.actions.js @@ -13,20 +13,6 @@ export const getUser = (uid) => { }; }; -export const getNotif = (uid) => { - console.log("loadNotif3"); - - return (dispatch)=> { - return axios - .get(`${process.env.REACT_APP_API_URL}api/user/notif/${uid}`) - .then((res) => { - dispatch(setUserData(res.data)) - }) - .catch((err) => console.log(err)); - }; -}; - - export const uploadPicture = (data, id) => { return (dispatch) => { return axios diff --git a/Site Web/client/src/components/AjoutLien.js b/Site Web/client/src/components/AjoutLien.js index ea76df87..4ef8e33f 100644 --- a/Site Web/client/src/components/AjoutLien.js +++ b/Site Web/client/src/components/AjoutLien.js @@ -19,7 +19,7 @@ const AjoutLien = () => { dispatch(getPosts()); cancelPost(); setDisplayAdd(false); - /*window.location.reload();*/ + window.location.reload(); }else { alert("Veuillez compléter tous les champs.") } @@ -70,7 +70,7 @@ const AjoutLien = () => { } {displayAdd && ( -
+

Ajout d'un lien

setDisplayAdd(false)}> diff --git a/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js b/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js index 7f815912..9f3257e5 100644 --- a/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js +++ b/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js @@ -10,7 +10,6 @@ import { uploadPicture } from '../../actions/user.actions'; const ConfigurationDuProfil = ()=>{ - const userData = useSelector((state) => state.user.user); const [pseudo, setPseudo] = useState(userData.pseudo); const[userPicture, setUserPicture] = useState(userData.picture); diff --git a/Site Web/client/src/components/Configurations/PolitiqueDeConfidentialite.js b/Site Web/client/src/components/Configurations/PolitiqueDeConfidentialite.js index 31f74bff..7831ac8f 100644 --- a/Site Web/client/src/components/Configurations/PolitiqueDeConfidentialite.js +++ b/Site Web/client/src/components/Configurations/PolitiqueDeConfidentialite.js @@ -6,21 +6,19 @@ const PolitiqueDeConfidentialite =()=>{ return(
-

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. Sed dignissim lacinia nunc.

+

La politique de confidentialité de notre réseau social est conçue pour vous informer sur les types d'informations que nous collectons, comment elles sont utilisées et protégées, et les choix que vous pouvez faire en ce qui concerne la collecte, l'utilisation et la divulgation de vos informations.

-

Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.

+

Nous collectons des informations vous concernant lorsque vous utilisez notre réseau social, y compris les informations de compte, les informations de profil, les informations de contenu, les informations de localisation, les informations de connexion et les informations de communication. Nous utilisons ces informations pour fournir et améliorer nos services, personnaliser votre expérience, communiquer avec vous, et pour d'autres fins autorisées par la loi.

-

Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam.

+

Nous ne vendons ni ne partageons vos informations personnelles avec des tiers à des fins commerciales sans votre consentement. Nous pouvons cependant partager des informations avec des partenaires de confiance pour des raisons telles que la fourniture de services, la conformité aux exigences légales, et la protection de nos utilisateurs et de notre réseau social.

-

Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. Sed non quam. In vel mi sit amet augue congue elementum. Morbi in ipsum sit amet pede facilisis laoreet. Donec lacus nunc, viverra nec, blandit vel, egestas et, augue. Vestibulum tincidunt malesuada tellus. Ut ultrices ultrices enim. Curabitur sit amet mauris. Morbi in dui quis est pulvinar ullamcorper. Nulla facilisi. Integer lacinia sollicitudin massa. Cras metus.

+

Vous pouvez contrôler les informations que vous partagez sur notre réseau social en modifiant les paramètres de votre compte. Vous pouvez également choisir de ne pas recevoir de communications marketing de notre part en suivant les instructions de désinscription incluses dans ces communications.

-

Sed aliquet risus a tortor. Integer id quam. Morbi mi. Quisque nisl felis, venenatis tristique, dignissim in, ultrices sit amet, augue. Proin sodales libero eget ante. Nulla quam. Aenean laoreet. Vestibulum nisi lectus, commodo ac, facilisis ac, ultricies eu, pede. Ut orci risus, accumsan porttitor, cursus quis, aliquet eget, justo. Sed pretium blandit orci. Ut eu diam at pede suscipit sodales. Aenean lectus elit, fermentum non, convallis id, sagittis at, neque.

+

Nous prenons des mesures pour protéger vos informations contre l'accès non autorisé, l'utilisation, la modification, la divulgation ou la destruction. Ces mesures comprennent des contrôles physiques, électroniques et administratifs pour protéger les informations stockées sur nos systèmes.

-

Nullam mauris orci, aliquet et, iaculis et, viverra vitae, ligula. Nulla ut felis in purus aliquam imperdiet. Maecenas aliquet mollis lectus. Vivamus consectetuer risus et tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum.

+

Si vous avez des questions ou des préoccupations concernant notre politique de confidentialité, veuillez nous contacter à l'adresse e-mail indiquée sur notre site web. Nous nous réservons le droit de modifier cette politique de temps à autre et vous invite à consulter régulièrement cette page pour rester informé de tout changement.

-

Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor.

- -

Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti.

+

En utilisant notre réseau social, vous acceptez les termes de cette politique de confidentialité.

) diff --git a/Site Web/client/src/components/Log/Inscription.js b/Site Web/client/src/components/Log/Inscription.js index 9712e195..71d8bac0 100644 --- a/Site Web/client/src/components/Log/Inscription.js +++ b/Site Web/client/src/components/Log/Inscription.js @@ -9,6 +9,7 @@ const Inscription = () => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [controlPassword, setControlPassword] = useState(''); + const handleRegister = async (e) => { e.preventDefault(); diff --git a/Site Web/client/src/components/Log/SuivreAussi.css b/Site Web/client/src/components/Log/SuivreAussi.css deleted file mode 100644 index 161590cc..00000000 --- a/Site Web/client/src/components/Log/SuivreAussi.css +++ /dev/null @@ -1,33 +0,0 @@ -#suivreAussi{ - font-size: 8px; - text-align: center; - border: 2px solid; - border-radius: 30px; - width: 200px; -} - -#listeCompteASuivre{ - border-top: 2px solid; - -} - -.infoPersonne{ - display: flex; -} - -.name{ - font-size: 12px; -} - -.arobase{ - color:gray; -} - -.PhotoProfile{ - margin: 10px 15px 0px 20px; - width: 40px; - height:40px; - border-radius: 20px; - border: 2px solid #555; -} - diff --git a/Site Web/client/src/components/Log/SuivreAussi.html b/Site Web/client/src/components/Log/SuivreAussi.html deleted file mode 100644 index 893538a3..00000000 --- a/Site Web/client/src/components/Log/SuivreAussi.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - Ma page de test - - - -
-

Suivre aussi

-
-
- -
-

personne 1

-

@personne1

-
-
-
- -
-

personne 1

-

@personne1

-
-
-
- -
-

personne 1

-

@personne1

-
-
-
-
- - diff --git a/Site Web/client/src/components/Log/coeurs.png b/Site Web/client/src/components/Log/coeurs.png deleted file mode 100644 index 7f184cd7..00000000 Binary files a/Site Web/client/src/components/Log/coeurs.png and /dev/null differ diff --git a/Site Web/client/src/components/Log/coeursPlein.png b/Site Web/client/src/components/Log/coeursPlein.png deleted file mode 100644 index 463c75df..00000000 Binary files a/Site Web/client/src/components/Log/coeursPlein.png and /dev/null differ diff --git a/Site Web/client/src/components/Log/commentaire.png b/Site Web/client/src/components/Log/commentaire.png deleted file mode 100644 index 8a9619de..00000000 Binary files a/Site Web/client/src/components/Log/commentaire.png and /dev/null differ diff --git a/Site Web/client/src/components/Log/likeEtCommantaire.html b/Site Web/client/src/components/Log/likeEtCommantaire.html deleted file mode 100644 index bb623be3..00000000 --- a/Site Web/client/src/components/Log/likeEtCommantaire.html +++ /dev/null @@ -1,165 +0,0 @@ - - - - Titre du document - - - -
-
- -
-
-
- -
-
- -
-

personne 1

-

@personne1

-
-
-
- -
-

personne 1

-

@personne1

-
-
-
- -
-

personne 1

-

@personne1

-
-
-
-
-
- -
-

personne 1

-

@personne1

-

texte du commantaire

-
-
-
- -
-

personne 1

-

@personne1

-

texte du commantaire

-
-
-
- -
-

personne 1

-

@personne1

-

texte du commantaire

-
-
-
-
- - - - - diff --git a/Site Web/client/src/components/Log/newPoste.html b/Site Web/client/src/components/Log/newPoste.html deleted file mode 100644 index b009eff7..00000000 --- a/Site Web/client/src/components/Log/newPoste.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - Titre du document - - - -

Forme Popup

-

Cliquez sur le bouton "Ouvrir la forme" pour ouvrir la fdbjfndbfhbdbnfhdbfnbdhbfhbdhbfhdbfhdhbfhdbhfforme Popup.

- - -
- -
- - -
-
-
- -
- - -
- -
- - -
- -
-
- -
-
- -
-
- - -
-
-
- - - - - diff --git a/Site Web/client/src/components/Log/pagePerso.css b/Site Web/client/src/components/Log/pagePerso.css deleted file mode 100644 index d81c4d85..00000000 --- a/Site Web/client/src/components/Log/pagePerso.css +++ /dev/null @@ -1,32 +0,0 @@ -#PhotoProfile{ - display: block; - margin-left: auto; - margin-right: auto; - width: 150px; - height:150px; - border-radius: 80px; - border: 2px solid #555; -} - -#blocAbonnement{ - display: flex; - justify-content: center; - - -} -#blocAbonnement div{ - margin-left: 80px; - margin-right: 80px; -} - -#blocName{ - text-align: center; -} - -.nombre{ - color:black; -} - -.texteNombre{ - color:grey; -} diff --git a/Site Web/client/src/components/Log/pagePerso.html b/Site Web/client/src/components/Log/pagePerso.html deleted file mode 100644 index 2889bf3a..00000000 --- a/Site Web/client/src/components/Log/pagePerso.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - Ma page de test - - - -
- -
-
-

Lena 1er

-

@Lena1er

-
-
-
-
10k
-
Abonnement
-
-
-
10k
-
Abonnée
-
-
- - - diff --git a/Site Web/client/src/components/Log/poste.css b/Site Web/client/src/components/Log/poste.css deleted file mode 100644 index d347bf4d..00000000 --- a/Site Web/client/src/components/Log/poste.css +++ /dev/null @@ -1,74 +0,0 @@ -body{ -background: green; - -} - -#cadrePoste{ - background: white; - border-radius: 5px; - width: 40%; - margin-left: auto; - margin-right: auto; -} - -/*haut du poste*/ -/* -#cadreInfoPoste{ - display: flex; - align-items:center; - -} - -#PhotoProfile{ - margin: 10px 15px 0px 20px; - width: 40px; - height:40px; - border-radius: 20px; - border: 2px solid #555; -} - -#NomProfile{ - font-family: arial; - font-size: 18px; - -}*/ - -#hautPoste{ - display: flex; - align-items:center; - justify-content: space-between; - margin-right: 15px; -} - -#cadreInfoPoste{ - display: flex; - align-items:center; - -} -#PhotoProfile{ - margin: 10px 15px 0px 20px; - width: 40px; - height:40px; - border-radius: 20px; - border: 2px solid #555; -} - -#NomProfile{ - font-family: arial; - font-size: 18px; - -} - -/*bas poste*/ -#basPoste{ - display: flex; - align-items:center; - justify-content: space-between; - margin-left: 10px; - margin-right: 10px; -} - -#like, #commentaire{ - display: flex; - align-items:center; -} diff --git a/Site Web/client/src/components/Log/poste.html b/Site Web/client/src/components/Log/poste.html deleted file mode 100644 index 2fe8009f..00000000 --- a/Site Web/client/src/components/Log/poste.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - Ma page de test - - - - - -
-
-
- -
Lena 1er
-
-
6 jours
-
- -
- /*utliser leakpreview*/ -
- -
-
- -
10k
-
-
- -
10k
-
-
-
- - - - diff --git a/Site Web/client/src/components/MiniProfil.js b/Site Web/client/src/components/MiniProfil.js new file mode 100644 index 00000000..47776f58 --- /dev/null +++ b/Site Web/client/src/components/MiniProfil.js @@ -0,0 +1,37 @@ +import React, {useEffect,useState} from 'react'; +import {useDispatch, useSelector} from "react-redux"; +import {getPosts} from "../actions/post.actions"; +import {getUserTemp} from "../actions/user.actions"; +import {useParams} from "react-router-dom"; +import {isEmpty} from "./Utils"; +import FollowHandler from "./UserProfil/FollowHandler"; + +const MiniProfil = ({uid} ) => { + 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]); + + if (!userData) { + return

Loading...

; + } + + + + return ( +
+ +
+ ); +}; + +export default MiniProfil; diff --git a/Site Web/client/src/components/Navbar.js b/Site Web/client/src/components/Navbar.js index 90ece44f..d5a4eae0 100644 --- a/Site Web/client/src/components/Navbar.js +++ b/Site Web/client/src/components/Navbar.js @@ -23,7 +23,7 @@ const Navbar = () => { data.append('postedId', userData._id); data.append('message', description); data.append('lien', lien); - console.log(data); + //console.log("test",data); putData(data); console.log(data); cancelPost(); @@ -78,7 +78,6 @@ const Navbar = () => { window.location = "/"; } - return (
{uid ? ( @@ -110,11 +109,17 @@ const Navbar = () => {
  • - + Me
  • +
  • + + + Recherche + +
  • diff --git a/Site Web/client/src/components/Notif.js b/Site Web/client/src/components/Notif.js index 52316d9f..8616aede 100644 --- a/Site Web/client/src/components/Notif.js +++ b/Site Web/client/src/components/Notif.js @@ -1,30 +1,30 @@ -import React from 'react'; -import {isEmpty} from "./Utils"; +import React, {useEffect,useState} from 'react'; +import {useDispatch, useSelector} from "react-redux"; +import {getPosts} from "../actions/post.actions"; +import {getUserTemp} from "../actions/user.actions"; +import MiniProfil from "./MiniProfil"; -const Notif = ({notification} ) => { - const messageNotif = (typeNotif) =>{ - if(typeNotif == 'like') { - return "a like"; +const Notif = ({notification} ) => { + console.log('notification',notification) + + + const MessageNotif = (notification) =>{ + if(notification.typeNotif == 'like') { + return "a like votre post"; } - return 'a commenter' + else if(notification.typeNotif == 'commente') { + return "a commenter votre post"; + } + return 'vous follow' } + return ( -
    +
    +
    - -
    -
    -
    - {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 2d30b656..254b0168 100644 --- a/Site Web/client/src/components/Routes/index.js +++ b/Site Web/client/src/components/Routes/index.js @@ -6,6 +6,7 @@ import Trends from '../../pages/Trends.js'; import Discover from '../../pages/Discover.js'; import Profil from '../../pages/Profil.js'; import Configuration from '../../pages/Configuration.js'; +import SearchBar from '../../pages/SearchBar.js'; const index = () => { return ( @@ -15,8 +16,9 @@ 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)}

    Profil

    {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-pic

      {user.pseudo}

      -
      +
    • @@ -88,10 +101,10 @@ const Profil = () => {
    )} {followerPopup && ( -
    -
    +
    +

    Abonnés

    - setFollowerPopup(false)}> + setFollowerPopup(false)}> ✕
      @@ -102,7 +115,7 @@ const Profil = () => {
    • user-pic

      {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-pic -

        {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-pic -

        {user.pseudo}

        -
        - -
        -
      • - ); - } + { + userData.followers.map((follower, i) => { + return ( +
      • + +
        + +
        +
      • + ) + }) } - return null; - })}
      @@ -204,54 +209,55 @@ const Profil = () => {
      - - -
      -
      + + +
      +
      - -
      -
      +
      +
      Vous pourriez suivre
      -
      -
      - +
      +
      + UtiT - Suivre + Suivre
      -
      - +
      + UtiT - Suivre + Suivre
      -
      - +
      + UtiT - Suivre + Suivre
      diff --git a/Site Web/client/src/pages/SearchBar.js b/Site Web/client/src/pages/SearchBar.js new file mode 100644 index 00000000..fbfa09b2 --- /dev/null +++ b/Site Web/client/src/pages/SearchBar.js @@ -0,0 +1,83 @@ +import React, { useState } from 'react'; +import { useSelector } from 'react-redux'; +import Navbar from '../components/Navbar'; + +const SearchBar = () => { + const [searchValue, setSearchValue] = useState(""); + const [searchUsers, setSearchUsers] = useState(true); + const [searchPosts, setSearchPosts] = useState(false); + const [searchResults, setSearchResults] = useState([]); + const postsData = useSelector((state) => state.post.post); + const usersData = useSelector((state) => state.users.users); + + function handleSearch() { + const input = searchValue.toLowerCase(); + console.log("Recherche pour : " + input); + + const filteredResultsUsers = usersData.filter(function(item) { + return item.pseudo.toLowerCase().indexOf(input) !== -1; + }); + + const filteredResultsPosts = postsData.filter(function(item) { + return item.message.toLowerCase().indexOf(input) !== -1; + }); + + if(searchUsers) + setSearchResults(filteredResultsUsers); + + if(searchPosts) + setSearchResults(filteredResultsPosts); + + console.log(searchResults); + } + + const handleModals = (e) => { + if (e.target.id === "Users") { + setSearchUsers(true); + setSearchPosts(false); + } else { + setSearchPosts(true); + setSearchUsers(false); + } + }; + + return ( +
      + +
      +
      + setSearchValue(e.target.value)} placeholder="Rechercher..." /> + +
      +
      + +
      + { searchUsers && +
        + {searchResults.map((result) => ( +
      • {result.pseudo}
      • + ))} +
      + } + { searchPosts && +
        + {searchResults.map((result) => ( +
      • {result.message}
      • + ))} +
      + } +
      +
      + ); +}; + +export default SearchBar; \ No newline at end of file diff --git a/Site Web/client/src/pages/Trends.js b/Site Web/client/src/pages/Trends.js index 1d3ca6c4..0ae4975a 100644 --- a/Site Web/client/src/pages/Trends.js +++ b/Site Web/client/src/pages/Trends.js @@ -1,80 +1,29 @@ -import React, {useEffect, useState} from 'react'; +import React, {useState} from 'react'; import Navbar from '../components/Navbar'; import Notif from '../components/Notif'; -import {useDispatch, useSelector} from "react-redux"; -import {getNotif, getUser} from '../actions/user.actions'; -import {isEmpty} from "../components/Utils"; -import axios from "axios"; -import FollowHandler from "../components/UserProfil/FollowHandler"; -import Post from "../components/Post/Post"; +import {useSelector} from "react-redux"; const Trends = () => { - console.log('test'); - const [loadNotif, setLoadNotif] = useState(true); - const [count , setCount] = useState(5); - const dispatch = useDispatch(); - + const [setLoadNotif] = useState(true); const userData = useSelector((state) => state.user.user); - const usersData = useSelector((state) => state.users.users); - - const loadMore = () => { - if (window.innerHeight + document.documentElement.scrollTop + 1 > document.scrollingElement.scrollHeight){ - setLoadNotif(true); - } - } - - console.log("userData",userData,userData.notif, userData.notif.length); return (

      Notification

      - { /*userData.notif.length ? userData.notif.filter(notif => notif._id === userData.notif._id).map((notif) => ) - :

      Aucune Notification

      */ - + { userData.notif != null && userData.notif.map((notif) => { - return + return ( +
    • + +
    • + ); }) }
      ); - - - /* - return ( -
      - -

      Notification

      - { - return(

      Aucune Notification

      ); - userData.notif.map((notif) => { - for (let i = 0; i < userData.notif.length; i++) { - if (notif._id === userData.notif[i]) { - return ( - - - ); - } - } - return

      Aucune Notification

      ; - }) - } -
      - );*/ - - // return ( - //
      - // - //

      Notification

      - // - // - // - // - // - // - //
      ); }; export default Trends; \ No newline at end of file diff --git a/Site Web/controllers/auth.controller.js b/Site Web/controllers/auth.controller.js index 84d34716..4ca43ba5 100644 --- a/Site Web/controllers/auth.controller.js +++ b/Site Web/controllers/auth.controller.js @@ -1,7 +1,7 @@ const UserModel = require('../models/user.model'); const jwt = require('jsonwebtoken'); const { signUpErrors, signInErrors } = require('../utils/errors.utils'); - +//const nodemailer = require('nodemailer'); const maxAge = 3 * 24 * 60 * 60 * 1000; //expiresIn temps avant l'expiration du token @@ -12,6 +12,63 @@ const createToken = (id) => { } +// // Définir les informations de connexion pour le service d'envoi d'e-mails +// const transporter = nodemailer.createTransport({ +// service: 'gmail', +// auth: { +// user: 'mixmox07340@gmail.com', +// pass: 'Appwow07' +// } +// }); + +// module.exports.signUp = async (req, res) => { +// console.log(req.body); + +// const {pseudo, email, password} = req.body + +// try { +// const user = await UserModel.create({pseudo, email, password}); +// // Générer un jeton de vérification +// const verificationToken = jwt.sign({ email }, 'secret-key', { expiresIn: '24h' }); +// // Préparer l'e-mail de vérification +// const mailOptions = { +// from: 'your-email@gmail.com', +// to: email, +// subject: 'Vérifiez votre adresse e-mail', +// html: ` +//

      Veuillez cliquer sur le lien ci-dessous pour vérifier votre adresse e-mail :

      +// Cliquez ici pour vérifier +// ` +// }; +// // Envoyer l'e-mail de vérification +// await transporter.sendMail(mailOptions); +// // Stocker le jeton de vérification associé à l'utilisateur dans la base de données +// await UserModel.updateOne({ _id: user._id }, { verificationToken }); +// res.status(200).json({ user: user._id}); +// } +// catch(err) { +// const errors = signUpErrors(err); +// res.status(200).send({ errors }) +// } +// } + +// module.exports.verifyEmail = async (req, res) => { +// const { email, token } = req.body; +// try { +// // Vérifier le jeton de vérification +// jwt.verify(token, 'secret-key', async (err, decoded) => { +// if (err) { +// return res.status(401).json({ error: 'Jeton de vérification non valide' }); +// } +// if (decoded.email){ + +// } +// }) +// }catch(err){ + +// } +// }; + //gestion des erreurs module.exports.signUp = async (req, res) => { console.log(req.body); @@ -22,7 +79,7 @@ module.exports.signUp = async (req, res) => { try { const user = await UserModel.create({pseudo, email, password}); - res.status(201).json({ user: user._id}); + res.status(200).json({ user: user._id}); } catch(err) { const errors = signUpErrors(err); diff --git a/Site Web/controllers/post.controller.js b/Site Web/controllers/post.controller.js index aeb07920..03d83b30 100644 --- a/Site Web/controllers/post.controller.js +++ b/Site Web/controllers/post.controller.js @@ -165,7 +165,9 @@ module.exports.unlikePost = async (req, res) => { // } // }; -module.exports.commentPost = (req, res) => { +module.exports.commentPost = async (req, res) => { + const idUser = await PostModel.findOne({ _id: ObjectID( req.params.id) }); + if (!ObjectID.isValid(req.params.id)) return res.status(400).send("ID unknown : " + req.params.id); @@ -183,7 +185,14 @@ module.exports.commentPost = (req, res) => { }, }, { new: true }) - .then((data) => res.send(data)) + .then((data) => { + addNotification.addNotification(idUser.postedId, { + typeNotif: "commente", + id_user: req.body.commenterId, + id_post1: req.params.id, + id_post2: data.comments.slice(-1)[0]._id + }); + res.send(data);}) .catch((err) => res.status(500).send({ message: err })); } catch (err) { return res.status(400).send(err); diff --git a/Site Web/controllers/user.controller.js b/Site Web/controllers/user.controller.js index ae9ed671..ee192b5c 100644 --- a/Site Web/controllers/user.controller.js +++ b/Site Web/controllers/user.controller.js @@ -8,9 +8,7 @@ module.exports.getAllUsers = async (req, res) => { }; module.exports.getNotif = async (req, res) => { - const users = await UserModel.find().select("-password"); - console.log('api get notif',users); res.status(200).json(users); }; @@ -18,10 +16,15 @@ module.exports.getNotif = async (req, res) => { module.exports.userInfo = (req, res) => { if (!ObjectID.isValid(req.params.id)) return res.status(400).send("ID unknown : " + req.params.id); + console.log('userinfo:',req.params.id) UserModel.findById(req.params.id, (err, docs) => { - if (!err) res.send(docs); - else console.log("ID unknown : " + err); + if (!err) { + console.log('doc:',docs) + res.send(docs); + } + else + console.log("ID unknown : " + err); }).select("-password"); }; diff --git a/Site Web/package-lock.json b/Site Web/package-lock.json index 65899d82..abcdd741 100644 --- a/Site Web/package-lock.json +++ b/Site Web/package-lock.json @@ -21,6 +21,7 @@ "jsonwebtoken": "^8.5.1", "mongoose": "^6.6.6", "multer": "^1.4.5-lts.1", + "nodemailer": "^6.9.0", "nodemon": "^2.0.20", "react-dom": "^18.2.0", "react-redux": "^8.0.5", @@ -13520,6 +13521,14 @@ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.8.tgz", "integrity": "sha512-dFSmB8fFHEH/s81Xi+Y/15DQY6VHW81nXRj86EMSL3lmuTmK1e+aT4wrFCkTbm+gSwkw4KpX+rT/pMM2c1mF+A==" }, + "node_modules/nodemailer": { + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.0.tgz", + "integrity": "sha512-jFaCEGTeT3E/m/5R2MHWiyQH3pSARECRUDM+1hokOYc3lQAAG7ASuy+2jIsYVf+RVa9zePopSQwKNVFH8DKUpA==", + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/nodemon": { "version": "2.0.20", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz", @@ -28646,6 +28655,11 @@ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.8.tgz", "integrity": "sha512-dFSmB8fFHEH/s81Xi+Y/15DQY6VHW81nXRj86EMSL3lmuTmK1e+aT4wrFCkTbm+gSwkw4KpX+rT/pMM2c1mF+A==" }, + "nodemailer": { + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.0.tgz", + "integrity": "sha512-jFaCEGTeT3E/m/5R2MHWiyQH3pSARECRUDM+1hokOYc3lQAAG7ASuy+2jIsYVf+RVa9zePopSQwKNVFH8DKUpA==" + }, "nodemon": { "version": "2.0.20", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz", diff --git a/Site Web/package.json b/Site Web/package.json index 5c84e05b..de4cb819 100644 --- a/Site Web/package.json +++ b/Site Web/package.json @@ -22,6 +22,7 @@ "jsonwebtoken": "^8.5.1", "mongoose": "^6.6.6", "multer": "^1.4.5-lts.1", + "nodemailer": "^6.9.0", "nodemon": "^2.0.20", "react-dom": "^18.2.0", "react-redux": "^8.0.5", diff --git a/Site Web/routes/user.routes.js b/Site Web/routes/user.routes.js index f528ad2e..33e9407d 100644 --- a/Site Web/routes/user.routes.js +++ b/Site Web/routes/user.routes.js @@ -9,6 +9,7 @@ const upload = multer(); //controlleur d'authentification router.post('/register', authController.signUp); router.post('/login', authController.signIn); +//router.post('/send-verification-email', authController.verifEmail); //retirer le token (cookie) router.get('/logout', authController.logout);