diff --git a/src/pages/test firestore/TestFirestore.tsx b/src/pages/test firestore/TestFirestore.tsx index c569717..ba10d12 100644 --- a/src/pages/test firestore/TestFirestore.tsx +++ b/src/pages/test firestore/TestFirestore.tsx @@ -3,7 +3,7 @@ import {auth} from "../../utils/firebase.ts"; import {useState} from "react"; import { deleteTransaction, - getTransactions, + getTransactionsFilterOrderBy, overwriteTransaction, Transaction, writeNewTransaction @@ -12,6 +12,7 @@ import {faker, fakerEN_GB} from "@faker-js/faker"; import {getCurrentBalance} from "../../utils/transaction_utils.ts"; import {signInWithGoogle} from "../../utils/authentication.ts"; import {Header} from "../../components/Header.tsx"; +import { orderBy } from "firebase/firestore"; function writeSampleData() { if (auth.currentUser === null) { @@ -25,7 +26,7 @@ function writeSampleData() { parseFloat(faker.finance.amount({min: -1000, max: 1000})), faker.word.noun(), faker.finance.currency().code, - faker.date.past().toISOString(), + faker.date.past().valueOf(), faker.lorem.sentence(), faker.internet.emoji(), faker.word.noun(), @@ -68,7 +69,7 @@ export function TestFirestorePage() { ; } - getTransactions(auth.currentUser).then((t) => setTransactions(t)); + getTransactionsFilterOrderBy(auth.currentUser, orderBy("dateTime", "desc")).then((t) => setTransactions(t)); getCurrentBalance(auth.currentUser).then((b) => setBalance(b)); return ( @@ -92,12 +93,13 @@ export function TestFirestorePage() { Transactions:

{ - transactions.map((t) =>
+ transactions.map((t) =>
+

{new Date(t.dateTime).toISOString()}