import { useQuery } from "@tanstack/react-query"; import { UserProfile } from "@/hooks/firebase/types/profileTypes"; import firestore from "@react-native-firebase/firestore"; export const useGetUserById = (uid: string | undefined) => { return useQuery({ queryKey: ["getUserById", uid], queryFn: async (): Promise => { if (!uid) return null; try { const doc = await firestore() .collection("Profiles") .doc(uid) .get(); if (!doc.exists) return null; const data = doc.data(); return { ...data, uid: doc.id, } as UserProfile; } catch (error) { console.error("Error retrieving user:", error); return null; } }, enabled: !!uid }); };