From 567d39e3b8191fd4d2ecb1b44ecb2075e1a84ac0 Mon Sep 17 00:00:00 2001 From: muddlebee Date: Tue, 19 Nov 2024 12:04:39 +0530 Subject: [PATCH] feat: wallet connect & swap merge --- src/app/page.tsx | 227 ++++++++++++++++++++++++++++++----------------- 1 file changed, 147 insertions(+), 80 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 5a5a269..8a07176 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -73,9 +73,42 @@ export default function Component() { const handleWalletConnect = () => { setIsConnected(!isConnected) setWalletAddress(isConnected ? '' : '0x1234...5678') - toast.success(isConnected ? 'Wallet disconnected' : 'Wallet connected', { - icon: isConnected ? '🔴' : '🟢', - }) + + if (!isConnected) { + toast.success( +
+
+ +
+
+

Wallet Connected

+

+ {`Connected to ${walletAddress}`} +

+
+
, + { + duration: 4000, + } + ) + } else { + toast.success( +
+
+ +
+
+

Wallet Disconnected

+

+ Your wallet has been disconnected +

+
+
, + { + duration: 4000, + } + ) + } } const handleSwap = async () => { @@ -141,6 +174,102 @@ export default function Component() { { label: 'MAX', value: 1 }, ] + // Render the main action button based on connection state + const renderActionButton = () => { + if (!isConnected) { + return ( + + ); + } + + return ( + + + + + + + Confirming Swap + +
+ {swapSteps.map((step, index) => ( +
+
+ + {step.status === 'completed' ? ( + + ) : step.status === 'loading' ? ( + + ) : ( + {step.id} + )} + + {index < swapSteps.length - 1 && ( +
+ )} +
+
+

{step.title}

+

+ {step.status === 'completed' ? 'Transaction confirmed' : + step.status === 'loading' ? 'Waiting for confirmation...' : + 'Waiting to start'} +

+
+
+ ))} +
+ + {swapSteps.every(step => step.status === 'completed') ? ( + + ) : ( + + )} + + +
+ ); + }; + return ( <>
@@ -430,76 +559,13 @@ export default function Component() { - - - - - - - Confirming Swap - -
- {swapSteps.map((step, index) => ( -
-
- - {step.status === 'completed' ? ( - - ) : step.status === 'loading' ? ( - - ) : ( - {step.id} - )} - - {index < swapSteps.length - 1 && ( -
- )} -
-
-

{step.title}

-

- {step.status === 'completed' ? 'Transaction confirmed' : - step.status === 'loading' ? 'Waiting for confirmation...' : - 'Waiting to start'} -

-
-
- ))} -
- - {swapSteps.every(step => step.status === 'completed') ? ( - - ) : ( - - )} - - -
+ + {renderActionButton()} +
@@ -529,15 +595,16 @@ export default function Component() {