-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e547ef
commit 4b0bfae
Showing
3 changed files
with
29 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/apps/marmalade-marketplace/src/utils/fetchOnSaleTokens.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { NonFungibleTokenBalance } from '@/graphql/queries/client'; | ||
import { database } from '@/utils/firebase'; | ||
import { collection, getDocs, query, where } from 'firebase/firestore'; | ||
import { Dispatch, SetStateAction } from 'react'; | ||
|
||
export const fetchOnSaleTokens = async ( | ||
accountName: string, | ||
cb: Dispatch<SetStateAction<NonFungibleTokenBalance[]>>, | ||
) => { | ||
if (accountName) { | ||
//const querySnapshot = await getDocs(query(collection(database, 'sales'))); | ||
const salesRef = collection(database, 'sales'); | ||
const q = await query(salesRef, where('seller.account', '==', accountName)); | ||
const querySnapshot = await getDocs(q); | ||
|
||
const docs: NonFungibleTokenBalance[] = []; | ||
querySnapshot.forEach((doc) => { | ||
docs.push(doc.data() as NonFungibleTokenBalance); | ||
}); | ||
cb(docs); | ||
} | ||
}; |