fix: suppress guest auth errors and add SVG placeholder for missing user avatar in PreviewMapShell
Build and Release / release (push) Successful in 38s
Build and Release / release (push) Successful in 38s
This commit is contained in:
+2
-2
@@ -62,8 +62,8 @@ export const apiResetPassword = async (payload: ResetPasswordPayload) => {
|
|||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const apiGetCurrentUser = async () => {
|
export const apiGetCurrentUser = async (config?: any) => {
|
||||||
const response = await api.get(API.User.CURRENT);
|
const response = await api.get(API.User.CURRENT, config);
|
||||||
return response?.data;
|
return response?.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ export default function PreviewMapShell({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchUserAvatar = async () => {
|
const fetchUserAvatar = async () => {
|
||||||
try {
|
try {
|
||||||
const userData = await apiGetCurrentUser();
|
const userData = await apiGetCurrentUser({ skipRefresh: true } as any);
|
||||||
console.log("PreviewMapShell: Fetched userData:", userData);
|
console.log("PreviewMapShell: Fetched userData:", userData);
|
||||||
if (userData?.data?.profile?.avatar_url) {
|
if (userData?.data?.profile?.avatar_url) {
|
||||||
console.log("PreviewMapShell: Setting avatarUrl to:", userData.data.profile.avatar_url);
|
console.log("PreviewMapShell: Setting avatarUrl to:", userData.data.profile.avatar_url);
|
||||||
@@ -130,7 +130,7 @@ export default function PreviewMapShell({
|
|||||||
console.log("PreviewMapShell: No avatar_url in profile:", userData?.data?.profile);
|
console.log("PreviewMapShell: No avatar_url in profile:", userData?.data?.profile);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("PreviewMapShell: Failed to fetch user avatar:", err);
|
console.log("PreviewMapShell: No active session (user is guest)");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchUserAvatar();
|
fetchUserAvatar();
|
||||||
@@ -250,8 +250,9 @@ export default function PreviewMapShell({
|
|||||||
padding: 0,
|
padding: 0,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{avatarUrl ? (
|
||||||
<Image
|
<Image
|
||||||
src={avatarUrl || "/images/no-images.jpg"}
|
src={avatarUrl}
|
||||||
alt="Cài đặt"
|
alt="Cài đặt"
|
||||||
width={46}
|
width={46}
|
||||||
height={46}
|
height={46}
|
||||||
@@ -261,6 +262,22 @@ export default function PreviewMapShell({
|
|||||||
objectFit: "cover",
|
objectFit: "cover",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
<svg
|
||||||
|
width="20"
|
||||||
|
height="20"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="#cbd5e1"
|
||||||
|
strokeWidth="2.5"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
style={{ transition: "color 0.2s ease" }}
|
||||||
|
>
|
||||||
|
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" />
|
||||||
|
<circle cx="12" cy="7" r="4" />
|
||||||
|
</svg>
|
||||||
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{isMenuOpen && (
|
{isMenuOpen && (
|
||||||
|
|||||||
Reference in New Issue
Block a user