diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 7deee5fb..adc5ec49 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -18,6 +18,7 @@ "lightweight-charts": "^4.2.2", "loglevel": "^1.9.2", "react": "^18.3.1", + "react-app": "^1.1.2", "react-dom": "^18.3.1", "react-financial-charts": "^2.0.1", "react-google-charts": "^5.1.0", @@ -15782,6 +15783,19 @@ "node": ">=0.10.0" } }, + "node_modules/react-app": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/react-app/-/react-app-1.1.2.tgz", + "integrity": "sha512-4MrTmJWu3WDX3upmEyyHGhA15L0qtqJBDMoVZRjd5hrf8lEoX/ja/EOG31eppiyRTWpZGGigCwb2lzsI6ZKDFQ==", + "license": "MIT", + "bin": { + "react-app": "bin/react-app.js" + }, + "engines": { + "node": ">=6", + "npm": ">=3.8" + } + }, "node_modules/react-app-polyfill": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/react-app-polyfill/-/react-app-polyfill-3.0.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index a73b7118..7bad8f51 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -13,6 +13,7 @@ "lightweight-charts": "^4.2.2", "loglevel": "^1.9.2", "react": "^18.3.1", + "react-app": "^1.1.2", "react-dom": "^18.3.1", "react-financial-charts": "^2.0.1", "react-google-charts": "^5.1.0", @@ -32,12 +33,6 @@ "test": "jest", "eject": "react-scripts eject" }, - "eslintConfig": { - "extends": [ - "react-app", - "react-app/jest" - ] - }, "browserslist": { "production": [ ">0.2%", diff --git a/frontend/src/service/profileService.js b/frontend/src/service/profileService.js index 14a79dbd..a2e4c8a1 100644 --- a/frontend/src/service/profileService.js +++ b/frontend/src/service/profileService.js @@ -2,7 +2,7 @@ import { apiClient } from './apiClient'; import log from '../utils/logger'; import { transformPost } from './postService'; -const transformProfile = (userData, profile, posts, comments) => { +const transformProfile = async (userData, profile, posts, comments) => { profile = { ...profile, username: userData.username, @@ -15,6 +15,15 @@ const transformProfile = (userData, profile, posts, comments) => { postsCnt: posts.length || 0, commentsCnt: comments.length || 0, }; + + console.log(profile); + profile.following = await Promise.all( + profile.following.map(async (profileId) => await ProfileService.userIdByProfileId(profileId)) + ); + profile.followers = await Promise.all( + profile.followers.map(async (profileId) => await ProfileService.userIdByProfileId(profileId)) + ); + return profile; }; @@ -45,13 +54,7 @@ const ProfileService = { try { const userData = await this.fetchUserById(id); // Convert followers and following from porfile id to user id - userData.following = await Promise.all( - userData.following.map(async (profileId) => await this.userIdByProfileId(profileId)) - ); - userData.followers = await Promise.all( - userData.followers.map(async (profileId) => await this.userIdByProfileId(profileId)) - ); - + const posts = await this.fetchPostsByProfileId(id); const transformedPosts = await Promise.all( @@ -60,7 +63,7 @@ const ProfileService = { const comments = await this.fetchCommentsByProfileId(id); const response = await apiClient.get(`/profiles/by-user-id/${id}/`); - return transformProfile(userData, response.data, transformedPosts, comments); + return await transformProfile(userData, response.data, transformedPosts, comments); } catch (error) { log.error(`Error fetching profile with ID ${id}:`, error); throw error;