Update fetchUserProfile to return profile
cgen-0c449a09ced44482ac833ff1062417cd
This commit is contained in:
parent
21e90fcbb5
commit
dd50cc9ea7
1 changed files with 4 additions and 2 deletions
|
|
@ -113,20 +113,22 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
|
||||||
return () => subscription.unsubscribe();
|
return () => subscription.unsubscribe();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const fetchUserProfile = async (userId: string) => {
|
const fetchUserProfile = async (userId: string): Promise<AethexUserProfile | null> => {
|
||||||
if (!isSupabaseConfigured) {
|
if (!isSupabaseConfigured) {
|
||||||
// Initialize demo data and get profile
|
// Initialize demo data and get profile
|
||||||
DemoStorageService.initializeDemoData();
|
DemoStorageService.initializeDemoData();
|
||||||
const demoProfile = DemoStorageService.getUserProfile();
|
const demoProfile = DemoStorageService.getUserProfile();
|
||||||
setProfile(demoProfile as AethexUserProfile);
|
setProfile(demoProfile as AethexUserProfile);
|
||||||
return;
|
return demoProfile as AethexUserProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const userProfile = await aethexUserService.getCurrentUser();
|
const userProfile = await aethexUserService.getCurrentUser();
|
||||||
setProfile(userProfile);
|
setProfile(userProfile);
|
||||||
|
return userProfile;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching user profile:', error);
|
console.error('Error fetching user profile:', error);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue