fix display profile-picture
This commit is contained in:
1 parent
430c95db78
commit
23219d1ffe
1 file changed
+4
-2
@@ -66,6 +66,7 @@ function ProfilePage() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
|
console.log(JSON.stringify(import.meta.env.VITE_API_URL));
|
||||||
if (!isOwnProfile && id) {
|
if (!isOwnProfile && id) {
|
||||||
const res = await getUserById(id);
|
const res = await getUserById(id);
|
||||||
if (res.status === 404) {
|
if (res.status === 404) {
|
||||||
@@ -78,10 +79,11 @@ function ProfilePage() {
|
|||||||
}
|
}
|
||||||
setProfileUser(res.data);
|
setProfileUser(res.data);
|
||||||
} else {
|
} else {
|
||||||
update();
|
//update();
|
||||||
setProfileUser(user);
|
setProfileUser(user);
|
||||||
if (user?.profile_photo_path) {
|
if (user?.profile_photo_path) {
|
||||||
setProfilePicture(`${import.meta.env.VITE_API_URL}/storage/${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 handleFileChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const file = e.target.files?.[0];
|
const file = e.target.files?.[0];
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
@@ -102,6 +103,7 @@ function ProfilePage() {
|
|||||||
const res = await uploadProfilePhoto(file);
|
const res = await uploadProfilePhoto(file);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
setProfilePicture(`${import.meta.env.VITE_API_URL}/storage/${res.data.profile_photo_path}`);
|
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 !");
|
setSuccess("Photo mise à jour !");
|
||||||
setError(null);
|
setError(null);
|
||||||
await update();
|
await update();
|
||||||
|
|||||||
Reference in new issue
Block a user