From 9898dca98bdd581a8ca5e9f593b0abcc76fc6d04 Mon Sep 17 00:00:00 2001 From: muddlebee Date: Wed, 13 Nov 2024 18:29:35 +0530 Subject: [PATCH] enhancements --- src/app/page.tsx | 127 +++++++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 58 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 3d159dd..6a8af5f 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -10,52 +10,71 @@ import { DialogTitle, DialogTrigger, } from "@/components/ui/dialog" +import { Settings, Clock, ArrowRight, ArrowDownToLine, Wallet } from 'lucide-react' -import { Settings, Clock, ArrowRight, DollarSign, Wallet } from 'lucide-react' interface TokenButtonProps { token: string; icon: React.ReactNode; onClick: () => void; + price?: string; // Add price prop } - const TokenButton = ({ token, icon, onClick }: TokenButtonProps) => ( ) export default function Component() { - const [walletConnected, setWalletConnected] = useState(false) + const [inputToken, setInputToken] = useState({ name: 'DOT', icon: '●', price: '$2.00' }) + const [outputToken, setOutputToken] = useState({ name: 'ETH', icon: 'Ξ', price: '$2000' }) const [inputAmount, setInputAmount] = useState('50') const [outputAmount, setOutputAmount] = useState('100') const [slippageTolerance, setSlippageTolerance] = useState(0.5) const [transactionDeadline, setTransactionDeadline] = useState(20) + const [isConnected, setIsConnected] = useState(false) + const [walletAddress, setWalletAddress] = useState('') const handleInputChange = (value: string) => { setInputAmount(value) setOutputAmount((parseFloat(value) * 2).toString()) } + const handleWalletConnect = () => { + setIsConnected(!isConnected) + setWalletAddress(isConnected ? '' : '0x1234...5678') + } + + const tokens = [ + { name: 'DOT', icon: '●', price: '$2.00' }, + { name: 'ETH', icon: 'Ξ', price: '$2000' }, + { name: 'BTC', icon: '₿', price: '$30000' }, + ] + return (
-
+
+

Swap

@@ -102,20 +121,21 @@ export default function Component() {
Pay - $2.000 + + ${(parseFloat(inputAmount) * parseFloat(inputToken.price.slice(1))).toFixed(3)} +
-
+
- + {inputToken.icon}
} - price="$2.00" onClick={() => {}} />
@@ -125,22 +145,16 @@ export default function Component() { Select a token
- - -
} - price="$2.00" - onClick={() => setInputToken('DOT')} - /> - - Ξ -
} - price="$2000" - onClick={() => setInputToken('ETH')} - /> + {tokens.map((token) => ( + + {token.icon} +
} + onClick={() => setInputToken(token)} + /> + ))}
@@ -153,7 +167,7 @@ export default function Component() { placeholder="0" />
- Balance: 100 + $100
@@ -161,27 +175,29 @@ export default function Component() {
- +
Receive - $2.000 + + ${(parseFloat(outputAmount) * parseFloat(outputToken.price.slice(1))).toFixed(3)} +
-
+
- Ξ + {outputToken.icon}
} - price="$2000" + price={outputToken.price} onClick={() => {}} />
@@ -191,22 +207,17 @@ export default function Component() { Select a token
- - -
} - price="$2.00" - onClick={() => setOutputToken('DOT')} - /> - - Ξ -
} - price="$2000" - onClick={() => setOutputToken('ETH')} - /> + {tokens.map((token) => ( + + {token.icon} +
} + price={token.price} + onClick={() => setOutputToken(token)} + /> + ))}
@@ -219,7 +230,7 @@ export default function Component() { placeholder="0" />
- Balance: 100 + $100
@@ -228,7 +239,7 @@ export default function Component() {
- 1 DOT = 2 ETH ($2,456.00) + 1 {inputToken.name} = {(parseFloat(outputToken.price.slice(1)) / parseFloat(inputToken.price.slice(1))).toFixed(4)} {outputToken.name} (${outputToken.price.slice(1)})