Skip to content

Commit

Permalink
feat: cleanup regex keep same color for now
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanjoshi914 committed Sep 26, 2023
1 parent c27f5c0 commit 28a3a5c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
6 changes: 3 additions & 3 deletions src/app/components/TransactionsTable/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand All @@ -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");
Expand All @@ -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();
});
});
25 changes: 3 additions & 22 deletions src/app/components/TransactionsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default function TransactionsTable({
href={tx.publisherLink}
rel="noopener noreferrer"
>
{transactionTitle(tx)}
{tx.title}
</a>
) : (
tx.title ||
Expand All @@ -112,12 +112,7 @@ export default function TransactionsTable({
)}
>
{type == "outgoing" ? "-" : "+"}{" "}
{getFormattedSats(tx.totalAmount).replace(/sats?/g, " ")}
<span className=" text-gray-800 dark:text-neutral-400">
{tCommon("sats", {
count: Number(tx.totalAmount),
})}
</span>
{getFormattedSats(tx.totalAmount)}
</p>

{!!tx.totalAmountFiat && (
Expand Down Expand Up @@ -167,15 +162,7 @@ export default function TransactionsTable({
)}
>
{transaction.type == "sent" ? "-" : "+"}{" "}
{getFormattedSats(transaction.totalAmount).replace(
/sats?/g,
" "
)}
<span className=" text-gray-800 dark:text-neutral-400">
{tCommon("sats", {
count: Number(transaction.amount),
})}
</span>
{getFormattedSats(transaction.totalAmount)}
</p>

{!!transaction.totalAmountFiat && (
Expand Down Expand Up @@ -279,9 +266,3 @@ export default function TransactionsTable({
</>
);
}

function transactionTitle(tx: Transaction) {
const title = tx.title;

if (title) return title;
}
8 changes: 4 additions & 4 deletions src/app/hooks/useTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 28a3a5c

Please sign in to comment.