manifold/web/hooks/use-users.ts
Austin Chen 37b8cc9687
Show a top 5 leaderboard on resolved markets (#66)
* Show a top5 leaderboard on resolved markets

* Only show profitable traders

* Include sales in profits

* Copy Leaderboard styling

* Also show the top comment and trade

* Fix padding for solo bets

* Only show both comment & bet if they differ
2022-03-20 18:07:45 -07:00

38 lines
738 B
TypeScript

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