morethanadiagnosis-hub/mobile/hooks/useUser.ts
fullsizemalt 5bc3ca1832 feat: integrate React Query and configure build profiles
- Add React Query provider and client
- Create reusable UI components (Loading, Error, Empty)
- Implement custom hooks with fallback data
- Integrate hooks into Resources and Community screens
- Add pull-to-refresh support
- Configure EAS Build profiles and environment variables
2025-11-18 12:36:52 -08:00

35 lines
897 B
TypeScript

import { useQuery } from '@tanstack/react-query';
export interface UserProfile {
id: string;
name: string;
email: string;
avatarUrl?: string;
bio?: string;
}
const FALLBACK_USER: UserProfile = {
id: '1',
name: 'Alex Johnson',
email: 'alex.johnson@example.com',
bio: 'On a journey to better mental health.',
};
async function fetchUserProfile(): Promise<UserProfile> {
// Simulate API call
// const response = await fetch(`${process.env.EXPO_PUBLIC_API_URL}/user/profile`);
// if (!response.ok) throw new Error('Failed to fetch user profile');
// return response.json();
// Return fallback data for now
return new Promise((resolve) => {
setTimeout(() => resolve(FALLBACK_USER), 500);
});
}
export function useUser() {
return useQuery({
queryKey: ['user-profile'],
queryFn: fetchUserProfile,
});
}