26 lines
588 B
TypeScript
26 lines
588 B
TypeScript
import _ from 'lodash'
|
|
import { useEffect, useState } from 'react'
|
|
import {
|
|
Contract,
|
|
listenForContracts,
|
|
listenForHotContracts,
|
|
} from '../lib/firebase/contracts'
|
|
|
|
export const useContracts = () => {
|
|
const [contracts, setContracts] = useState<Contract[] | 'loading'>('loading')
|
|
|
|
useEffect(() => {
|
|
return listenForContracts(setContracts)
|
|
}, [])
|
|
|
|
return contracts
|
|
}
|
|
|
|
export const useHotContracts = () => {
|
|
const [hotContracts, setHotContracts] = useState<Contract[] | undefined>()
|
|
|
|
useEffect(() => listenForHotContracts(setHotContracts), [])
|
|
|
|
return hotContracts
|
|
}
|