Skip to content

Commit

Permalink
Update page.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ArhanAnsari authored Oct 26, 2024
1 parent abb19fe commit 445abc0
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions app/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,19 @@ const ProfilePage = () => {
};

const handleNameChange = async () => {
if (!user) return;

try {
await updateProfile(user, { displayName: name });
await updateUserData(user.email!, { name }); // Update name in Firestore
setNameEditMode(false);
alert("Name updated successfully!");
} catch (error) {
console.error("Error updating name:", error);
alert("Failed to update name. Please try again.");
}
};
if (!user) return;

try {
await updateProfile(user, { displayName: name });
// Update name in Firestore as part of the userData object
await updateUserData(user.email!, { ...userData, name });
setNameEditMode(false);
alert("Name updated successfully!");
} catch (error) {
console.error("Error updating name:", error);
alert("Failed to update name. Please try again.");
}
};

const handleSignOut = () => {
signOut(auth).catch((error) => console.error("Sign out error:", error));
Expand Down

0 comments on commit 445abc0

Please sign in to comment.