From af389f762df5f5a41b1c302929461252e5548143 Mon Sep 17 00:00:00 2001
From: daniel-vahn
Date: Fri, 26 Apr 2024 10:41:51 +0200
Subject: [PATCH] Update balance display in App.tsx and fetch fiat value in
TransactionHistoryItem.tsx
---
src/App.tsx | 9 ++++----
.../utils/TransactionHistoryItem.tsx | 22 ++++++++++++++-----
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/src/App.tsx b/src/App.tsx
index 69f1e5c..f953c84 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -295,7 +295,7 @@ function App() {
$
- 250
+ {balance || 0}
@@ -317,10 +317,9 @@ function App() {
{/* = ({
currency,
symbol,
valueSpot,
- valueFiat,
}) => {
+ const [valueFiat, setValueFiat] = useState(0);
+
+ const getFiatValue = async () => {
+ const response = await fetch(
+ `https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd`
+ );
+ const data = await response.json();
+ setValueFiat(Number((data.ethereum.usd * valueSpot).toFixed(2)));
+ };
+
+ useEffect(() => {
+ getFiatValue();
+ }, []);
+
return (
-
+