Skip to content

Commit

Permalink
Merge pull request #34 from Eclipse-Laboratories-Inc/modal-popup
Browse files Browse the repository at this point in the history
add transaction details
  • Loading branch information
dandlezzz authored Sep 6, 2024
2 parents 769d009 + 5ffa647 commit 6f784f6
Show file tree
Hide file tree
Showing 13 changed files with 392 additions and 39 deletions.
19 changes: 19 additions & 0 deletions app/components/deposit/activity.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
gap: 8px;
font-weight: 500;
width: 100%;
height: 364px;
overflow: scroll;
}

.deposit-transaction {
Expand All @@ -14,6 +16,15 @@
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 10px;
background: rgba(255, 255, 255, 0.03);
transition: background 100ms var(--ease-out-quad);
span::first-letter {
text-transform: uppercase;
}
}

.deposit-transaction:hover {
background: rgba(255, 255, 255, 0.04);
cursor: pointer;
}

.white-in {
Expand Down Expand Up @@ -59,4 +70,12 @@
.gray-in {
font-size: 12px;
}
.eth-to-ecl { gap: "7px"; }
.tx-age { gap: "4px"; }
}

@keyframes bounce {
0% { transform: translateY(-10px); }
50% { transform: translateY(5px); }
100% { transform: translateY(0); }
}
61 changes: 50 additions & 11 deletions app/components/deposit/activityContent.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,72 @@
import { useEffect, useState } from 'react';
import { Arrow } from "@/app/components/icons";
import { TransactionIcon } from "../icons";
import { getLastDeposits, timeAgo } from "@/lib/activityUtils"
import { ethers } from 'ethers';
import { TransactionDetails } from "./transactionDetails";
import {
useUserWallets,
Wallet
} from "@dynamic-labs/sdk-react-core";
import "./activity.css";

