From f5de6ac14c59547dee639b505444223b9a46d3e9 Mon Sep 17 00:00:00 2001
From: im-adithya
Date: Tue, 9 Jul 2024 19:09:00 +0530
Subject: [PATCH] chore: format sat amounts and date
---
frontend/src/components/TransactionItem.tsx | 26 ++++++++++++++++----
frontend/src/components/TransactionsList.tsx | 4 +--
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/frontend/src/components/TransactionItem.tsx b/frontend/src/components/TransactionItem.tsx
index 17048a83..f51cdab8 100644
--- a/frontend/src/components/TransactionItem.tsx
+++ b/frontend/src/components/TransactionItem.tsx
@@ -1,4 +1,6 @@
import dayjs from "dayjs";
+import timezone from "dayjs/plugin/timezone";
+import utc from "dayjs/plugin/utc";
import {
ArrowDownIcon,
ArrowUpIcon,
@@ -21,6 +23,9 @@ import { copyToClipboard } from "src/lib/clipboard";
import { cn } from "src/lib/utils";
import { Transaction } from "src/types";
+dayjs.extend(utc);
+dayjs.extend(timezone);
+
type Props = {
tx: Transaction;
};
@@ -89,9 +94,14 @@ function TransactionItem({ tx }: Props) {
type == "incoming" && "text-green-600 dark:color-green-400"
)}
>
- {type == "outgoing" ? "-" : "+"} {Math.floor(tx.amount / 1000)}
+ {type == "outgoing" ? "-" : "+"}
+ {new Intl.NumberFormat(undefined, {}).format(
+ Math.floor(tx.amount / 1000)
+ )}{" "}
+
+
+ {Math.floor(tx.amount / 1000) == 1 ? "sat" : "sats"}
- sats
{/* {!!tx.totalAmountFiat && (
@@ -130,7 +140,9 @@ function TransactionItem({ tx }: Props) {
- {Math.floor(tx.amount / 1000)}{" "}
+ {new Intl.NumberFormat(undefined, {}).format(
+ Math.floor(tx.amount / 1000)
+ )}{" "}
{Math.floor(tx.amount / 1000) == 1 ? "sat" : "sats"}
{/*
@@ -141,14 +153,18 @@ function TransactionItem({ tx }: Props) {
Date & Time
- {dayjs(tx.settled_at * 1000).toString()}
+ {dayjs(tx.settled_at * 1000)
+ .tz(dayjs.tz.guess())
+ .format("D MMMM YYYY, HH:mm")}
{type == "outgoing" && (
Fee
- {Math.floor(tx.fees_paid / 1000)}{" "}
+ {new Intl.NumberFormat(undefined, {}).format(
+ Math.floor(tx.fees_paid / 1000)
+ )}{" "}
{Math.floor(tx.fees_paid / 1000) == 1 ? "sat" : "sats"}
diff --git a/frontend/src/components/TransactionsList.tsx b/frontend/src/components/TransactionsList.tsx
index f64551c7..41bb28ff 100644
--- a/frontend/src/components/TransactionsList.tsx
+++ b/frontend/src/components/TransactionsList.tsx
@@ -23,8 +23,8 @@ function TransactionsList() {
/>
) : (
<>
- {transactions?.map((tx, i) => {
- return
;
+ {transactions?.map((tx) => {
+ return
;
})}
>
)}