forked from BETAIL-BOYS/TradeFlow-Web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.tsx
More file actions
51 lines (43 loc) · 1.49 KB
/
Copy pathpage.tsx
File metadata and controls
51 lines (43 loc) · 1.49 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
"use client";
import React, { useState } from "react";
import { connectWallet, WalletType } from "@/lib/stellar";
import Navbar from "@/components/Navbar";
import WalletModal from "@/components/WalletModal";
import { SwapCard } from "@/components/SwapCard";
import WalletNotConnected from "@/components/WalletNotConnected";
export default function SwapPage() {
const [address, setAddress] = useState("");
const [isModalOpen, setIsModalOpen] = useState(false);
const handleConnectWallet = async (walletType: WalletType) => {
try {
const userInfo = await connectWallet(walletType);
if (userInfo && userInfo.publicKey) {
setAddress(userInfo.publicKey);
}
} catch (e: any) {
console.error("Connection failed:", e.message);
alert(e.message || "Failed to connect to wallet.");
}
};
return (
<div className="min-h-screen bg-tradeflow-dark text-white font-sans flex flex-col">
<Navbar address={address} onConnect={() => setIsModalOpen(true)} />
<div className="flex-1 px-8">
{!address ? (
<WalletNotConnected onConnect={() => setIsModalOpen(true)} />
) : (
<div className="flex items-center justify-center py-12">
<SwapCard />
</div>
)}
</div>
<WalletModal
isOpen={isModalOpen}
onClose={() => setIsModalOpen(false)}
onConnect={handleConnectWallet}
/>
</div>
);
}
// Inconsequential change for repo health
// Maintenance: minor update