37b8cc9687
* 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
38 lines
738 B
TypeScript
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
|
|
}
|