import { Ionicons } from "@expo/vector-icons"; import { useRouter } from "expo-router"; import { useCallback, useEffect, useState } from "react"; import { ActivityIndicator, Image, Platform, TouchableOpacity, View } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { CalComAPIService, type UserProfile } from "@/services/calcom"; import { getAvatarUrl } from "@/utils/getAvatarUrl"; import { CalComLogo } from "./CalComLogo"; export function Header() { const router = useRouter(); const insets = useSafeAreaInsets(); const [userProfile, setUserProfile] = useState(null); const [loading, setLoading] = useState(true); const fetchUserProfile = useCallback(async () => { try { const profile = await CalComAPIService.getUserProfile(); setUserProfile(profile); setLoading(false); } catch (err) { console.error("Failed to fetch user profile"); if (__DEV__) { const message = err instanceof Error ? err.message : String(err); const stack = err instanceof Error ? err.stack : undefined; console.debug("[Header] fetchUserProfile failed", { message, stack }); } setLoading(false); } }, []); useEffect(() => { fetchUserProfile(); }, [fetchUserProfile]); const handleProfile = () => { // Navigate to profile sheet on all platforms (Android, Web, Extension) router.push("/profile-sheet"); }; return ( {/* Left: Cal.com Logo */} {/* Right: Icons */} {/* Profile Picture */} {loading ? ( ) : userProfile?.avatarUrl ? ( ) : ( )} ); }