Skip to content

Commit 4dedd12

Browse files
committed
refactor: Update api endpoints to match response format
1 parent 3523566 commit 4dedd12

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

src/hooks/useFetchThemes.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const useFetchThemes = (
3636
}
3737

3838
const response = await galleryApiFetch(finalUrl);
39-
apiThemes = await response.json();
39+
const result = await response.json();
40+
apiThemes = result.data;
4041
} else {
4142
apiThemes = Placeholders.themes;
4243
}

src/hooks/useFetchUserData.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const useLoginUser = (url: string, provider: string, key: string) => {
2626
try {
2727
const response = await galleryApiFetch(`${url}?provider=${provider}&key=${key}`);
2828
const result = await response.json();
29-
setData(result);
29+
setData(result.data);
3030
} catch (err: unknown) {
3131
setError(err as Error);
3232
} finally {

src/interfaces/UserData.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ export interface UserData {
88
name: string;
99
email: string;
1010
handle: string;
11-
avatar_url: string;
11+
avatarUrl: string;
1212
status: string;
1313
location: string;
14-
profile_url: string;
14+
profileUrl: string;
1515
provider: string;
16-
provider_user_id: string;
16+
providerUserId: string;
1717
}

src/pages/UserProfile.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ const UserProfilePage: React.FC = () => {
2121
const refreshUserData = async () => {
2222
try {
2323
const response = await galleryApiFetch(Endpoints.fetchUserProfile);
24-
const result = await response.json();
25-
setUserData(result);
24+
if (response.ok) {
25+
const result = await response.json();
26+
setUserData(result.data);
27+
}
2628
} catch {
2729
// no update if error
2830
}
@@ -37,7 +39,7 @@ const UserProfilePage: React.FC = () => {
3739
<div className="flex items-center">
3840
<div className="rounded-full w-32 h-32 bg-gray-700 overflow-hidden mr-6">
3941
<img
40-
src={userData?.avatar_url || botAvatar}
42+
src={userData?.avatarUrl || botAvatar}
4143
alt={userData?.name || 'Bot Avatar'}
4244
className="w-full h-full object-cover"
4345
/>
@@ -53,7 +55,7 @@ const UserProfilePage: React.FC = () => {
5355
<div className="mt-6">
5456
<div className="flex items-center mb-4">
5557
<Github className="mr-2" />
56-
<Link to={userData?.profile_url as string} className="text-sm">
58+
<Link to={userData?.profileUrl as string} className="text-sm">
5759
{userData?.handle}
5860
</Link>
5961
</div>

0 commit comments

Comments
 (0)