From 28a3a5ced7a403586b5ce91769e133105ee7ece4 Mon Sep 17 00:00:00 2001
From: pavanjoshi914
Date: Tue, 26 Sep 2023 14:56:15 +0530
Subject: [PATCH] feat: cleanup regex keep same color for now
---
.../TransactionsTable/index.test.tsx | 6 ++---
.../components/TransactionsTable/index.tsx | 25 +++----------------
src/app/hooks/useTransactions.ts | 8 +++---
3 files changed, 10 insertions(+), 29 deletions(-)
diff --git a/src/app/components/TransactionsTable/index.test.tsx b/src/app/components/TransactionsTable/index.test.tsx
index fd8348386e..cf29b6bf12 100644
--- a/src/app/components/TransactionsTable/index.test.tsx
+++ b/src/app/components/TransactionsTable/index.test.tsx
@@ -118,7 +118,7 @@ describe("TransactionsTable", () => {
expect(screen.getByText("Alby")).toBeInTheDocument();
expect(screen.getByText(/5 days ago/)).toBeInTheDocument();
- expect(await screen.findByText(/- 1,234,000/)).toBeInTheDocument();
+ expect(await screen.findByText(/- 1,234,000 sats/)).toBeInTheDocument();
expect(await screen.findByText(/~\$241.02/)).toBeInTheDocument();
});
@@ -135,7 +135,7 @@ describe("TransactionsTable", () => {
expect(await screen.findByText("lambo lambo")).toBeInTheDocument();
expect(await screen.findByText(/4 days ago/)).toBeInTheDocument();
- expect(await screen.findByText(/\+ 66,666/)).toBeInTheDocument();
+ expect(await screen.findByText(/\+ 66,666 sats/)).toBeInTheDocument();
expect(await screen.findByText(/~\$13.02/)).toBeInTheDocument();
const disclosureButtons = screen.queryByRole("button");
@@ -155,7 +155,7 @@ describe("TransactionsTable", () => {
expect(screen.getByText("dumplings")).toBeInTheDocument();
expect(screen.getByText(/5 days ago/)).toBeInTheDocument();
- expect(await screen.findByText(/\+ 88,888/)).toBeInTheDocument();
+ expect(await screen.findByText(/\+ 88,888 sats/)).toBeInTheDocument();
expect(await screen.findByText(/~\$17.36/)).toBeInTheDocument();
});
});
diff --git a/src/app/components/TransactionsTable/index.tsx b/src/app/components/TransactionsTable/index.tsx
index 101d631f13..2da8dfe25a 100644
--- a/src/app/components/TransactionsTable/index.tsx
+++ b/src/app/components/TransactionsTable/index.tsx
@@ -88,7 +88,7 @@ export default function TransactionsTable({
href={tx.publisherLink}
rel="noopener noreferrer"
>
- {transactionTitle(tx)}
+ {tx.title}
) : (
tx.title ||
@@ -112,12 +112,7 @@ export default function TransactionsTable({
)}
>
{type == "outgoing" ? "-" : "+"}{" "}
- {getFormattedSats(tx.totalAmount).replace(/sats?/g, " ")}
-
- {tCommon("sats", {
- count: Number(tx.totalAmount),
- })}
-
+ {getFormattedSats(tx.totalAmount)}
{!!tx.totalAmountFiat && (
@@ -167,15 +162,7 @@ export default function TransactionsTable({
)}
>
{transaction.type == "sent" ? "-" : "+"}{" "}
- {getFormattedSats(transaction.totalAmount).replace(
- /sats?/g,
- " "
- )}
-
- {tCommon("sats", {
- count: Number(transaction.amount),
- })}
-
+ {getFormattedSats(transaction.totalAmount)}
{!!transaction.totalAmountFiat && (
@@ -279,9 +266,3 @@ export default function TransactionsTable({
>
);
}
-
-function transactionTitle(tx: Transaction) {
- const title = tx.title;
-
- if (title) return title;
-}
diff --git a/src/app/hooks/useTransactions.ts b/src/app/hooks/useTransactions.ts
index d07de8af4e..18ca597bce 100644
--- a/src/app/hooks/useTransactions.ts
+++ b/src/app/hooks/useTransactions.ts
@@ -33,22 +33,22 @@ export const useTransactions = () => {
const _transactions: Transaction[] =
await convertPaymentsToTransactions(payments);
- const finalList: Transaction[] = [..._transactions, ...invoices];
+ const transactionList: Transaction[] = [..._transactions, ...invoices];
- for (const transaction of finalList) {
+ for (const transaction of transactionList) {
transaction.totalAmountFiat = settings.showFiat
? await getFormattedFiat(transaction.totalAmount)
: "";
}
// Sort the final list by date in descending order.
- finalList.sort((a, b) => {
+ transactionList.sort((a, b) => {
const dateA = a.timestamp;
const dateB = b.timestamp;
return dateB - dateA;
});
- setTransactions(finalList);
+ setTransactions(transactionList);
setIsLoadingTransactions(false);
} catch (e) {