-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.tsx
175 lines (163 loc) · 6.14 KB
/
dashboard.tsx
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
"use client"
import { useState, useEffect } from "react";
import { Button } from "@/components/ui/button";
import { Search, Bell, Menu, X, MessageSquare } from "lucide-react";
import { bitteWallet } from "@/lib/bitte-wallet";
import { DashboardPage } from "@/components/dashboard-page";
import { AutomatePage } from "@/components/automate-page";
import { QuestsPage } from "@/components/quests-page";
import { TransactionsPage } from "@/components/transactions-page";
import { SettingsPage } from "@/components/settings-page";
import { ChatModal } from "@/components/chat-modal";
import { NeroChat } from "@/components/nero-chat";
export default function Dashboard() {
const [isSidebarOpen, setIsSidebarOpen] = useState(true);
const [isChatOpen, setIsChatOpen] = useState(false);
const [isNeroChatOpen, setIsNeroChatOpen] = useState(false);
const [currentPage, setCurrentPage] = useState("dashboard");
const [walletInfo, setWalletInfo] = useState<any>(null);
useEffect(() => {
const params = new URLSearchParams(window.location.search);
if (params.has("account_id") && params.has("public_key")) {
(async () => {
const info = await bitteWallet.connect();
setWalletInfo(info);
})();
}
}, []);
const handleWalletConnect = async () => {
if (bitteWallet.isConnected()) {
await bitteWallet.disconnect();
setWalletInfo(null);
} else {
const info = await bitteWallet.connect();
setWalletInfo(info);
}
};
const handleStartConversation = () => {
setIsChatOpen(false);
setIsNeroChatOpen(true);
};
const renderPage = () => {
switch (currentPage) {
case "dashboard":
return <DashboardPage />;
case "quests":
return <QuestsPage />;
case "automate":
return <AutomatePage />;
case "transactions":
return <TransactionsPage />;
case "setting":
return <SettingsPage />;
default:
return <DashboardPage />;
}
};
return (
<div className="flex min-h-screen bg-gray-50">
{/* Mobile sidebar toggle */}
<Button
variant="outline"
size="icon"
className="fixed left-4 top-4 z-50 md:hidden"
onClick={() => setIsSidebarOpen(!isSidebarOpen)}
>
{isSidebarOpen ? <X className="h-4 w-4" /> : <Menu className="h-4 w-4" />}
</Button>
{/* Sidebar */}
<div
className={`fixed inset-y-0 left-0 z-40 w-64 transform bg-white transition-transform duration-300 ease-in-out md:translate-x-0 ${
isSidebarOpen ? "translate-x-0" : "-translate-x-full"
}`}
>
<div className="flex h-full flex-col">
<div className="flex h-16 items-center border-b px-6">
<img
src="https://hebbkx1anhila5yf.public.blob.vercel-storage.com/logo-5nPwJ7XsByF8cWNBqmPapf6TgR4m3q.svg"
alt="Logo"
className="h-8 w-8"
/>
</div>
<div className="flex-1 overflow-auto py-4">
<nav className="space-y-1 px-3">
{[
{ name: "Dashboard", icon: "🏠" },
{ name: "Quests", icon: "🎯" },
{ name: "Automate", icon: "⚡" },
{ name: "Transactions", icon: "💳" },
{ name: "Setting", icon: "⚙️" },
].map((item) => (
<Button
key={item.name}
variant={currentPage === item.name.toLowerCase() ? "subtle" : "ghost"}
className={`w-full justify-start gap-3 ${
currentPage === item.name.toLowerCase() ? "bg-gray-100 text-gray-900" : "text-gray-700"
}`}
onClick={() => setCurrentPage(item.name.toLowerCase())}
>
<span>{item.icon}</span>
{item.name}
</Button>
))}
</nav>
</div>
</div>
</div>
{/* Main content */}
<div className={`flex-1 ${isSidebarOpen ? "md:ml-64" : ""}`}>
<header className="sticky top-0 z-30 flex h-16 items-center justify-between border-b bg-white px-6">
<div className="flex items-center">
<div className="text-xl font-bold capitalize mr-4">{currentPage}</div>
<Button
variant="outline"
size="sm"
className="flex items-center gap-2"
onClick={() => setIsChatOpen(true)}
>
<MessageSquare className="h-4 w-4" />
Talk to AI
</Button>
</div>
<div className="relative ml-auto flex items-center gap-4">
<div className="relative">
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400" />
<input
type="text"
placeholder="Search for a Token"
className="h-10 rounded-md border border-gray-200 bg-gray-50 pl-10 pr-4 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
/>
</div>
<Button
onClick={handleWalletConnect}
className="hidden sm:flex items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-1.5 text-sm hover:bg-gray-100"
>
<span className="text-gray-500">
{walletInfo ? walletInfo.shortAddress : "Connect Wallet"}
</span>
</Button>
<Button variant="outline" size="icon">
<Bell className="h-4 w-4" />
</Button>
<div className="h-8 w-8 overflow-hidden rounded-full bg-gray-200">
<img
src="/placeholder.svg?height=32&width=32"
alt="User avatar"
className="h-full w-full object-cover"
/>
</div>
</div>
</header>
<main>{renderPage()}</main>
</div>
{/* Chat Modal */}
<ChatModal
isOpen={isChatOpen}
onClose={() => setIsChatOpen(false)}
onStartConversation={handleStartConversation}
/>
{/* Nero Chat */}
{isNeroChatOpen && <NeroChat onClose={() => setIsNeroChatOpen(false)} />}
</div>
);
}