-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build pending transactions tab for tETH
- Loading branch information
Showing
14 changed files
with
660 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,108 @@ | ||
import { useState } from 'react'; | ||
import { ethers } from 'ethers'; | ||
import { Arrow } from "@/app/components/icons"; | ||
import { useState } from "react"; | ||
import { ethers } from "ethers"; | ||
import { Arrow } from "@/app/components/icons"; | ||
import { TransactionIcon, ActivityBoxIcon } from "../icons"; | ||
import { timeAgo } from "@/lib/activityUtils"; | ||
import Skeleton from 'react-loading-skeleton'; | ||
import { TransactionDetails } from "../TransactionDetails"; | ||
import { useTransaction } from "../TransactionPool" | ||
import Skeleton from "react-loading-skeleton"; | ||
import { TransactionDetails } from "../TransactionDetails"; | ||
import { useTransaction } from "../TransactionPool"; | ||
import { Tabs } from "./index"; | ||
import "./activity.css"; | ||
import { useWallets } from '@/app/hooks/useWallets'; | ||
import "./activity.css"; | ||
import { useWallets } from "@/app/hooks/useWallets"; | ||
|
||
export const ActivityContent = ({ setActiveTab }: {setActiveTab: React.Dispatch<React.SetStateAction<Tabs>>}) => { | ||
export const ActivityContent = ({ setActiveTab }: { setActiveTab: React.Dispatch<React.SetStateAction<Tabs>> }) => { | ||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false); | ||
const [currentTx, setCurrentTx] = useState<any>(null); | ||
const { transactions, deposits } = useTransaction(); | ||
|
||
const { evmWallet } = useWallets(); | ||
|
||
if (!evmWallet) { | ||
setActiveTab(Tabs.Deposit); | ||
return <></> | ||
if (!evmWallet) { | ||
setActiveTab(Tabs.Deposit); | ||
return <></>; | ||
} | ||
return ( | ||
|
||
return ( | ||
<> | ||
<div className={isModalOpen ? "status-overlay active" : "status-overlay"}></div> | ||
<div className="activity-container"> | ||
{evmWallet && deposits && deposits.map((tx, index) => { | ||
const status = Number(tx.isError) | ||
? "failed" | ||
: transactions.get(tx.hash)?.pdaData | ||
? "completed" | ||
: (transactions.get(tx.hash)?.pdaData === undefined) | ||
? null | ||
: "loading"; | ||
return ( | ||
<div key={index} className="deposit-transaction flex flex-row items-center" onClick={() => { setIsModalOpen(true); setCurrentTx(tx)}}> | ||
<img src="swap.png" alt="Swap" className="swap-image" style={{position: "absolute", width: "22px"}} hidden /> | ||
<img src="eth.png" alt="Ethereum" style={{ objectFit: "cover", height: "53px", width: "53px", marginLeft: "5px", marginRight: "16px"}} /> | ||
<div className="flex flex-col justify-center" style={{width: "85%"}}> | ||
<div className="transaction-top flex justify-between"> | ||
<div className="flex tx-age" style={{ gap: "7px"}}> | ||
<span className="gray-in">Deposit</span> | ||
<span className="gray-in">•</span> | ||
<span className="gray-in">{timeAgo(Number(tx.timeStamp))}</span> | ||
</div> | ||
<div className={`flex flex-row items-center status-div ${status}`}> | ||
{(status) | ||
? <><TransactionIcon iconType={status}/> | ||
<span>{status === "loading" ? "depositing" : status}</span></> | ||
: <Skeleton height={15} width={91} /> | ||
} | ||
</div> | ||
</div> | ||
<div className="transaction-bottom flex justify-between"> | ||
<div className="flex flex-row items-center eth-to-ecl" style={{gap: "14px"}}> | ||
<span className="white-in">Ethereum</span> | ||
<Arrow /> | ||
<span className="white-in">Eclipse</span> | ||
<div className={isModalOpen ? "status-overlay active" : "status-overlay"}></div> | ||
<div className="activity-container"> | ||
{evmWallet && | ||
deposits && | ||
deposits.map((tx, index) => { | ||
const status = Number(tx.isError) | ||
? "failed" | ||
: transactions.get(tx.hash)?.pdaData | ||
? "completed" | ||
: transactions.get(tx.hash)?.pdaData === undefined | ||
? null | ||
: "loading"; | ||
return ( | ||
<div | ||
key={index} | ||
className="deposit-transaction flex flex-row items-center" | ||
onClick={() => { | ||
setIsModalOpen(true); | ||
setCurrentTx(tx); | ||
}} | ||
> | ||
<img | ||
src="swap.png" | ||
alt="Swap" | ||
className="swap-image" | ||
style={{ position: "absolute", width: "22px" }} | ||
hidden | ||
/> | ||
<img | ||
src="eth.png" | ||
alt="Ethereum" | ||
style={{ objectFit: "cover", height: "53px", width: "53px", marginLeft: "5px", marginRight: "16px" }} | ||
/> | ||
<div className="flex flex-col justify-center" style={{ width: "85%" }}> | ||
<div className="transaction-top flex justify-between"> | ||
<div className="flex tx-age" style={{ gap: "7px" }}> | ||
<span className="gray-in">Deposit</span> | ||
<span className="gray-in">•</span> | ||
<span className="gray-in">{timeAgo(Number(tx.timeStamp))}</span> | ||
</div> | ||
<div className={`flex flex-row items-center status-div ${status}`}> | ||
{status ? ( | ||
<> | ||
<TransactionIcon iconType={status} /> | ||
<span>{status === "loading" ? "depositing" : status}</span> | ||
</> | ||
) : ( | ||
<Skeleton height={15} width={91} /> | ||
)} | ||
</div> | ||
</div> | ||
<div className="transaction-bottom flex justify-between"> | ||
<div className="flex flex-row items-center eth-to-ecl" style={{ gap: "14px" }}> | ||
<span className="white-in">Ethereum</span> | ||
<Arrow /> | ||
<span className="white-in">Eclipse</span> | ||
</div> | ||
<span className="white-in">{Number(ethers.utils.formatEther(tx.value)).toFixed(3)} ETH</span> | ||
</div> | ||
</div> | ||
</div> | ||
<span className="white-in">{Number(ethers.utils.formatEther(tx.value)).toFixed(3)} ETH</span> | ||
); | ||
})} | ||
{!evmWallet ? ( | ||
<span>Connect your evm wallet first.</span> | ||
) : ( | ||
!deposits?.length && ( | ||
<div className="flex flex-col items-center justify-center" style={{ height: "90%", gap: "21px" }}> | ||
<ActivityBoxIcon activityBoxClassName="" /> | ||
<span style={{ fontSize: "18px", color: "rgba(255, 255, 255, 0.3)", fontWeight: "500", width: "266px" }}> | ||
You don’t have any transactions to show | ||
</span> | ||
</div> | ||
</div> | ||
) | ||
)} | ||
</div> | ||
)})} | ||
{(!evmWallet) | ||
? <span>Connect your evm wallet first.</span> | ||
: (!(deposits?.length) | ||
&& <div className="flex flex-col items-center justify-center" style={{height: "90%", gap: "21px"}}> | ||
<ActivityBoxIcon activityBoxClassName="" /> | ||
<span style={{fontSize: "18px", color: "rgba(255, 255, 255, 0.3)", fontWeight: "500", width: "266px"}}>You don’t have any transactions to show</span> | ||
</div> | ||
)} | ||
</div> | ||
{ isModalOpen && <TransactionDetails from={""} tx={currentTx} closeModal={() => setTimeout(() => setIsModalOpen(false), 100)} /> } | ||
{isModalOpen && ( | ||
<TransactionDetails from={""} tx={currentTx} closeModal={() => setTimeout(() => setIsModalOpen(false), 100)} /> | ||
)} | ||
</> | ||
) | ||
} | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.