2022-04-29 23:35:56 +00:00
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
import { Txn } from '../../common/txn'
|
2022-05-02 17:55:40 +00:00
|
|
|
import {
|
|
|
|
listenForAllCharityTxns,
|
|
|
|
listenForCharityTxns,
|
|
|
|
} from '../lib/firebase/txns'
|
2022-04-29 23:35:56 +00:00
|
|
|
|
|
|
|
export const useCharityTxns = (charityId: string) => {
|
|
|
|
const [txns, setTxns] = useState<Txn[]>([])
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
return listenForCharityTxns(charityId, setTxns)
|
|
|
|
}, [charityId])
|
|
|
|
|
|
|
|
return txns
|
|
|
|
}
|
2022-05-02 17:55:40 +00:00
|
|
|
|
|
|
|
export const useAllCharityTxns = () => {
|
|
|
|
const [txns, setTxns] = useState<Txn[]>([])
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
return listenForAllCharityTxns(setTxns)
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
return txns
|
|
|
|
}
|