diff --git a/src/components/Task/Task.module.css b/src/components/Task/Task.module.css index 052d0a3..b8489f6 100644 --- a/src/components/Task/Task.module.css +++ b/src/components/Task/Task.module.css @@ -2,7 +2,6 @@ width: 100%; padding: 12px; margin-bottom: 10px; - border-radius: 8px; } .content { diff --git a/src/components/Task/Task.tsx b/src/components/Task/Task.tsx index 7c939b2..daf805d 100644 --- a/src/components/Task/Task.tsx +++ b/src/components/Task/Task.tsx @@ -52,7 +52,7 @@ const Task: React.FC = ({ task }) => { }, [task.events_id]); return ( -
+

diff --git a/src/pages/Admin/components/IncompleteEvent/IncompleteEvent.jsx b/src/pages/Admin/components/IncompleteEvent/IncompleteEvent.jsx index 5548ea6..698f3b4 100644 --- a/src/pages/Admin/components/IncompleteEvent/IncompleteEvent.jsx +++ b/src/pages/Admin/components/IncompleteEvent/IncompleteEvent.jsx @@ -11,7 +11,7 @@ function IncompleteEvent() {

Derniers événements

{events.map((event) => ( -
+

{event.name}

{new Date(event.start).toLocaleDateString("fr-FR")} - {new Date(event.end).toLocaleDateString("fr-FR")} diff --git a/src/pages/Admin/components/IncompleteEvent/IncompleteEvent.module.css b/src/pages/Admin/components/IncompleteEvent/IncompleteEvent.module.css index 85849fc..e9c76d2 100644 --- a/src/pages/Admin/components/IncompleteEvent/IncompleteEvent.module.css +++ b/src/pages/Admin/components/IncompleteEvent/IncompleteEvent.module.css @@ -29,17 +29,18 @@ transform: translateX(20px); animation: slideInEvent 1s ease forwards; flex-shrink: 0; + padding: 10px; } .eventCard ul { align-items: center; - margin-left: 8%; - padding-left: 15px; + margin-left: 5%; } .eventCard ul li { text-align: left; list-style-type: circle; + list-style: none; } .eventCard > h3 { diff --git a/src/pages/Admin/components/pendingMembers/PendingMembers.jsx b/src/pages/Admin/components/pendingMembers/PendingMembers.jsx index f8280f6..6db113a 100644 --- a/src/pages/Admin/components/pendingMembers/PendingMembers.jsx +++ b/src/pages/Admin/components/pendingMembers/PendingMembers.jsx @@ -58,7 +58,7 @@ function PendingMembers() { {pendingMembers.map((member, index) => ( -

+

{member.name} {member.lastname}

diff --git a/src/pages/Home/components/Calendar/calendar.jsx b/src/pages/Home/components/Calendar/calendar.jsx index 8129bf7..a03f6e6 100644 --- a/src/pages/Home/components/Calendar/calendar.jsx +++ b/src/pages/Home/components/Calendar/calendar.jsx @@ -5,7 +5,8 @@ import {EventContext} from "../../../../contexts/events/EventContext.js"; import Button from "../../../../components/ui/button/button.jsx"; import {AuthContext} from "../../../../contexts/auth/AuthContext.ts"; -function Calendar() { +function +Calendar() { const { user } = useContext(AuthContext); diff --git a/src/pages/Profile/ProfilePage.tsx b/src/pages/Profile/ProfilePage.tsx index eddae6a..722f4bd 100644 --- a/src/pages/Profile/ProfilePage.tsx +++ b/src/pages/Profile/ProfilePage.tsx @@ -17,20 +17,20 @@ import deleteProfilePhoto from "../../utils/users/deleteProfilePhoto.js"; interface TaskType { - id: number; - name: string; - description: string; - location: string; - start: string; - end: string; - max_participants: number; - events_id: number; - created_at: string; - updated_at: string; - pivot: { - user_id: number; - task_id: number; - }; + id: number; + name: string; + description: string; + location: string; + start: string; + end: string; + max_participants: number; + events_id: number; + created_at: string; + updated_at: string; + pivot: { + user_id: number; + task_id: number; + }; } @@ -53,161 +53,162 @@ interface AuthContextType { } function ProfilePage() { - const navigate = useNavigate(); - const { id } = useParams(); - const { user, update } = useContext(AuthContext) as AuthContextType; - const [profileUser, setProfileUser] = useState(null); - const [profilePicture, setProfilePicture] = useState(null); - const [error, setError] = useState(null); - const [success, setSuccess] = useState(null); - const fileInputRef = useRef(null); + const navigate = useNavigate(); + const {id} = useParams(); + const {user, update} = useContext(AuthContext) as AuthContextType; + const [profileUser, setProfileUser] = useState(null); + const [profilePicture, setProfilePicture] = useState(null); + const [error, setError] = useState(null); + const [success, setSuccess] = useState(null); + const fileInputRef = useRef(null); - const isOwnProfile = !id || user?.id.toString() === id; + const isOwnProfile = !id || user?.id.toString() === id; - useEffect(() => { - (async () => { - if (!isOwnProfile && id) { - const res = await getUserById(id); - if (res.status === 404) { - navigate("/404"); - return; + useEffect(() => { + (async () => { + if (!isOwnProfile && id) { + const res = await getUserById(id); + if (res.status === 404) { + navigate("/404"); + return; + } + if (res.status !== 200) { + console.error("Erreur lors du chargement du profil", res); + return; + } + setProfileUser(res.data); + } else { + update(); + setProfileUser(user); + if (user?.profile_photo_path) { + setProfilePicture(`${import.meta.env.VITE_API_URL}/storage/${user.profile_photo_path}`); + } + } + })(); + }, [user, id]); + + const handleEditPictureClick = () => { + if (fileInputRef.current) { + fileInputRef.current.click(); } - if (res.status !== 200) { - console.error("Erreur lors du chargement du profil", res); - return; + }; + + // Remplacé : handleFileChange extrait vers utils/users/uploadProfilePhoto + const handleFileChange = async (e: React.ChangeEvent) => { + const file = e.target.files?.[0]; + if (!file) return; + + try { + const res = await uploadProfilePhoto(file); + if (res.ok) { + setProfilePicture(`${import.meta.env.VITE_API_URL}/storage/${res.data.profile_photo_path}`); + setSuccess("Photo mise à jour !"); + setError(null); + await update(); + } else { + setError(res.data?.message || res.error || "Erreur lors de l'upload."); + setSuccess(null); + } + } catch (err) { + setError("Erreur réseau."); + setSuccess(null); } - setProfileUser(res.data); - } else { - update(); - setProfileUser(user); - if (user?.profile_photo_path) { - setProfilePicture(`${import.meta.env.VITE_API_URL}/storage/${user.profile_photo_path}`); + }; + + // Remplacé : handleDeletePicture extrait vers utils/users/deleteProfilePhoto + const handleDeletePicture = async () => { + try { + const res = await deleteProfilePhoto(); + if (res.status >= 200 && res.status < 300) { + setProfilePicture(null); + setSuccess("Photo supprimée !"); + setError(null); + await update(); + } else { + setError(res.data?.message || "Erreur lors de la suppression."); + setSuccess(null); + } + } catch (err) { + setError("Erreur réseau."); + setSuccess(null); } - } - })(); - }, [user, id]); + }; - const handleEditPictureClick = () => { - if (fileInputRef.current) { - fileInputRef.current.click(); - } - }; + return ( +
+
+
+
+ Photo de profil +
- // Remplacé : handleFileChange extrait vers utils/users/uploadProfilePhoto - const handleFileChange = async (e: React.ChangeEvent) => { - const file = e.target.files?.[0]; - if (!file) return; + {isOwnProfile && ( +
+ + {user?.profile_photo_path && ( + + )} +
+ )} - try { - const res = await uploadProfilePhoto(file); - if (res.ok) { - setProfilePicture(`${import.meta.env.VITE_API_URL}/storage/${res.data.profile_photo_path}`); - setSuccess("Photo mise à jour !"); - setError(null); - await update(); - } else { - setError(res.data?.message || res.error || "Erreur lors de l'upload."); - setSuccess(null); - } - } catch (err) { - setError("Erreur réseau."); - setSuccess(null); - } - }; + + {error &&

{error}

} + {success &&

{success}

} - // Remplacé : handleDeletePicture extrait vers utils/users/deleteProfilePhoto - const handleDeletePicture = async () => { - try { - const res = await deleteProfilePhoto(); - if (res.status >= 200 && res.status < 300) { - setProfilePicture(null); - setSuccess("Photo supprimée !"); - setError(null); - await update(); - } else { - setError(res.data?.message || "Erreur lors de la suppression."); - setSuccess(null); - } - } catch (err) { - setError("Erreur réseau."); - setSuccess(null); - } - }; +
+
+

+ {profileUser?.name} {profileUser?.lastname} +

+ {user?.isAdmin && profileUser && !isOwnProfile && ( + + )} +
- return ( -
-
-
-
- Photo de profil -
+
+
+

Role : {profileUser?.role}

+

Membre depuis : {profileUser && formatDate(profileUser.created_at)} +

+
- {isOwnProfile && ( -
- - {user?.profile_photo_path && ( - - )} -
- )} +
+

Mail : {profileUser?.email}

+

Téléphone : {profileUser?.phone ?? "Non renseigné"}

+
- - {error &&

{error}

} - {success &&

{success}

} + {isOwnProfile && ( +
+ +
+ )} +
-
-
-

- {profileUser?.name} {profileUser?.lastname} -

- {user?.isAdmin && profileUser && !isOwnProfile && ( - - )} -
- -
-
-

Role : {profileUser?.role}

-

Membre depuis : {profileUser && formatDate(profileUser.created_at)}

-
- -
-

Mail : {profileUser?.email}

-

Téléphone : {profileUser?.phone ?? "Non renseigné"}

-
- - {isOwnProfile && ( -
- +

Tâches :

+ {profileUser?.tasks.length ? ( + profileUser.tasks.map((task) =>) + ) : ( +

Aucune tâche.

+ )} +
- )}
- -

Tâches :

- {profileUser?.tasks.length ? ( - profileUser.tasks.map((task) => ) - ) : ( -

Aucune tâche.

- )} -
-
-
- ); + ); } export default ProfilePage; \ No newline at end of file