From 9f317f73f73096408283d8ef758ac9f9b0de5f43 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Mon, 17 Nov 2025 02:58:08 +0000 Subject: [PATCH] completionId: cgen-654631a825c8488a9c64ba2fe973dcf5 cgen-654631a825c8488a9c64ba2fe973dcf5 --- client/pages/ethos/ArtistProfile.tsx | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/client/pages/ethos/ArtistProfile.tsx b/client/pages/ethos/ArtistProfile.tsx index eef7e056..0fdf024e 100644 --- a/client/pages/ethos/ArtistProfile.tsx +++ b/client/pages/ethos/ArtistProfile.tsx @@ -46,27 +46,45 @@ interface Artist { } export default function ArtistProfile() { - const { userId } = useParams<{ userId: string }>(); + const { userId: identifier } = useParams<{ userId: string }>(); + const navigate = useNavigate(); const [artist, setArtist] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { const fetchArtist = async () => { - if (!userId) return; + if (!identifier) return; try { - const res = await fetch(`${API_BASE}/api/ethos/artists?id=${userId}`); + // Support both username and userId + let resolvedUserId = identifier; + + if (!isUUID(identifier)) { + // If not a UUID, try to resolve username to userId + const userId = await resolveIdentifierToUserId(identifier); + if (userId) { + resolvedUserId = userId; + } else { + // If resolution failed and it's not a UUID, it's an invalid identifier + setArtist(null); + setLoading(false); + return; + } + } + + const res = await fetch(`${API_BASE}/api/ethos/artists?id=${resolvedUserId}`); const data = await res.json(); setArtist(data); } catch (error) { console.error("Failed to fetch artist:", error); + setArtist(null); } finally { setLoading(false); } }; fetchArtist(); - }, [userId]); + }, [identifier]); if (loading) { return (