From 44d4b54e271a2759d2ee319d58110d812c68fe1c Mon Sep 17 00:00:00 2001 From: Dominik Stumpf Date: Mon, 29 Jul 2024 20:56:00 +0200 Subject: [PATCH] chore: add back profile fetching --- next.config.js | 3 ++ .../(marketing)/profile/[username]/page.tsx | 43 ++++++++++--------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/next.config.js b/next.config.js index 35ce1a0ae6..f04d1cc35c 100644 --- a/next.config.js +++ b/next.config.js @@ -88,6 +88,9 @@ const nextConfig = { { hostname: "og.link3.to", }, + { + hostname: "imagedelivery.net" + } ], contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;", }, diff --git a/src/app/(marketing)/profile/[username]/page.tsx b/src/app/(marketing)/profile/[username]/page.tsx index 9b049028f4..8e5ff1ef80 100644 --- a/src/app/(marketing)/profile/[username]/page.tsx +++ b/src/app/(marketing)/profile/[username]/page.tsx @@ -43,27 +43,30 @@ const LevelPolygon = () => { } async function getProfileData(username: string) { - // const req = `https://api.guild.xyz/v2/profiles/${username}` - // const res = await fetch(req) - // if (!res.ok) { - // throw new Error("Failed to fetch profile data") - // } - // return res.json() as Promise - // - // mocking for the time being - const res = { - id: 4, - userId: 6027190, - username: "durumm", - name: "durum", - bio: null, - profileImageUrl: - "https://guild-xyz.mypinata.cloud/ipfs/QmWGdo6FkjSz22oDZFMJysx3hGKoVqtzTWVMx9tTSP7jvi", - backgroundImageUrl: null, - createdAt: "2024-07-25T10:04:20.781Z", - updatedAt: "2024-07-25T10:04:20.781Z", + const req = `https://api.guild.xyz/v2/profiles/${username}` + try { + const res = await fetch(req) + if (!res.ok) { + throw new Error("Failed to fetch profile data") + } + return res.json() as Promise + } catch (e) { + // mocking for the time being if fetch fails + console.error(e) + const res = { + id: 4, + userId: 6027190, + username: "durumm", + name: "durum", + bio: null, + profileImageUrl: + "https://guild-xyz.mypinata.cloud/ipfs/QmWGdo6FkjSz22oDZFMJysx3hGKoVqtzTWVMx9tTSP7jvi", + backgroundImageUrl: null, + createdAt: "2024-07-25T10:04:20.781Z", + updatedAt: "2024-07-25T10:04:20.781Z", + } + return res } - return res } // TODO: try get this from the backend if not possible write zod validation