Skip to content

Added Profile Page#68

Open
Bhoomi-18 wants to merge 1 commit intoCoderUzumaki:mainfrom
Bhoomi-18:added-profile-page
Open

Added Profile Page#68
Bhoomi-18 wants to merge 1 commit intoCoderUzumaki:mainfrom
Bhoomi-18:added-profile-page

Conversation

@Bhoomi-18
Copy link
Copy Markdown
Contributor

Description

This PR has added a profile page to the project with the option to delete the account.

Fixes #12

Type of Change

  • Bug fix
  • New feature
  • Refactoring
  • Documentation update
  • CI/CD update
  • Other (please describe):

Changes Made

  • Added a profile page
  • Added a account delete option

Screenshots (if applicable)

Screen.Recording.2025-08-05.165513.mp4

Environment Variables

  • I have added/updated environment variables
  • I have documented them in the .env.example

No new environment variables needed.

Checklist

  • My code follows the project's coding style
  • I have tested my changes locally
  • I have linked the related issue
  • I have added necessary documentation (if any)
  • I have not included any sensitive data in this PR

Contributor: @Bhoomi-18

@vercel
Copy link
Copy Markdown

vercel bot commented Aug 5, 2025

@Bhoomi-18 is attempting to deploy a commit to the coderuzumaki's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link
Copy Markdown

vercel bot commented Aug 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
prepedge_ai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2025 7:52pm

Copy link
Copy Markdown

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

This PR adds a comprehensive profile page with user profile management capabilities and account deletion functionality. The implementation includes both frontend UI components and backend API endpoints to support profile operations.

Key changes:

  • Added profile page with editable user information and account deletion
  • Implemented backend API routes for profile updates, user retrieval, and account deletion
  • Enhanced authentication context with user data management and refresh functionality

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
server/routes/authRoutes.js Added three new API endpoints: update profile, delete account, and get user profile
server/index.js Updated CORS configuration to support both production and local development origins
server/config/db.js Simplified MongoDB connection by removing deprecated options
client/src/routes.jsx Added new profile page route with protected access
client/src/pages/ProfilePage.jsx Created comprehensive profile page component with edit functionality and account deletion
client/src/context/AuthContext.jsx Enhanced auth context with user token management and refresh capabilities
client/src/components/Header.jsx Updated header component to include profile navigation and improved logout handling
Files not reviewed (1)
  • client/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

client/src/components/Header.jsx:149

  • The profile dropdown menu includes a profile link, but there's no visible 'Profile' option being rendered in this diff. Ensure the profile navigation is properly implemented in the dropdown menu.
          {isMobileMenuOpen && (

try {
const user = await User.findOneAndDelete({ firebase_user_id: uid });
if (!user) return res.status(404).json({ error: "User not found" });
await admin.auth().deleteUser(uid); // Delete Firebase user
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The Firebase user deletion should happen before the database deletion to prevent orphaned Firebase users if the database operation fails. Consider reversing the order or implementing proper transaction handling.

Suggested change
await admin.auth().deleteUser(uid); // Delete Firebase user
// Delete Firebase user first
await admin.auth().deleteUser(uid);
// Then delete from local database
const user = await User.findOneAndDelete({ firebase_user_id: uid });
if (!user) return res.status(404).json({ error: "User not found" });

Copilot uses AI. Check for mistakes.
{ id: 2, action: "Commented on State Management article", date: "Jul 30, 2025" },
{ id: 3, action: "Joined Practice Room", date: "Jul 28, 2025" },
];

Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The recent activity data is hardcoded. Consider fetching this data from an API endpoint or making it configurable to display actual user activity.

Suggested change
const [recentActivity, setRecentActivity] = useState([]);
const [activityLoading, setActivityLoading] = useState(true);
const [activityError, setActivityError] = useState("");
useEffect(() => {
const fetchRecentActivity = async () => {
setActivityLoading(true);
setActivityError("");
try {
const res = await axios.get(
`${import.meta.env.VITE_API_URL}/api/user/activity`,
{
headers: { Authorization: `Bearer ${user.token}` },
withCredentials: true,
}
);
setRecentActivity(res.data.activities || []);
} catch (err) {
setActivityError("Failed to load recent activity.");
} finally {
setActivityLoading(false);
}
};
if (user && user.token) {
fetchRecentActivity();
}
}, [user]);

Copilot uses AI. Check for mistakes.
theme: "Light Mode",
notifications: true,
language: "English",
};
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The preferences object is hardcoded. Consider fetching user preferences from the backend or implementing a preferences management system.

Suggested change
};
// Fetch user preferences from backend
import { useEffect } from "react";
useEffect(() => {
const fetchPreferences = async () => {
setPreferencesLoading(true);
setPreferencesError("");
try {
const res = await axios.get(
`${import.meta.env.VITE_API_URL}/api/user/preferences`,
{
headers: { Authorization: `Bearer ${user.token}` },
withCredentials: true,
}
);
setPreferences(res.data);
} catch (err) {
setPreferencesError("Failed to load preferences.");
setPreferences(null);
} finally {
setPreferencesLoading(false);
}
};
if (user && user.token) {
fetchPreferences();
}
}, [user]);

Copilot uses AI. Check for mistakes.
});

setMessage("Account deleted. Redirecting...");
setTimeout(() => navigate("/login"), 1500);
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

After account deletion, the user should be logged out through the auth context rather than just navigating to login. This ensures proper cleanup of auth state.

Suggested change
setTimeout(() => navigate("/login"), 1500);
setTimeout(() => logout(), 1500);

Copilot uses AI. Check for mistakes.

const confirmLogout = async () => {
// If you have a delete endpoint, replace this with axios call
// await axios.delete("/api/user/delete", { headers: { Authorization: `Bearer ${user.token}` } });
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The confirmLogout function contains commented code that suggests account deletion logic, but this function should only handle logout. The account deletion logic is misplaced and could cause confusion.

Suggested change
// await axios.delete("/api/user/delete", { headers: { Authorization: `Bearer ${user.token}` } });

Copilot uses AI. Check for mistakes.
@Bhoomi-18
Copy link
Copy Markdown
Contributor Author

@CoderUzumaki please review the pr

@CoderUzumaki
Copy link
Copy Markdown
Owner

Hey @Bhoomi-18 ,

Currently this PR can not be merged as it requires some changes mentioned below:

  1. Values are hard-coded, which is not suitable for a dynamic website like PrepEdge AI, You should use backend APIs to fetch relevant data, to show.

  2. Use values/attributes that are actually applicable and available in our website.
    for example, there is no quiz, or an option to comment on articles etc, so instead of these you may want to include last 3-4 interviews that user had given as recent activity.

Please make the necessary changes for this PR to be merged. If you face any issues feel free to contact me.

Thank you for your contribution, I am looking forward for your updated PR.

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.

Design a profile page

3 participants