From 301fd77470ddc7ad2a24509ecfcf5cc1891480ee Mon Sep 17 00:00:00 2001 From: Drake <150128459+VialsShiny@users.noreply.github.com> Date: Fri, 28 Nov 2025 13:54:49 +0100 Subject: [PATCH 1/5] Adding Animation for Comment Modal --- frontend/src/layout/CommentModal.jsx | 161 ++++++++++++++------------- 1 file changed, 84 insertions(+), 77 deletions(-) diff --git a/frontend/src/layout/CommentModal.jsx b/frontend/src/layout/CommentModal.jsx index 484b2f0..65f1b1a 100644 --- a/frontend/src/layout/CommentModal.jsx +++ b/frontend/src/layout/CommentModal.jsx @@ -1,11 +1,12 @@ import Box from '@mui/material/Box'; import Modal from '@mui/material/Modal'; -import { useState } from 'react'; -import { fetchData } from '../components/services/Fetch'; +import Slide from '@mui/material/Slide'; +import {useState} from 'react'; +import {fetchData} from '../components/services/Fetch'; import throwError from '../components/services/throwError'; import FormatForm from '../components/utils/FormatForm'; -import { useAuth } from '../providers/AuthProviders'; -import { Comments } from './../components/ui/Comments'; +import {useAuth} from '../providers/AuthProviders'; +import {Comments} from './../components/ui/Comments'; async function handleComment( setComment, @@ -13,14 +14,14 @@ async function handleComment( token, username, user_image_url, - id, + id ) { event.preventDefault(); const apiUrl = import.meta.env.VITE_API_URL; - const { comment } = FormatForm(event); + const {comment} = FormatForm(event); - if (!comment) {return;} + if (!comment) return; fetchData(`${apiUrl}api/posts/${id}/comments`, { method: 'POST', @@ -28,19 +29,19 @@ async function handleComment( 'Content-Type': 'application/json', Authorization: `Bearer ${token}`, }, - body: JSON.stringify({ comment: comment }), + body: JSON.stringify({comment: comment}), }).catch((error) => { throwError(error); }); setComment((prev) => [ - ...prev, { comment, created_at: new Date().toISOString(), user: username, user_image_url: user_image_url, }, + ...prev, ]); event.target.reset(); @@ -53,7 +54,7 @@ export default function CommentsModal({ postId = 0, }) { const [newComments, setNewComments] = useState(comments); - const { currentUser } = useAuth(); + const {currentUser} = useAuth(); const currentToken = localStorage.getItem('token') ?? ''; const currentUserName = currentUser?.username; const currentUserPP = currentUser?.image_url; @@ -63,85 +64,91 @@ export default function CommentsModal({ - -
e.stopPropagation()} + {/* Ajout de Fade pour l'animation */} + + - {/* Header */} -
-

Commentaires

- -
- - {/* Comments list */} -
- {newComments.length === 0 && ( -

- Pas encore de commentaires -

- )} - {newComments.map((comment, i) => ( - - ))} -
- - {/* Add comment input */} - {currentUser ? ( -
- handleComment( - setNewComments, - e, - currentToken, - currentUserName, - currentUserPP, - id, - ) - } - > - +
e.stopPropagation()} + > + {/* Header */} +
+

Commentaires

- - ) : ( -
-

- Vous devez être{' '} - connecté{' '} - pour accéder à cette fonctionnalité -

- )} -
- + + {/* Comments list */} +
+ {newComments.length === 0 && ( +

+ Pas encore de commentaires +

+ )} + {newComments.map((comment, i) => ( + + ))} +
+ + {/* Add comment input */} + {currentUser ? ( +
+ handleComment( + setNewComments, + e, + currentToken, + currentUserName, + currentUserPP, + id + ) + } + > + + +
+ ) : ( +
+

+ Vous devez être{' '} + + connecté + {' '} + pour accéder à cette fonctionnalité +

+
+ )} +
+
+
); } From 179e9505b1c6316258350ca480781167372b5203 Mon Sep 17 00:00:00 2001 From: Drake <150128459+VialsShiny@users.noreply.github.com> Date: Fri, 28 Nov 2025 14:13:15 +0100 Subject: [PATCH 2/5] Adding 'z-99' to the NavBar --- frontend/src/components/layout/NavBar.jsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/layout/NavBar.jsx b/frontend/src/components/layout/NavBar.jsx index 44b49e2..10c99ab 100644 --- a/frontend/src/components/layout/NavBar.jsx +++ b/frontend/src/components/layout/NavBar.jsx @@ -1,11 +1,11 @@ import useMediaQuery from '@mui/material/useMediaQuery'; -import { useState } from 'react'; -import { FiHome, FiLogIn, FiLogOut, FiUserPlus } from 'react-icons/fi'; -import { Link } from 'react-router-dom'; -import { useAuth } from '../../providers/AuthProviders'; +import {useState} from 'react'; +import {FiHome, FiLogIn, FiLogOut, FiUserPlus} from 'react-icons/fi'; +import {Link} from 'react-router-dom'; +import {useAuth} from '../../providers/AuthProviders'; export const NavBar = () => { - const { currentUser, setCurrentUser, isAuthenticate } = useAuth(); + const {currentUser, setCurrentUser, isAuthenticate} = useAuth(); const [isAuthenticated, setIsAuthenticated] = useState(isAuthenticate); const isDesktop = useMediaQuery('(min-width:1024px)'); @@ -21,7 +21,7 @@ export const NavBar = () => { return isDesktop ? (