import { useState, useEffect } from 'react' import { PrivateUser, User } from 'common/user' import { getUser, listenForAllUsers, listenForPrivateUsers, } from 'web/lib/firebase/users' export const useUsers = () => { const [users, setUsers] = useState([]) useEffect(() => { listenForAllUsers(setUsers) }, []) return users } export const useUserById = (userId?: string) => { const [user, setUser] = useState(undefined) useEffect(() => { if (userId) { getUser(userId).then(setUser) } }, [userId]) return user } export const usePrivateUsers = () => { const [users, setUsers] = useState([]) useEffect(() => { listenForPrivateUsers(setUsers) }, []) return users }