fix: suppress guest auth errors and add SVG placeholder for missing user avatar in PreviewMapShell
Build and Release / release (push) Successful in 38s

This commit is contained in:
taDuc
2026-06-04 18:49:58 +07:00
parent 9a5dfdb2ed
commit 5aee0eccb2
2 changed files with 32 additions and 15 deletions
+2 -2
View File
@@ -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;
}; };
+30 -13
View File
@@ -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,17 +250,34 @@ export default function PreviewMapShell({
padding: 0, padding: 0,
}} }}
> >
<Image {avatarUrl ? (
src={avatarUrl || "/images/no-images.jpg"} <Image
alt="Cài đặt" src={avatarUrl}
width={46} alt="Cài đặt"
height={46} width={46}
style={{ height={46}
width: "100%", style={{
height: "100%", width: "100%",
objectFit: "cover", height: "100%",
}} 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 && (