manifold/web/hooks/use-charity-txns.ts

27 lines
562 B
TypeScript
Raw Normal View History

import { useEffect, useState } from 'react'
import { Txn } from '../../common/txn'
import {
listenForAllCharityTxns,
listenForCharityTxns,
} from '../lib/firebase/txns'
export const useCharityTxns = (charityId: string) => {
const [txns, setTxns] = useState<Txn[]>([])
useEffect(() => {
return listenForCharityTxns(charityId, setTxns)
}, [charityId])
return txns
}
export const useAllCharityTxns = () => {
const [txns, setTxns] = useState<Txn[]>([])
useEffect(() => {
return listenForAllCharityTxns(setTxns)
}, [])
return txns
}