Skip to content

Commit

Permalink
hotfix: resolve missing portfolio fetch issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hikasap committed Dec 16, 2024
1 parent eacc84b commit 883cb7a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions frontend/src/service/profileService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ import { apiClient } from './apiClient';
import log from '../utils/logger';
import { transformPost } from './postService';

const transformProfile = (userData, profile, posts, comments, portfolios) => {
const transformProfile = (userData, profile, posts, comments) => {
profile = {
...profile,
username: userData.username,
badges: [],
name: "Not Set",
posts: posts,
comments: comments,
portfolios: portfolios,
followingCnt: profile?.following?.length || 0,
followersCnt: profile?.followers?.length || 0,
postsCnt: posts.length || 0,
commentsCnt: comments.length || 0,
portfoliosCnt: portfolios.length || 0,
};
return profile;
};
Expand Down Expand Up @@ -52,10 +50,9 @@ const ProfileService = {
posts.map(async (post) => transformPost(post))
);
const comments = await this.fetchCommentsByProfileId(id);
const portfolios = await this.fetchPortfoliosByProfileId(id);
const response = await apiClient.get(`/profiles/by-user-id/${id}/`);

return transformProfile(userData, response.data, transformedPosts, comments, portfolios);
return transformProfile(userData, response.data, transformedPosts, comments);
} catch (error) {
log.error(`Error fetching profile with ID ${id}:`, error);
throw error;
Expand Down

0 comments on commit 883cb7a

Please sign in to comment.