manifold/web/lib/firebase/txns.ts
Sinclair Chen 73fc67955d
Send M$ to Charity & txns (#81)
* Add components for CPM landing and charity pages

* Remove misc.ts to fix build

* Set up cloud function for writing txns

* More plumbing for txns

* Fix up API call

* Use Date.now() to keep timestamps simple

* Some styles for charity list page

* Hard code charities data

* Pass charity data to charity page

* Update txn type

* Listen for charity txns

* Handle txn to non-user by burning it

* Read txns for charity card and charity page.

* Set images to object contain

* Clean up txn types

* Move pic to top of card. Other misc styling.

* Update charity short & long descriptions

* Add `token` and `category` to Txn

* Fix breakages

* Show Charity link in the sidebar

* Fix typing issues

* Fix not reading from the right type

* Switch out icon

* Also show Charity icon on mobile

* Update copy

Co-authored-by: Austin Chen <akrolsmir@gmail.com>
Co-authored-by: James Grugett <jahooma@gmail.com>
2022-04-29 19:35:56 -04:00

24 lines
608 B
TypeScript

import { collection, query, where, orderBy } from 'firebase/firestore'
import _ from 'lodash'
import { Txn } from '../../../common/txn'
import { db } from './init'
import { 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)
}