From 430063e913971254718031b6b13572281b5360e8 Mon Sep 17 00:00:00 2001 From: bokhonglo Date: Thu, 9 Apr 2026 14:39:14 +0700 Subject: [PATCH] update user profile --- src/components/user-profile/UserInfoCard.tsx | 85 +++++++++++--------- src/components/user-profile/UserMetaCard.tsx | 85 +++++++++++++++----- 2 files changed, 109 insertions(+), 61 deletions(-) diff --git a/src/components/user-profile/UserInfoCard.tsx b/src/components/user-profile/UserInfoCard.tsx index f98d51a..c46f1bd 100644 --- a/src/components/user-profile/UserInfoCard.tsx +++ b/src/components/user-profile/UserInfoCard.tsx @@ -89,46 +89,53 @@ export default function UserInfoCard({ data }: { data: UserMetaCardProps }) { {data.data?.email || "Email address"}

+ {data.data?.profile?.phone && ( +
+

+ Phone +

+

+ {data.data?.profile?.phone || "+XXX XXX XXX"} +

+
+ )} -
-

- Phone -

-

- {data.data?.profile?.phone || "+XXX XXX XXX"} -

-
+ {data.data?.profile?.bio && ( +
+

+ Bio +

+

+ {data.data?.profile?.bio || "No bio available"} +

+
+ )} -
-

- Bio -

-

- {data.data?.profile?.bio || "No bio available"} -

-
- -
-

- Address -

-

- {data.data?.profile?.location || "No location available"} -

-
-
-

- Website -

- - {data.data?.profile?.website || "No website"} - -
+ {data.data?.profile?.location && ( +
+

+ Address +

+

+ {data.data?.profile?.location || "No location available"} +

+
+ )} + {data.data?.profile?.website && ( +
+

+ Website +

+ + {data.data?.profile?.website || "No website"} + +
+ )} @@ -230,7 +237,7 @@ export default function UserInfoCard({ data }: { data: UserMetaCardProps }) { onChange={handleChange} /> -
+
(null); @@ -18,7 +18,9 @@ export default function UserMetaCard({ data }: { data: UserMetaCardProps }) { } }; - const handleFileChange = async (event: React.ChangeEvent) => { + const handleFileChange = async ( + event: React.ChangeEvent, + ) => { const file = event.target.files?.[0]; if (!file) return; @@ -31,10 +33,11 @@ export default function UserMetaCard({ data }: { data: UserMetaCardProps }) { const uploadedMedia = await uploadMedia(file); console.log("Upload thành công:", uploadedMedia); - } catch (error) { console.error("Lỗi khi upload avatar:", error); - setPreviewImage(data.data?.profile?.avatar_url || "/images/no-images.jpg"); + setPreviewImage( + data.data?.profile?.avatar_url || "/images/no-images.jpg", + ); alert("Không thể tải ảnh lên. Vui lòng thử lại!"); } finally { setIsUploading(false); @@ -49,8 +52,7 @@ export default function UserMetaCard({ data }: { data: UserMetaCardProps }) {
- -
@@ -61,17 +63,48 @@ export default function UserMetaCard({ data }: { data: UserMetaCardProps }) { alt="avatar" className="object-cover w-full h-full" /> - +
{isUploading ? ( - - - + + + ) : ( - - - + + + )}
@@ -94,14 +127,22 @@ export default function UserMetaCard({ data }: { data: UserMetaCardProps }) { {data.data?.roles?.map((role) => role.name).join(", ") || "No roles available"}

-
-

- {data.data?.profile?.bio || "No bio available"} -

-
-

- {data.data?.profile?.location || "user location"} -

+ {data.data?.profile?.bio && ( + <> +
+

+ {data.data?.profile?.bio || "No bio available"} +

+ + )} + {data.data?.profile?.location && ( + <> +
+

+ {data.data?.profile?.location || "user location"} +

+ + )}
@@ -109,4 +150,4 @@ export default function UserMetaCard({ data }: { data: UserMetaCardProps }) {
); -} \ No newline at end of file +}