summaryrefslogtreecommitdiffstats
path: root/src/features/profile/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/profile/hooks')
-rw-r--r--src/features/profile/hooks/useProfile.ts5
-rw-r--r--src/features/profile/hooks/useUpdateProfile.ts5
2 files changed, 6 insertions, 4 deletions
diff --git a/src/features/profile/hooks/useProfile.ts b/src/features/profile/hooks/useProfile.ts
index 82068f4..2f5278d 100644
--- a/src/features/profile/hooks/useProfile.ts
+++ b/src/features/profile/hooks/useProfile.ts
@@ -4,6 +4,7 @@ import { useEffect, useState } from 'react';
import { useAuthSession } from '@/providers/AuthProvider';
import { profileService } from '@/features/profile/services/profileService';
import { UserProfile } from '@/features/profile/types';
+import { getErrorMessage } from '@/shared/lib/errors/getErrorMessage';
export function useProfile() {
const { user } = useAuthSession();
@@ -25,8 +26,8 @@ export function useProfile() {
const data = await profileService.getMyProfile(user.uid);
setProfile(data);
- } catch (err: any) {
- setError(err?.message ?? 'No se pudo cargar el perfil');
+ } catch (err) {
+ setError(getErrorMessage(err, 'No se pudo cargar el perfil'));
} finally {
setLoading(false);
}
diff --git a/src/features/profile/hooks/useUpdateProfile.ts b/src/features/profile/hooks/useUpdateProfile.ts
index bc069dc..cd4a39a 100644
--- a/src/features/profile/hooks/useUpdateProfile.ts
+++ b/src/features/profile/hooks/useUpdateProfile.ts
@@ -3,6 +3,7 @@
import { useState } from 'react';
import { profileService } from '@/features/profile/services/profileService';
import { useAuthSession } from '@/providers/AuthProvider';
+import { getErrorMessage } from '@/shared/lib/errors/getErrorMessage';
export function useUpdateProfile(initialDisplayName = '', initialPhotoURL = '') {
const { user } = useAuthSession();
@@ -37,8 +38,8 @@ export function useUpdateProfile(initialDisplayName = '', initialPhotoURL = '')
setPhotoURL(photoURL.trim());
setSuccessMessage('Perfil actualizado correctamente');
- } catch (err: any) {
- setError(err?.message ?? 'No se pudo actualizar el perfil');
+ } catch (err) {
+ setError(getErrorMessage(err, 'No se pudo actualizar el perfil'));
} finally {
setIsSubmitting(false);
}