mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-25 02:57:56 +00:00
4a3694c831
- Replaced shadowColor/shadowOffset/shadowOpacity/shadowRadius with boxShadow - Fixed 28 files (21 screens + 7 components) - Preserved elevation for Android compatibility - All React Native Web deprecation warnings resolved Files fixed: - All screen components - All reusable components - Navigation components - Modal components
206 lines
8.5 KiB
TypeScript
206 lines
8.5 KiB
TypeScript
import React, { useState } from 'react';
|
|
// import { useNavigate } from 'react-router-dom';
|
|
import { useWallet } from '@/contexts/WalletContext';
|
|
import { usePezkuwi } from '@/contexts/PezkuwiContext';
|
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|
import TokenSwap from '@/components/TokenSwap';
|
|
import PoolDashboard from '@/components/PoolDashboard';
|
|
import { CreatePoolModal } from './CreatePoolModal';
|
|
import { InitializeHezPoolModal } from './InitializeHezPoolModal';
|
|
import { InitializeUsdtModal } from './InitializeUsdtModal';
|
|
import { XCMConfigurationWizard } from '@/components/admin/XCMConfigurationWizard';
|
|
import { ArrowRightLeft, Droplet, Settings } from 'lucide-react';
|
|
import { isFounderWallet } from '@pezkuwi/utils/auth';
|
|
|
|
export const DEXDashboard: React.FC = () => {
|
|
const { account } = useWallet();
|
|
const { sudoKey } = usePezkuwi();
|
|
const [activeTab, setActiveTab] = useState('swap');
|
|
|
|
// Admin modal states
|
|
const [showCreatePoolModal, setShowCreatePoolModal] = useState(false);
|
|
const [showInitializeHezPoolModal, setShowInitializeHezPoolModal] = useState(false);
|
|
const [showInitializeUsdtModal, setShowInitializeUsdtModal] = useState(false);
|
|
const [showXcmBridgeModal, setShowXcmBridgeModal] = useState(false);
|
|
|
|
const isFounder = account ? isFounderWallet(account, sudoKey) : false;
|
|
|
|
const handleCreatePool = () => {
|
|
setShowCreatePoolModal(true);
|
|
};
|
|
|
|
const handleModalClose = () => {
|
|
setShowCreatePoolModal(false);
|
|
setShowInitializeHezPoolModal(false);
|
|
setShowInitializeUsdtModal(false);
|
|
setShowXcmBridgeModal(false);
|
|
};
|
|
|
|
const handleSuccess = async () => {
|
|
// Pool modals will refresh their own data
|
|
};
|
|
|
|
return (
|
|
<div className="min-h-screen bg-gray-950 text-white">
|
|
{/* Header */}
|
|
<div className="bg-gradient-to-r from-green-900/30 via-yellow-900/30 to-red-900/30 border-b border-gray-800 py-8">
|
|
<div className="max-w-7xl mx-auto px-4">
|
|
<h1 className="text-4xl font-bold mb-2 bg-gradient-to-r from-green-400 via-yellow-400 to-red-400 bg-clip-text text-transparent">
|
|
Pezkuwi DEX
|
|
</h1>
|
|
<p className="text-gray-400 text-lg">
|
|
Decentralized exchange for trading tokens on PezkuwiChain
|
|
</p>
|
|
|
|
{/* Wallet status */}
|
|
{account && (
|
|
<div className="mt-4 flex items-center gap-4">
|
|
<div className="px-4 py-2 bg-gray-900/80 rounded-lg border border-gray-800">
|
|
<span className="text-xs text-gray-400">Connected: </span>
|
|
<span className="text-sm font-mono text-white">
|
|
{account.slice(0, 6)}...{account.slice(-4)}
|
|
</span>
|
|
</div>
|
|
{isFounder && (
|
|
<div className="px-4 py-2 bg-green-600/20 border border-green-600/30 rounded-lg">
|
|
<span className="text-xs text-green-400 font-semibold">
|
|
FOUNDER ACCESS
|
|
</span>
|
|
</div>
|
|
)}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
|
|
{/* Main content */}
|
|
<div className="max-w-7xl mx-auto px-4 py-8">
|
|
{!account ? (
|
|
<div className="text-center py-12">
|
|
<div className="mb-4 text-gray-400 text-lg">
|
|
Please connect your Polkadot wallet to use the DEX
|
|
</div>
|
|
</div>
|
|
) : (
|
|
<Tabs value={activeTab} onValueChange={setActiveTab} className="w-full">
|
|
<TabsList className={`grid w-full ${isFounder ? 'grid-cols-3' : 'grid-cols-2'} gap-2 bg-gray-900/50 p-1 rounded-lg mb-8`}>
|
|
<TabsTrigger value="swap" className="flex items-center gap-2">
|
|
<ArrowRightLeft className="w-4 h-4" />
|
|
<span className="hidden sm:inline">Swap</span>
|
|
</TabsTrigger>
|
|
<TabsTrigger value="pools" className="flex items-center gap-2">
|
|
<Droplet className="w-4 h-4" />
|
|
<span className="hidden sm:inline">Pools</span>
|
|
</TabsTrigger>
|
|
{isFounder && (
|
|
<TabsTrigger value="admin" className="flex items-center gap-2">
|
|
<Settings className="w-4 h-4" />
|
|
<span className="hidden sm:inline">Admin</span>
|
|
</TabsTrigger>
|
|
)}
|
|
</TabsList>
|
|
|
|
<TabsContent value="swap" className="mt-6">
|
|
<TokenSwap />
|
|
</TabsContent>
|
|
|
|
<TabsContent value="pools" className="mt-6">
|
|
<PoolDashboard />
|
|
</TabsContent>
|
|
|
|
{isFounder && (
|
|
<TabsContent value="admin" className="mt-6">
|
|
<div className="max-w-2xl mx-auto space-y-6">
|
|
<div className="p-6 bg-gray-900 border border-blue-900/30 rounded-lg">
|
|
<h3 className="text-xl font-bold text-white mb-2">Token Wrapping</h3>
|
|
<p className="text-gray-400 mb-6">
|
|
Convert native HEZ to wrapped wHEZ for use in DEX pools
|
|
</p>
|
|
<button
|
|
onClick={() => setShowInitializeHezPoolModal(true)}
|
|
className="w-full px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors font-medium"
|
|
>
|
|
Wrap HEZ to wHEZ
|
|
</button>
|
|
</div>
|
|
|
|
<div className="p-6 bg-gray-900 border border-green-900/30 rounded-lg">
|
|
<h3 className="text-xl font-bold text-white mb-2">USDT Token Minting</h3>
|
|
<p className="text-gray-400 mb-6">
|
|
Mint wUSDT tokens for testing and liquidity provision
|
|
</p>
|
|
<button
|
|
onClick={() => setShowInitializeUsdtModal(true)}
|
|
className="w-full px-6 py-3 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors font-medium"
|
|
>
|
|
Mint wUSDT
|
|
</button>
|
|
</div>
|
|
|
|
<div className="p-6 bg-gray-900 border border-purple-900/30 rounded-lg">
|
|
<h3 className="text-xl font-bold text-white mb-2">XCM Configuration Wizard</h3>
|
|
<p className="text-gray-400 mb-6">
|
|
Complete 6-step parachain setup: Reserve ParaId, generate artifacts, register parachain, open HRMP channels, register foreign assets, and test XCM transfers.
|
|
</p>
|
|
<button
|
|
onClick={() => setShowXcmBridgeModal(true)}
|
|
className="w-full px-6 py-3 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors font-medium"
|
|
>
|
|
Open XCM Configuration Wizard
|
|
</button>
|
|
</div>
|
|
|
|
<div className="p-6 bg-gray-900 border border-gray-800 rounded-lg">
|
|
<h3 className="text-xl font-bold text-white mb-2">Pool Management</h3>
|
|
<p className="text-gray-400 mb-6">
|
|
Create new liquidity pools for token pairs on PezkuwiChain
|
|
</p>
|
|
<button
|
|
onClick={handleCreatePool}
|
|
className="w-full px-6 py-3 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors font-medium"
|
|
>
|
|
Create New Pool
|
|
</button>
|
|
</div>
|
|
|
|
<div className="p-6 bg-gray-900 border border-gray-800 rounded-lg">
|
|
<h3 className="text-xl font-bold text-white mb-2">Pool Statistics</h3>
|
|
<p className="text-gray-400 text-sm">
|
|
View detailed pool statistics in the Pools tab
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</TabsContent>
|
|
)}
|
|
</Tabs>
|
|
)}
|
|
</div>
|
|
|
|
{/* Admin Modals */}
|
|
<CreatePoolModal
|
|
isOpen={showCreatePoolModal}
|
|
onClose={handleModalClose}
|
|
onSuccess={handleSuccess}
|
|
/>
|
|
|
|
<InitializeHezPoolModal
|
|
isOpen={showInitializeHezPoolModal}
|
|
onClose={handleModalClose}
|
|
onSuccess={handleSuccess}
|
|
/>
|
|
|
|
<InitializeUsdtModal
|
|
isOpen={showInitializeUsdtModal}
|
|
onClose={handleModalClose}
|
|
onSuccess={handleSuccess}
|
|
/>
|
|
|
|
<XCMConfigurationWizard
|
|
isOpen={showXcmBridgeModal}
|
|
onClose={handleModalClose}
|
|
onSuccess={handleSuccess}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|