diff options
| author | Alberto Duarte Delgado <alberto@albertoduarte.com> | 2026-04-01 00:56:41 +0100 |
|---|---|---|
| committer | Alberto Duarte Delgado <alberto@albertoduarte.com> | 2026-04-01 00:56:41 +0100 |
| commit | bd4a70dab890153617cad4e0be1364941993d51d (patch) | |
| tree | 5242c256c3e96f8768b29907716fb1274eb9c1fb /src/features/profile | |
| parent | dac9dc1ae6b3531c93801360147100950a103692 (diff) | |
firestore rules y logica de cancelación de reservas
Diffstat (limited to 'src/features/profile')
| -rw-r--r-- | src/features/profile/services/profileService.ts | 12 |
1 files changed, 7 insertions, 5 deletions
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<void> { 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 } : {}), }); |