export const ActivityContent = () => {
const [deposits, setDeposits] = useState<any[] | null>(null);
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
const [currentTx, setCurrentTx] = useState<any>(null);

const userWallets: Wallet[] = useUserWallets() as Wallet[];
const evmWallet = userWallets.find(w => w.chain == "EVM");

useEffect(() => {
const fetchDeposits = async () => {
try {
const data = await getLastDeposits(evmWallet?.address || '');
setDeposits(data.reverse());
} catch (error) {
console.error("Error fetching deposits:", error);
}
};

if (evmWallet) fetchDeposits();
}, [evmWallet]);

return (
<>
<div className="activity-container">
<div className="deposit-transaction flex flex-row">
<div className="flex items-center justify-center" style={{width: "18%", justifyContent: "flex-start"}}>
<img src="swap.png" alt="Swap" className="swap-image" hidden/>
<img src="eth.png" alt="Ethereum" style={{ objectFit: "cover", height: "53px", width: "53px"}} />
</div>
{evmWallet && deposits && deposits.map((tx, index) => {
// TODO: add loading state
const status = Number(tx.isError) ? "failed" : "completed";
return (
<div key={index} className="deposit-transaction flex flex-row" 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">
<span className="gray-in">Deposit • 1 min ago</span>
<div className="flex flex-row items-center status-div loading">
<TransactionIcon iconType="loading"/>
<span>Depositing</span>
<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}`}>
<TransactionIcon iconType={status}/>
<span>{status}</span>
</div>
</div>
<div className="transaction-bottom flex justify-between">
<div className="flex flex-row items-center" style={{gap: "14px"}}>
<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">1 ETH</span>
<span className="white-in">{Number(ethers.utils.formatEther(tx.value)).toFixed(3)} ETH</span>
</div>
</div>
</div>
)})}
{(!evmWallet) ? <span>Connect your evm wallet first.</span> : (!(deposits?.length) && <span>You don&apos;t have any transactions.</span>)}
</div>
{ isModalOpen && <TransactionDetails tx={currentTx} closeModal={() => setTimeout(() => setIsModalOpen(false), 100)} /> }
</>
)
}
14 changes: 1 addition & 13 deletions app/components/deposit/depositContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export const DepositContent: React.FC<DepositProps> = ({ amountEther, setAmountE

try {
// lets keep this here
/*
const { request } = await client.simulateContract({
address: contractAddress,
abi,
Expand All @@ -112,15 +111,6 @@ export const DepositContent: React.FC<DepositProps> = ({ amountEther, setAmountE
value: weiValue
})
await walletClient.writeContract(request)
*/
await walletClient.sendTransaction({
to: contractAddress,
abi,
functionName: 'deposit',
args: [destinationBytes32, weiValue],
account,
value: weiValue
});
setIsMmPopup(false)
} catch (error) {
setIsMmPopup(false)
Expand Down Expand Up @@ -300,12 +290,10 @@ export const DepositContent: React.FC<DepositProps> = ({ amountEther, setAmountE
<span style={{ width: '100%' }}> {determineButtonText()}</span>
</DynamicConnectButton>
:
<div className={determineButtonClass()}>
<button className="w-full deposit-button p-4" onClick={submitDeposit}>
<button className={`w-full deposit-button p-4 ${determineButtonClass()}`} onClick={submitDeposit}>
{(isMmPopup) ? <Loading loadingClassName="loading-animation" /> : null }
{determineButtonText()}
</button>
</div>
}
</div>
);
Expand Down
12 changes: 9 additions & 3 deletions app/components/deposit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Activity } from "../icons";
import './styles.css';
import { DepositContent, DepositProps } from "./depositContent";
import { ActivityContent } from "./activityContent";
import ExtendedDetails from '../ExtendedDetails'
import classNames from 'classnames';

enum Tabs {
Deposit,
Expand All @@ -14,19 +16,23 @@ enum Tabs {
const Deposit: React.FC<DepositProps> = ({ amountEther, setAmountEther }) => {
const [activeTab, setActiveTab] = useState<Tabs>(Tabs.Deposit);
return (
<>
<div className="deposit-container">
<div className="deposit-card">
<div className="header-tabs">
<div className="active header-tab" style={{ width: "43.5%" }} onClick={() => setActiveTab(Tabs.Deposit)}>Deposit</div>
<div className="inactive header-tab" style={{ width: "43.5%" }}>Withdraw</div>
<div className="inactive header-tab flex items-center justify-center" style={{ width: "56px" }} onClick={() => {setActiveTab(Tabs.Activity)}}>
<div className={classNames("header-tab", (activeTab === Tabs.Deposit ? "active" : "inactive"))} style={{ width: "43.5%" }} onClick={() => setActiveTab(Tabs.Deposit)}>Deposit</div>
<div className={classNames("header-tab", "disabled", (activeTab === Tabs.Withdraw ? "active" : "inactive"))} style={{ width: "43.5%" }}>Withdraw</div>
<div className={classNames("header-tab", "flex", "items-center", "justify-center", (activeTab === Tabs.Activity ? "active" : "inactive"))} style={{ width: "56px" }} onClick={() => {setActiveTab(Tabs.Activity)}}>
<Activity activityClassName="" />
</div>
</div>
{ activeTab === Tabs.Deposit && <DepositContent amountEther={amountEther} setAmountEther={setAmountEther}/> }
{ activeTab === Tabs.Activity && <ActivityContent /> }
</div>
</div>
<br></br>
{ (activeTab === Tabs.Deposit) && <ExtendedDetails amountEther={amountEther} /> }
</>
);
}

Expand Down
15 changes: 10 additions & 5 deletions app/components/deposit/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,23 @@
.header-tabs div.active {
color: #a3ffa5; /* Light green color for active tab text */
background-color: rgba(161, 254, 160, 0.05);
transition: background-color 300ms var(--ease-out-quad), color 300ms var(--ease-out-quad);
path {
stroke-opacity: 1;
stroke: #a3ffa5;
transition: stroke-opacity 300ms var(--ease-out-quad);
}
}

.header-tabs div.inactive {
background-color: rgba(255, 255, 255, 0.02);
color: #666666; /* Dark gray color for inactive tab text */
}

.header-tabs div.disabled {
cursor: not-allowed;
}

.arrow-container {
position: absolute;
top: 50%;
Expand Down Expand Up @@ -341,17 +351,14 @@ input::placeholder {
.submit-button:active {
transform: scale(0.95);
transition: transform 0.1s var(--ease-out-quad);
height: 66px;
}

.connect-btn:active {
height: 62px;
}

.wallet-connect-button:active {
transform: scale(1.0526);
transform-origin: center center;
font-size: 95%;
}

.deposit-button {
Expand All @@ -362,9 +369,7 @@ input::placeholder {
}

.deposit-button:active{
transform: scale(1.052631);
transform-origin: center center;
font-size: 95%;
}

.amount-input-container {
Expand Down
117 changes: 117 additions & 0 deletions app/components/deposit/transaction-details.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
.transaction-details-modal {
position: absolute;
z-index: 500;
width: 494px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
height: 631px;
padding: 20px;

border: 1px solid rgba(255, 255, 255, 0.1);
background: rgba(6, 6, 6, 1);
border-radius: 30px;
}

.modal-cross {
width: 14px;
height: 14px;
cursor: pointer;
}

.transaction-details-header {
width: 100%;
font-size: 20px;
line-height: 26px;
font-weight: 500;
}

.logo-header {
background: rgba(255, 255, 255, 0.04);
border-radius: 70px;
width: 192px;
height: 75px;
margin-top: 30px;
padding: 10px;
gap: 25px;
}

.status-panel {
width: 100%;
height: 192px;
background: rgba(255, 255, 255, 0.03);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 10px;
margin-top: 30px;
.white-text {
font-weight: 500;
font-size: 18px;
line-height: 23.4px;
}
.gray-text {
font-weight: 500;
font-size: 16px;
line-height: 20.8px;
}
}

.panel-elem {
padding: 14px;
width: 100%;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-elem:nth-of-type(3) {
border-bottom: none;
}

.left-side {
gap: 8px;
}

.done-item{
color: #A1FEA0;
background: rgba(161, 254, 160, 0.05);
font-size: 16px;
font-weight: 500;
border-radius: 30px;
padding: 6px 12px 6px 6px;
}

.tx-done-icon {
width: 24px;
height: 24px;
}

.info-name {
font-weight: 500;
font-size: 16px;
}

.green-text {
color: rgba(161, 254, 160, 1);
font-size: 16px;
}

.done-button {
margin-top: 20px;
background: rgba(255, 255, 255, 0.05);
border-radius: 10px;
font-size: 20px;
width: 100%;
font-weight: 500;
height: 58px;
transition: transform 100ms var(--ease-out-quad);
}

.done-button:active {
transform: scale(0.95);
}

a {
transition: color 100ms var(--ease-out-quad);
}

a:hover {
color: rgba(71, 121, 255, 1);
}
Loading

0 comments on commit 6f784f6

Please sign in to comment.