Skip to content

View Poster's Profile#95

Merged
ntur101 merged 1 commit intoSofteng310:mainfrom
kmck133:feature/see-other-profiles
Oct 19, 2025
Merged

View Poster's Profile#95
ntur101 merged 1 commit intoSofteng310:mainfrom
kmck133:feature/see-other-profiles

Conversation

@kmck133
Copy link
Copy Markdown
Collaborator

@kmck133 kmck133 commented Oct 19, 2025

📌 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.

Copilot AI review requested due to automatic review settings October 19, 2025 08:03
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}
Copy link

Copilot AI Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
{userInfo.name}
{userInfo?.name || 'Unknown User'}

Copilot uses AI. Check for mistakes.
const fetchedItems = snapshot.docs.map((doc) =>
normalizeFirestoreItem(doc.data() || {}, doc.id)
)
setUserPosts(fetchedItems)
Copy link

Copilot AI Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
setUserPosts(fetchedItems)
const filteredItems = fetchedItems.filter(item => item.status !== 'resolved')
setUserPosts(filteredItems)

Copilot uses AI. Check for mistakes.
{userData?.profilePic ? (
<img
src={userData.profilePic}
alt={`${userData.name}'s profile`}
Copy link

Copilot AI Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'}.

Suggested change
alt={`${userData.name}'s profile`}
alt={userData?.name ? `${userData.name}'s profile` : 'Profile picture'}

Copilot uses AI. Check for mistakes.
Comment on lines +56 to +62
const itemsRef = collection(db, 'items')
const userDocRef = doc(db, 'users', userId)
const itemsQuery = query(
itemsRef,
where('postedBy', '==', userDocRef),
orderBy('date', 'desc')
)
Copy link

Copilot AI Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copilot uses AI. Check for mistakes.
Comment on lines 20 to +25
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)
Copy link

Copilot AI Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

@ntur101 ntur101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!! love this feature - makes everything come together

@ntur101 ntur101 merged commit 04ded44 into Softeng310:main Oct 19, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: See Other User's Profiles

3 participants