mirror of
https://github.com/urosran/cally.git
synced 2025-07-15 01:35:22 +00:00
added Feedback page, added braindump backend
This commit is contained in:
28
hooks/firebase/useGetFeedbacks.ts
Normal file
28
hooks/firebase/useGetFeedbacks.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { useAuthContext } from "@/contexts/AuthContext";
|
||||
import { useQuery } from "react-query";
|
||||
import firestore from "@react-native-firebase/firestore";
|
||||
import { IFeedback } from "@/contexts/FeedbackContext";
|
||||
|
||||
export const useGetFeedbacks = () => {
|
||||
const { user: currentUser } = useAuthContext();
|
||||
|
||||
return useQuery<IFeedback[]>({
|
||||
queryKey: ["feedbacks", currentUser?.uid],
|
||||
queryFn: async () => {
|
||||
try {
|
||||
const snapshot = await firestore()
|
||||
.collection("Feedbacks")
|
||||
.where("creatorId", "==", currentUser?.uid)
|
||||
.get();
|
||||
|
||||
return snapshot.docs.map((doc) => ({
|
||||
...doc.data(),
|
||||
})) as IFeedback[];
|
||||
} catch (error) {
|
||||
console.error("Error fetching feedbacks:", error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
enabled: !!currentUser?.uid, // Only run query if we have a user ID
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user