-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IWB-1: added useBlacklist hook (#289)
* added blacklist hook * removed transaction and hope that it works * fixed useBlackList.js hook firestore error, and made blacklist check functional * added refresh spinner for chooseTeam.js * kinda works lmao * minor comment change Co-authored-by: Jake Gehrke <91503842+Gehrkej@users.noreply.github.com> * fix - added email to blacklist record * fix - added assertion if pfp exists when removing a user * fixed "invalid-argument" * removed redundant remove user fix * pretty * added missing state from merge * simple fix --------- Co-authored-by: Jake Gehrke <91503842+Gehrkej@users.noreply.github.com> Co-authored-by: Jake Gehrke <gehrkej@oregonstate.edu>
- Loading branch information
1 parent
088c141
commit 76fb5c7
Showing
3 changed files
with
52 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { collection, getDocs } from "firebase/firestore"; | ||
import { useAuthContext } from "~/context/Auth"; | ||
import { db } from "~/firebaseConfig"; | ||
|
||
export const useBlackList = ({ enabled = true } = {}) => { | ||
const { currentTeamId } = useAuthContext(); | ||
|
||
const { data, error, isLoading } = useQuery({ | ||
queryKey: ["blacklist"], | ||
queryFn: async () => { | ||
console.log("fetching blacklist"); | ||
const newBlacklist = {}; | ||
// Fetch blacklist | ||
const querySnapshot = await getDocs( | ||
collection(db, "teams", currentTeamId, "blacklist"), | ||
); | ||
querySnapshot.forEach((doc) => { | ||
newBlacklist[doc.id] = doc.data(); | ||
}); | ||
return newBlacklist; | ||
}, | ||
enabled, | ||
}); | ||
|
||
return { | ||
data, | ||
error, | ||
isLoading, | ||
}; | ||
}; |