92 lines
3.8 KiB
TypeScript
92 lines
3.8 KiB
TypeScript
import React from 'react';
|
|
import { useWeb3 } from '../../context/Web3Context';
|
|
import { DEPLOYMENTS } from '@wtfx/contracts';
|
|
import { Wallet, ShieldAlert, CheckCircle2 } from 'lucide-react';
|
|
|
|
interface NavbarProps {
|
|
activeTab: string;
|
|
setActiveTab: (tab: string) => void;
|
|
}
|
|
|
|
export const AdminNavbar: React.FC<NavbarProps> = ({ activeTab, setActiveTab }) => {
|
|
const { account, isCorrectNetwork, connectWallet, switchNetwork } = useWeb3();
|
|
|
|
const navItems = [
|
|
{ id: 'governance', label: '⚙️ 协议全局治理' },
|
|
{ id: 'adjudication', label: '⚖️ 市场争议终裁与熔断' },
|
|
{ id: 'faucet', label: '🚰 超管铸币水龙头' },
|
|
];
|
|
|
|
return (
|
|
<header className="bg-slate-900/80 backdrop-blur-md border-b border-slate-800 sticky top-0 z-50">
|
|
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 h-16 flex items-center justify-between">
|
|
<div className="flex items-center space-x-8">
|
|
<div className="flex items-center space-x-3">
|
|
<div className="w-9 h-9 bg-gradient-to-tr from-cyan-500 to-indigo-600 rounded-lg flex items-center justify-center font-black text-white shadow-lg shadow-cyan-500/20">
|
|
W
|
|
</div>
|
|
<div>
|
|
<span className="font-bold text-lg text-white tracking-wider">WTFX</span>
|
|
<span className="ml-2 text-xs font-mono px-2 py-0.5 rounded bg-cyan-950 text-cyan-400 border border-cyan-800">
|
|
ADMIN CONSOLE
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<nav className="flex space-x-1">
|
|
{navItems.map((item) => (
|
|
<button
|
|
key={item.id}
|
|
onClick={() => setActiveTab(item.id)}
|
|
className={`px-3.5 py-2 rounded-lg text-sm font-medium transition-all ${
|
|
activeTab === item.id
|
|
? 'bg-slate-800 text-white shadow-sm border border-slate-700'
|
|
: 'text-slate-400 hover:text-slate-200 hover:bg-slate-800/50'
|
|
}`}
|
|
>
|
|
{item.label}
|
|
</button>
|
|
))}
|
|
</nav>
|
|
</div>
|
|
|
|
<div className="flex items-center space-x-4">
|
|
{account ? (
|
|
<div className="flex items-center space-x-3">
|
|
{!isCorrectNetwork ? (
|
|
<button
|
|
onClick={switchNetwork}
|
|
className="flex items-center space-x-1.5 bg-amber-500/10 text-amber-400 border border-amber-500/30 px-3 py-1.5 rounded-lg text-xs font-medium hover:bg-amber-500/20 transition-colors"
|
|
>
|
|
<ShieldAlert className="w-4 h-4" />
|
|
<span>切换至 Robinhood 测试网</span>
|
|
</button>
|
|
) : (
|
|
<span className="flex items-center space-x-1 text-emerald-400 bg-emerald-950/40 border border-emerald-800/50 px-2.5 py-1 rounded-md text-xs font-mono">
|
|
<CheckCircle2 className="w-3.5 h-3.5" />
|
|
<span>Robinhood 46630</span>
|
|
</span>
|
|
)}
|
|
|
|
<div className="flex items-center space-x-2 bg-slate-800 border border-slate-700 px-3 py-1.5 rounded-lg">
|
|
<div className="w-2 h-2 rounded-full bg-emerald-500"></div>
|
|
<span className="font-mono text-xs text-slate-200">
|
|
{account.slice(0, 6)}...{account.slice(-4)}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
) : (
|
|
<button
|
|
onClick={connectWallet}
|
|
className="flex items-center space-x-2 bg-cyan-600 hover:bg-cyan-500 text-white px-4 py-2 rounded-lg text-sm font-medium shadow-md shadow-cyan-600/20 transition-all"
|
|
>
|
|
<Wallet className="w-4 h-4" />
|
|
<span>连接钱包</span>
|
|
</button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</header>
|
|
);
|
|
};
|