manifold/web/lib/firebase/txns.ts
James Grugett 83ded17625 Revert "Comment tips (#469)"
This reverts commit e567782a7d.
2022-06-17 16:31:21 -05:00

29 lines
747 B
TypeScript

import { collection, query, where, orderBy } from 'firebase/firestore'
import { Txn } from 'common/txn'
import { db } from './init'
import { getValues, listenForValues } from './utils'
const txnCollection = collection(db, 'txns')
const getCharityQuery = (charityId: string) =>
query(
txnCollection,
where('toType', '==', 'CHARITY'),
where('toId', '==', charityId),
orderBy('createdTime', 'desc')
)
export function listenForCharityTxns(
charityId: string,
setTxns: (txns: Txn[]) => void
) {
return listenForValues<Txn>(getCharityQuery(charityId), setTxns)
}
const charitiesQuery = query(txnCollection, where('toType', '==', 'CHARITY'))
export function getAllCharityTxns() {
return getValues<Txn>(charitiesQuery)
}