From bd4a70dab890153617cad4e0be1364941993d51d Mon Sep 17 00:00:00 2001 From: Alberto Duarte Delgado Date: Wed, 1 Apr 2026 00:56:41 +0100 Subject: firestore rules y logica de cancelación de reservas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/profile/services/profileService.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/features/profile') diff --git a/src/features/profile/services/profileService.ts b/src/features/profile/services/profileService.ts index 566c3fa..f7e89b4 100644 --- a/src/features/profile/services/profileService.ts +++ b/src/features/profile/services/profileService.ts @@ -1,6 +1,6 @@ // src/features/profile/services/profileService.ts -import { doc, getDoc, updateDoc } from 'firebase/firestore'; +import { doc, getDoc, setDoc } from 'firebase/firestore'; import { updateProfile } from 'firebase/auth'; import { db, auth } from '@/shared/lib/firebase/config'; import { UserProfile } from '@/features/profile/types'; @@ -29,14 +29,16 @@ export const profileService = { photoURL?: string; }): Promise { const { uid, displayName, photoURL } = params; + const currentUser = auth.currentUser; - await updateDoc(doc(db, 'users', uid), { + await setDoc(doc(db, 'users', uid), { + email: currentUser?.email ?? '', displayName, ...(photoURL !== undefined ? { photoURL } : {}), - }); + }, { merge: true }); - if (auth.currentUser) { - await updateProfile(auth.currentUser, { + if (currentUser) { + await updateProfile(currentUser, { displayName, ...(photoURL !== undefined ? { photoURL } : {}), }); -- cgit v1.2.3-54-g00ecf