diff --git a/Site Web/client/src/components/AjoutLien.js b/Site Web/client/src/components/AjoutLien.js index 630d2924..9ff155b4 100644 --- a/Site Web/client/src/components/AjoutLien.js +++ b/Site Web/client/src/components/AjoutLien.js @@ -3,6 +3,7 @@ import React, {useContext, useState} from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { addPost, getPosts } from '../actions/post.actions'; import { UidContext } from './AppContext'; +import IconeFavor from '../assets/img/logo.png'; const AjoutLien = () => { const uid = useContext(UidContext); @@ -29,6 +30,7 @@ const AjoutLien = () => { dispatch(getPosts()); cancelPost(); setDisplayAdd(false); + await new Promise(r => setTimeout(r, 500)); window.location.reload(); }else { alert("Veuillez compléter tous les champs et ajouter au moins un tag.") @@ -74,23 +76,34 @@ const AjoutLien = () => { } {uid !== null && - + } {displayAdd && ( -
+

Ajout d'un lien

setDisplayAdd(false)}> ✕ -
    +
      setLien(e.target.value)} value={lien} required /> @@ -110,7 +123,7 @@ const AjoutLien = () => { value={tag} onChange={e => setTag(e.target.value)} /> - Add Tag + Ajouter un tag
        {tags.map(t => ( @@ -120,7 +133,7 @@ const AjoutLien = () => {
        - +
        diff --git a/Site Web/client/src/components/Configurations/ConfigurationDuCompte.js b/Site Web/client/src/components/Configurations/ConfigurationDuCompte.js index 293e97b9..6794eec0 100644 --- a/Site Web/client/src/components/Configurations/ConfigurationDuCompte.js +++ b/Site Web/client/src/components/Configurations/ConfigurationDuCompte.js @@ -16,7 +16,7 @@ const ConfigurationDuCompte =()=>{ e.preventDefault(); console.log(userData._id); axios - .put(`${process.env.REACT_APP_API_URL}api/user/update/`+ userData._id , { email, password }) + .put(`${process.env.REACT_APP_API_URL}api/user/update/email/`+ userData._id , { email, password }) .then(response => { console.log(response); }) @@ -24,12 +24,27 @@ const ConfigurationDuCompte =()=>{ console.log(error); }); } + + /* const handleSuppression{ + + } + */ + const deleteUser = (userId) => { + try { + console.log("test"); + console.log(userId); + const response = axios.delete(`${process.env.REACT_APP_API_URL}api/user/delete/${userId}`); + console.log(response.data.message); + } catch (error) { + console.log(error.response.data.error); + } + } return(
        -

        Modification des information du compte

        +

        Modification des informations du compte

        @@ -69,10 +84,10 @@ const ConfigurationDuCompte =()=>{

        Suppression du compte

        - -

        Note : action irreversible qui vous fera perdre toutes les données du compte en conséquence

        +

        Note : Cette action est irréversible qui vous fera perdre toutes les données du compte en conséquence

        ) diff --git a/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js b/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js index 34d168f1..29030412 100644 --- a/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js +++ b/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js @@ -3,7 +3,7 @@ import { useSelector, useDispatch } from 'react-redux'; import PLUS from "../../assets/img/plus.png"; import { NavLink } from "react-router-dom"; import axios from "axios"; -import { uploadPicture } from '../../actions/user.actions'; +import { getUser, uploadPicture } from '../../actions/user.actions'; import { useParams } from 'react-router-dom'; import { UidContext } from '../AppContext'; @@ -16,6 +16,9 @@ const ConfigurationDuProfil = ()=>{ const [tmpAffichageImage, setTmpAffichageImage]=useState(PLUS); const [displayAdd, setDisplayAdd] = useState(false); const [message, setMessage] = useState(''); + const dispatch=useDispatch(); + + const handleLoadFile=(e)=>{ const file=e.target.files[0]; @@ -35,6 +38,21 @@ const ConfigurationDuProfil = ()=>{ console.log(tmpImage); }; + + const handleUpdatePseudo=(e)=>{ + e.preventDefault(); + console.log(userData.pseudo); + axios + .put(`${process.env.REACT_APP_API_URL}api/user/update/`+ userData._id , { pseudo }) + .then(response => { + console.log(response); + }) + .catch(error => { + console.log(error); + }); + dispatch(getUser); + } + const handleTPM =()=> { console.log("test"); console.log(tmpImage); @@ -44,6 +62,7 @@ const ConfigurationDuProfil = ()=>{ const handleUpdate = async (e) => { e.preventDefault(); + try { await axios.patch( `${process.env.REACT_APP_API_URL}api/user/${userData.id}/image`, tmpImage); setMessage("Image de profil mise à jour avec succès!"); @@ -51,29 +70,10 @@ const ConfigurationDuProfil = ()=>{ setMessage("Erreur lors de la mise à jour de l'image de profil"); } - userPicture(tmpAffichageImage); + setUserPicture(tmpAffichageImage); console.log(userPicture); setDisplayAdd(false); - //const pseudoError = document.querySelector(".pseudo.error"); - /* const pictureError =document.querySelector(".picture.error"); - await axios({ - method: "post", - url: `${process.env.REACT_APP_API_URL}api/user/upload`, - data: { - // pseudo, - userPicture, - - } - , - }) - .then((res) => { - console.log(res); - if (res.data.errors) { - //pseudoError.innerHTML = res.data.errors.pseudo; - pictureError.innerHTML = res.data.errors.picture; - } - }) - .catch((err) => console.log(err));*/ + }; @@ -115,7 +115,7 @@ const ConfigurationDuProfil = ()=>{
        - +
      @@ -138,7 +138,6 @@ const ConfigurationDuProfil = ()=>{
{/*onChange={handleLoadFile} onChange={(e)=> setTmpImage(e.target.files[0].name)} */} diff --git a/Site Web/client/src/components/Post/ActionComment.js b/Site Web/client/src/components/Post/ActionComment.js index 1b22a76c..a46668ec 100644 --- a/Site Web/client/src/components/Post/ActionComment.js +++ b/Site Web/client/src/components/Post/ActionComment.js @@ -7,7 +7,8 @@ import { UidContext } from '../AppContext'; const ActionComment = ( { commentaire , postId}) => { const [createur, setCreateur] = useState(false); const [edit, setEdit] = useState(false); - const [message,setMessage] = useState(''); + const [message,setMessage] = useState(commentaire.text); + const uid = useContext(UidContext); const dispatch = useDispatch(); @@ -15,13 +16,14 @@ const ActionComment = ( { commentaire , postId}) => { e.preventDefault(); if(message){ dispatch(editComment(postId, commentaire._id, message)); - setMessage(''); setEdit(false); } }; const handleDelete = () => { dispatch(deleteComment(postId, commentaire._id)); + setMessage('commantaire suprimer'); + setEdit(false); }; useEffect(() => { @@ -36,6 +38,9 @@ const ActionComment = ( { commentaire , postId}) => { }, [uid, commentaire.commenterId]); return ( + <> +

{message}

+
{createur && edit === false && ( setEdit(!edit)}> @@ -45,24 +50,28 @@ const ActionComment = ( { commentaire , postId}) => { {createur && edit && (
- - +
+ +
+ { + if(window.confirm("Etes-vous sur de supprimer ce commentaire ?")){ + handleDelete(); + } + }}> + + +
+ +
setMessage(e.target.value)} defaultValue={commentaire.text}/>
-
- { - if(window.confirm("Etes-vous sur de supprimer ce commentaire ?")){ - handleDelete(); - } - }}> - - -
- + +
)}
+ ); }; diff --git a/Site Web/client/src/components/Post/ButtonLike.js b/Site Web/client/src/components/Post/ButtonLike.js index ae1d5cb5..cbd71345 100644 --- a/Site Web/client/src/components/Post/ButtonLike.js +++ b/Site Web/client/src/components/Post/ButtonLike.js @@ -6,39 +6,40 @@ import CoeurPlein from '../../assets/img/coeursPlein.png'; import { likePost, unlikePost } from '../../actions/post.actions'; const ButtonLike = ( { post } ) => { - const [liked, setLiked] = useState(false); const uid = useContext(UidContext); + const [likes, setLikes] = useState(post.likers.length); + const [liked, setLiked] = useState(post.likers.includes(uid)); const dispatch = useDispatch(); const like = (e) => { e.preventDefault(); - dispatch(likePost(post._id, uid)); + setLikes(likes + 1); setLiked(true); + dispatch(likePost(post._id, uid)); }; const unlike = (e) => { e.preventDefault(); - dispatch(unlikePost(post._id, uid)); + setLikes(likes - 1); setLiked(false); + dispatch(unlikePost(post._id, uid)); }; - useEffect(() => { - if (post.likers.includes(uid)) { - setLiked(true); - } else { - setLiked(false); - } - }, [uid, post.likers, liked]); return ( -
- {uid && liked === false && ( - like - )} - {uid && liked && ( - unlike - )} -
+ <> +
+ {uid && liked === false && ( + like + )} + {uid && liked && ( + unlike + )} +
+
+ {likes} +
+ ); }; diff --git a/Site Web/client/src/components/Post/Comment.js b/Site Web/client/src/components/Post/Comment.js index b9a3b727..ae4a9823 100644 --- a/Site Web/client/src/components/Post/Comment.js +++ b/Site Web/client/src/components/Post/Comment.js @@ -4,6 +4,9 @@ import { addComment, getPosts } from '../../actions/post.actions'; import FollowHandler from '../UserProfil/FollowHandler'; import { isEmpty, timestampParser } from '../Utils'; import ActionComment from './ActionComment'; +import MiniProfil from "../MiniProfil"; + + const Comment = ({ post }) => { const [message, setMessage] = useState(""); @@ -27,41 +30,29 @@ const Comment = ({ post }) => { return (
- { - if (user._id === comment.commenterId) return user.picture; - else return null; - }) - .join("") - } - alt="commenter-pic" - /> +
-

{comment.commenterPseudo}

- {comment.commenterId !== userData._id && ( - - )}
{timestampParser(comment.timestamp)}
-

{comment.text}

- +
+ +
+
); diff --git a/Site Web/client/src/components/Post/DisplayPost/DiplayPostDossier.js b/Site Web/client/src/components/Post/DisplayPost/DiplayPostDossier.js index 30bbe569..702b8621 100644 --- a/Site Web/client/src/components/Post/DisplayPost/DiplayPostDossier.js +++ b/Site Web/client/src/components/Post/DisplayPost/DiplayPostDossier.js @@ -13,14 +13,17 @@ const DiplayPostDossier = () => { useEffect(() => { dispatch(getPosts()); },[dispatch]) - + console.log("datados"); + console.log(postsData); return (
    - {!isEmpty(postsData[0]) && + {!isEmpty(postsData) && postsData.map((post) => { if(post.postedId === uid){ + console.log(post) + console.log("tttt") return } })} diff --git a/Site Web/client/src/components/Post/DisplayPost/DisplayPostLikeProfil.js b/Site Web/client/src/components/Post/DisplayPost/DisplayPostLikeProfil.js index 60b6f9fa..af9debbd 100644 --- a/Site Web/client/src/components/Post/DisplayPost/DisplayPostLikeProfil.js +++ b/Site Web/client/src/components/Post/DisplayPost/DisplayPostLikeProfil.js @@ -13,7 +13,8 @@ const DisplayPostLikeProfil = () => { useEffect(() => { dispatch(getPosts()); },[dispatch]) - + console.log("datapost like"); + console.log(postsData); return (
    diff --git a/Site Web/client/src/components/Post/DisplayPost/NouveauDisplayPosts.js b/Site Web/client/src/components/Post/DisplayPost/NouveauDisplayPosts.js index a5555d9d..13eab004 100644 --- a/Site Web/client/src/components/Post/DisplayPost/NouveauDisplayPosts.js +++ b/Site Web/client/src/components/Post/DisplayPost/NouveauDisplayPosts.js @@ -13,7 +13,8 @@ const NouveauDisplayPosts = () => { useEffect(() => { dispatch(getPosts()); },[dispatch]) - + console.log("datapost"); + console.log(postsData); if (!postsData) { return

    Loading...

    ; } diff --git a/Site Web/client/src/components/Post/Post.js b/Site Web/client/src/components/Post/Post.js index 1f197a7a..29007eba 100644 --- a/Site Web/client/src/components/Post/Post.js +++ b/Site Web/client/src/components/Post/Post.js @@ -75,7 +75,6 @@ const Post = ( { post } ) => {
    -
    {post.likers.length}
    setComments(!comments)}/> diff --git a/Site Web/client/src/components/Post/PostNouvelleAffichage.js b/Site Web/client/src/components/Post/PostNouvelleAffichage.js index 003b58fe..0243cab8 100644 --- a/Site Web/client/src/components/Post/PostNouvelleAffichage.js +++ b/Site Web/client/src/components/Post/PostNouvelleAffichage.js @@ -46,12 +46,15 @@ const PostNouvelleAffichage = ( { post } ) => { useEffect(() => { - !isEmpty(usersData[0]) && setIsLoading(false) + try { + !isEmpty(usersData[0]) && setIsLoading(false) + } + catch (error){ + + } }) - if(!isLoading){ - return

    ; - } + try { return (
  • @@ -70,8 +73,6 @@ const PostNouvelleAffichage = ( { post } ) => {
    - {/* */} -
    {post.likers.length}
    setComments(!comments)}/> diff --git a/Site Web/client/src/components/UserProfil/NavigationProfil/DossiersPersonnels.js b/Site Web/client/src/components/UserProfil/NavigationProfil/DossiersPersonnels.js index f1b7b7fd..abec1e2f 100644 --- a/Site Web/client/src/components/UserProfil/NavigationProfil/DossiersPersonnels.js +++ b/Site Web/client/src/components/UserProfil/NavigationProfil/DossiersPersonnels.js @@ -5,7 +5,6 @@ import DiplayPostDossier from "../../Post/DisplayPost/DiplayPostDossier"; const DossiersPersonnels=()=>{ - return(
    diff --git a/Site Web/client/src/components/UserProfil/SuggestFriends.js b/Site Web/client/src/components/UserProfil/SuggestFriends.js index 2ceee84c..2a5c50b0 100644 --- a/Site Web/client/src/components/UserProfil/SuggestFriends.js +++ b/Site Web/client/src/components/UserProfil/SuggestFriends.js @@ -66,22 +66,27 @@ const SuggestFriends = () => { } }, [userData, usersData, change]) - return ( + try { + return (
    Vous pourriez suivre
    {chargement ? ( - + ) : ( -
    +
    {friends && friends.map((user) => { - for(let i = 0; i < usersData.length; i++){ - if(user === usersData[i]._id){ + for (let i = 0; i < usersData.length; i++) { + if (user === usersData[i]._id) { return (
    - - +
    + +
    +
    + +
    ); } @@ -92,7 +97,11 @@ const SuggestFriends = () => { )}
    - ); + ); + } + catch (error){ + return
    Loading...
    + } }; export default SuggestFriends; \ No newline at end of file diff --git a/Site Web/client/src/pages/Profil.js b/Site Web/client/src/pages/Profil.js index 5092841c..772e9b6e 100644 --- a/Site Web/client/src/pages/Profil.js +++ b/Site Web/client/src/pages/Profil.js @@ -34,7 +34,7 @@ const Profil = () => { setUidS(true); } }, [uid]); - + const handleModals = (e) => { if (e.target.id === "DossierPersonnels") { @@ -64,7 +64,7 @@ const Profil = () => {
    - +

    {userData.pseudo}

    @@ -84,55 +84,53 @@ const Profil = () => {
    {followingPopup && ( -
    -
    -

    Abonnements

    - setFollowingPopup(false)}> - ✕ - -
      - { - userData.following.map((follower, i) => { - return ( -
    • - -
      - -
      -
    • - ) - }) - } -
    -
    -
    - )} - {followerPopup && ( -
    -
    -

    Abonnés

    - setFollowerPopup(false)}> - ✕ - -
      - { - userData.followers.map((follower, i) => { - return ( -
    • - -
      - -
      -
    • - ) - }) - } -
    -
    -
    - )} - - +
    +
    +

    Abonnements

    + setFollowingPopup(false)}> + ✕ + +
      + { + userData.following.map((follower, i) => { + return ( +
    • + +
      + +
      +
    • + ) + }) + } +
    +
    +
    + )} + {followerPopup && ( +
    +
    +

    Abonnements

    + setFollowerPopup(false)}> + ✕ + +
      + { + userData.followers.map((follower, i) => { + return ( +
    • + +
      + +
      +
    • + ) + }) + } +
    +
    +
    + )}
    diff --git a/Site Web/client/src/pages/SearchBar.js b/Site Web/client/src/pages/SearchBar.js index b8c21c6c..ca6f8d11 100644 --- a/Site Web/client/src/pages/SearchBar.js +++ b/Site Web/client/src/pages/SearchBar.js @@ -56,11 +56,31 @@ const SearchBar = () => {
    -
    + + {/* setSearchValue(e.target.value)} placeholder="Rechercher..."/> -
    + */} +
    +
    +
    +
    +
    + +
    + setSearchValue(e.target.value)} placeholder="Rechercher..."/> +
    +
    +
    + +
    +
    + +
    +