Conversation
|
There was a problem hiding this comment.
Pull Request Overview
Adds a public profile view for item reporters and wires navigation from item details to that profile, enabling users to review a poster’s prior submissions.
- Introduces a PublicProfile page that displays basic user info and their posts.
- Links the reporter’s name in ItemDetail to the new public profile route.
- Adds a new route and minor Firestore normalization/variable-scope adjustments.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| frontend/src/pages/PublicProfile.js | New page: fetches user document and live-updating list of items by the user; renders profile header and item cards. |
| frontend/src/pages/ItemDetail.js | Makes reporter’s name clickable, navigating to /profile/:userId. |
| frontend/src/firebase/firestore.js | Avoids shadowing Firestore’s doc function and normalizes kind based on status; filters out resolved posts. |
| frontend/src/App.js | Registers the new /profile/:userId route and imports PublicProfile. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| to={`/profile/${userInfo.id}`} | ||
| className="text-emerald-600 hover:text-emerald-700 hover:underline transition-colors font-medium" | ||
| > | ||
| {userInfo.name} |
There was a problem hiding this comment.
If userInfo.id exists but userInfo.name is undefined or empty, this renders an empty link. Preserve the previous fallback by rendering {userInfo?.name || 'Unknown User'} here.
| {userInfo.name} | |
| {userInfo?.name || 'Unknown User'} |
| const fetchedItems = snapshot.docs.map((doc) => | ||
| normalizeFirestoreItem(doc.data() || {}, doc.id) | ||
| ) | ||
| setUserPosts(fetchedItems) |
There was a problem hiding this comment.
This includes posts with status 'resolved', whereas getUserPosts excludes them. Align behavior by filtering out resolved items before updating state, e.g., filter on the raw snapshot data or normalized item status.
| setUserPosts(fetchedItems) | |
| const filteredItems = fetchedItems.filter(item => item.status !== 'resolved') | |
| setUserPosts(filteredItems) |
| {userData?.profilePic ? ( | ||
| <img | ||
| src={userData.profilePic} | ||
| alt={`${userData.name}'s profile`} |
There was a problem hiding this comment.
If userData.name is missing, the alt text becomes "undefined's profile". Provide a meaningful fallback, e.g., alt={userData?.name ? ${userData.name}'s profile : 'Profile picture'}.
| alt={`${userData.name}'s profile`} | |
| alt={userData?.name ? `${userData.name}'s profile` : 'Profile picture'} |
| const itemsRef = collection(db, 'items') | ||
| const userDocRef = doc(db, 'users', userId) | ||
| const itemsQuery = query( | ||
| itemsRef, | ||
| where('postedBy', '==', userDocRef), | ||
| orderBy('date', 'desc') | ||
| ) |
There was a problem hiding this comment.
[nitpick] This duplicates user-posts query logic that also exists in getUserPosts (with slightly different filtering). Consider centralizing the query/normalization in a shared helper (e.g., userPostsQuery or subscribeToUserPosts) to keep behavior consistent (especially the 'resolved' filter) and reduce divergence.
| if (itemData.status?.toLowerCase() !== 'resolved') { | ||
| posts.push({ | ||
| id: doc.id, | ||
| ...itemData | ||
| id: docSnapshot.id, | ||
| ...itemData, | ||
| // Normalize: if kind is missing, use status field as fallback | ||
| kind: itemData.kind || (itemData.status?.toLowerCase() === 'found' || itemData.status?.toLowerCase() === 'lost' ? itemData.status : undefined) |
There was a problem hiding this comment.
[nitpick] status?.toLowerCase() is computed multiple times. Cache it once to simplify and avoid repeated calls, e.g., const status = itemData.status?.toLowerCase(); then compare against status in both the filter and normalization.
ntur101
left a comment
There was a problem hiding this comment.
LGTM!! love this feature - makes everything come together



📌 Description
Made it so when you click on the username of who posted in the item detail page, it shows the poster's profile and their previous posts. This will allow the user to see previous things the poster has put up for reliability verification.
🔗 Related Issue(s)
Closes #94
✅ Changes
Added the ability to see other user's profiles and their posts.
🧪 How to Test
Go to the details page of an item, and click on the username of who posted it to show their profile.