feat: add public profile page with clickable leaderboard#38
feat: add public profile page with clickable leaderboard#38Aharshi3614 wants to merge 2 commits into
Conversation
|
@Aharshi3614 is attempting to deploy a commit to the rishabhjtripathi2903-3434's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughPublic user profile pages added: backend schema gains ChangesPublic User Profile Feature
Sequence DiagramsequenceDiagram
participant User
participant Leaderboard
participant App
participant BrowserHash
participant ProfileAPI
participant ProfileView
User->>Leaderboard: clicks a username
Leaderboard->>App: onProfileClick(userId)
App->>BrowserHash: set hash "profile/<userId>"
BrowserHash->>App: hashchange -> parse userId
App->>ProfileView: render with userId
ProfileView->>ProfileAPI: GET /api/users/:userId/profile
ProfileAPI-->>ProfileView: profile data
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tree_output.txt (1)
1-255:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRemove auto-generated tree listing from version control.
This file appears to be an auto-generated directory listing unrelated to the profile page feature. Directory tree outputs typically become stale as the repository evolves and should not be committed to version control.
🧹 Recommended fix
- Remove the file from the repository:
git rm tree_output.txt
- Add it to
.gitignoreto prevent future accidental commits:+# Tree output files +tree_output.txt🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tree_output.txt` around lines 1 - 255, The repo contains an auto-generated file tree_output.txt that should not be versioned; remove it from Git and prevent re-adding by updating ignore rules: run git rm to remove tree_output.txt and then add an entry for tree_output.txt (or a pattern) to .gitignore so future commits don't include the auto-generated listing; update any commit that introduced tree_output.txt if needed to keep history clean.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/src/sections/ProfileView.tsx`:
- Around line 52-55: The catch block currently treats every fetch failure as
"not found" by calling setNotFound(true); instead add a separate error state
(e.g., setError / error state variable) and only setNotFound(true) when the HTTP
response indicates a 404; for other failures set the error state and log the
error. Locate the profile-loading routine (the async function in ProfileView,
e.g., fetchProfile / the useEffect that calls it) and change the logic so you
inspect response.status (or the thrown HttpError) to decide: if status === 404
call setNotFound(true), else call setError(error) and do not mark not-found;
apply the same change to the other fetch block referenced around lines 102-107
to keep consistent behavior.
In `@backend/src/controllers/userController.ts`:
- Around line 172-192: The PUT profile response is missing memberSince which the
frontend expects; update the res.status(200).json response in userController.ts
(the block that returns data after the update using the updated variable) to
include memberSince (derived from updated.memberSince or updated.createdAt as
appropriate) alongside id, name, avatar, bio, xp, streak, and solved so the
saved profile payload matches the GET profile schema and fixes the profile
header replacement.
---
Outside diff comments:
In `@tree_output.txt`:
- Around line 1-255: The repo contains an auto-generated file tree_output.txt
that should not be versioned; remove it from Git and prevent re-adding by
updating ignore rules: run git rm to remove tree_output.txt and then add an
entry for tree_output.txt (or a pattern) to .gitignore so future commits don't
include the auto-generated listing; update any commit that introduced
tree_output.txt if needed to keep history clean.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e4549feb-67b8-4adb-86bc-d1e982d55a6f
📒 Files selected for processing (7)
app/src/App.tsxapp/src/sections/Leaderboard.tsxapp/src/sections/ProfileView.tsxbackend/prisma/schema.prismabackend/src/controllers/userController.tsbackend/src/routes/userRoutes.tstree_output.txt
| } catch (error) { | ||
| console.error('Failed to fetch profile', error); | ||
| setNotFound(true); | ||
| } finally { |
There was a problem hiding this comment.
Don’t render “Profile not found” for non-404 failures.
Line 54 marks every fetch failure as not-found, so server/network errors are misreported as missing users. Keep a separate error state and reserve not-found UI for true 404 responses.
Proposed fix
const [notFound, setNotFound] = useState(false);
+ const [loadError, setLoadError] = useState(false);
useEffect(() => {
const fetchProfile = async () => {
setLoading(true);
setNotFound(false);
+ setLoadError(false);
try {
const res = await fetch(`${API_BASE_URL}/api/users/${userId}/profile`);
if (res.status === 404) {
setNotFound(true);
return;
}
+ if (!res.ok) {
+ setLoadError(true);
+ return;
+ }
- if (res.ok) {
- const data = await res.json();
- setProfile(data);
- setEditBio(data.bio || '');
- setEditAvatarUrl(data.avatar || '');
- }
+ const data = await res.json();
+ setProfile(data);
+ setEditBio(data.bio || '');
+ setEditAvatarUrl(data.avatar || '');
} catch (error) {
console.error('Failed to fetch profile', error);
- setNotFound(true);
+ setLoadError(true);
} finally {
setLoading(false);
}
};Also applies to: 102-107
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@app/src/sections/ProfileView.tsx` around lines 52 - 55, The catch block
currently treats every fetch failure as "not found" by calling
setNotFound(true); instead add a separate error state (e.g., setError / error
state variable) and only setNotFound(true) when the HTTP response indicates a
404; for other failures set the error state and log the error. Locate the
profile-loading routine (the async function in ProfileView, e.g., fetchProfile /
the useEffect that calls it) and change the logic so you inspect response.status
(or the thrown HttpError) to decide: if status === 404 call setNotFound(true),
else call setError(error) and do not mark not-found; apply the same change to
the other fetch block referenced around lines 102-107 to keep consistent
behavior.
Description
Adds public profile pages that users can view by clicking on any user in the leaderboard.
Changes
/api/users/:userId/profileGET and PUT endpointsbiofield to User model in PrismaProfileView.tsxcomponentTesting
Closes #22
Summary by CodeRabbit
New Features
Backend