2021-12-14 05:40:38 +00:00
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
import { Bet, listenForUserBets } from '../lib/firebase/bets'
|
|
|
|
|
2022-02-04 00:13:04 +00:00
|
|
|
export const useUserBets = (userId: string | undefined) => {
|
|
|
|
const [bets, setBets] = useState<Bet[] | undefined>(undefined)
|
2021-12-14 05:40:38 +00:00
|
|
|
|
|
|
|
useEffect(() => {
|
2022-02-04 00:13:04 +00:00
|
|
|
if (userId) return listenForUserBets(userId, setBets)
|
2021-12-14 05:40:38 +00:00
|
|
|
}, [userId])
|
|
|
|
|
|
|
|
return bets
|
|
|
|
}
|