fix display profile-picture
This commit is contained in:
@@ -66,6 +66,7 @@ function ProfilePage() {
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
console.log(JSON.stringify(import.meta.env.VITE_API_URL));
|
||||
if (!isOwnProfile && id) {
|
||||
const res = await getUserById(id);
|
||||
if (res.status === 404) {
|
||||
@@ -78,10 +79,11 @@ function ProfilePage() {
|
||||
}
|
||||
setProfileUser(res.data);
|
||||
} else {
|
||||
update();
|
||||
//update();
|
||||
setProfileUser(user);
|
||||
if (user?.profile_photo_path) {
|
||||
setProfilePicture(`${import.meta.env.VITE_API_URL}/storage/${user.profile_photo_path}`);
|
||||
//setProfilePicture(`${import.meta.env.VITE_API_URL}/${user.profile_photo_path}`);
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -93,7 +95,6 @@ function ProfilePage() {
|
||||
}
|
||||
};
|
||||
|
||||
// Remplacé : handleFileChange extrait vers utils/users/uploadProfilePhoto
|
||||
const handleFileChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
@@ -102,6 +103,7 @@ function ProfilePage() {
|
||||
const res = await uploadProfilePhoto(file);
|
||||
if (res.ok) {
|
||||
setProfilePicture(`${import.meta.env.VITE_API_URL}/storage/${res.data.profile_photo_path}`);
|
||||
//setProfilePicture(`${import.meta.env.VITE_API_URL}/${res.data.profile_photo_path}`);
|
||||
setSuccess("Photo mise à jour !");
|
||||
setError(null);
|
||||
await update();
|
||||
|
||||
Reference in New Issue
Block a user