manifold/web/hooks/use-charity-txns.ts
Sinclair Chen db695875c4
CPM: sort charities by amount raised (#117)
* Sort charities by amount raised (after Featured)

* Sort donations chronologically

* refactor charities query to remove parens
2022-05-02 10:55:40 -07:00

27 lines
562 B
TypeScript

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
}