Sort contracts by creation time
This commit is contained in:
parent
4f2c8bcdce
commit
70e86155be
|
@ -9,6 +9,7 @@ import {
|
||||||
query,
|
query,
|
||||||
getDocs,
|
getDocs,
|
||||||
onSnapshot,
|
onSnapshot,
|
||||||
|
orderBy,
|
||||||
} from 'firebase/firestore'
|
} from 'firebase/firestore'
|
||||||
|
|
||||||
export type Contract = {
|
export type Contract = {
|
||||||
|
@ -57,7 +58,11 @@ export async function deleteContract(contractId: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function listContracts(creatorId: string): Promise<Contract[]> {
|
export async function listContracts(creatorId: string): Promise<Contract[]> {
|
||||||
const q = query(contractCollection, where('creatorId', '==', creatorId))
|
const q = query(
|
||||||
|
contractCollection,
|
||||||
|
where('creatorId', '==', creatorId),
|
||||||
|
orderBy('createdTime', 'desc')
|
||||||
|
)
|
||||||
const snapshot = await getDocs(q)
|
const snapshot = await getDocs(q)
|
||||||
const contracts: Contract[] = []
|
const contracts: Contract[] = []
|
||||||
snapshot.forEach((doc) => contracts.push(doc.data() as Contract))
|
snapshot.forEach((doc) => contracts.push(doc.data() as Contract))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user