-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathTransactions.jsx
More file actions
97 lines (89 loc) · 2.76 KB
/
Copy pathTransactions.jsx
File metadata and controls
97 lines (89 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import React, { useContext } from "react";
import { TransactionContext } from "../context/TransactionContext";
import useFetch from "../hooks/useFetch";
import dummyData from "../utils/dummyData";
import { shortenAddress } from "../utils/shortenAddress";
const TransactionsCard = ({
addressTo,
addressFrom,
timestamp,
message,
keyword,
amount,
url,
}) => {
const gifUrl = useFetch({ keyword });
return (
<div
className="bg-[#181918] m-4 flex flex-1
2xl:min-w-[450px]
2xl:max-w-[500px]
sm:min-w-[270px]
sm:max-w-[300px]
min-w-full
flex-col p-3 rounded-md hover:shadow-2xl"
>
<div className="flex flex-col items-center w-full mt-3">
<div className="display-flex justify-start w-full mb-6 p-2">
<a
href={`https://sepolia.etherscan.io/address/${addressFrom}`}
target="_blank"
rel="noreferrer"
>
<p className="text-white text-base">
From: {shortenAddress(addressFrom)}
</p>
</a>
<a
href={`https://sepolia.etherscan.io/address/${addressTo}`}
target="_blank"
rel="noreferrer"
>
<p className="text-white text-base">
To: {shortenAddress(addressTo)}
</p>
</a>
<p className="text-white text-base">Amount: {amount} ETH</p>
{message && (
<>
<br />
<p className="text-white text-base">Message: {message}</p>
</>
)}
</div>
<img
src={gifUrl || url}
alt="nature"
className="w-full h-64 2xl:h-96 rounded-md shadow-lg object-cover"
/>
<div className="bg-black p-3 px-5 w-max rounded-3xl -mt-5 shadow-2xl">
<p className="text-[#37c7da] font-bold">{timestamp}</p>
</div>
</div>
</div>
);
};
const Transactions = () => {
const { transactions, currentAccount } = useContext(TransactionContext);
return (
<div className="flex w-full justify-center items-center 2xl:px-20 gradient-bg-transactions">
<div className="flex flex-col md:p-12 py-12 px-4">
{currentAccount ? (
<h3 className="text-white text-3xl text-center my-2">
Latest Transactions
</h3>
) : (
<h3 className="text-white text-3xl text-center my-2">
Connect your account to see the latest transactions
</h3>
)}
<div className="flex flex-wrap justify-center items-center mt-10">
{[...dummyData, ...transactions].reverse().map((transaction, i) => (
<TransactionsCard key={i} {...transaction} />
))}
</div>
</div>
</div>
);
};
export default Transactions;