omninexus-ai / App.tsx
aditya9708's picture
Auto-deploy from AI Studio
e4c7604 verified
Raw History Blame Contribute Delete
13.3 kB
import React, { useState, useEffect } from 'react';
import { AppView, Tool, AffiliateStats, GlobalStats } from './types';
import LandingPage from './components/LandingPage';
import ExplorerView from './components/ExplorerView';
import CreateView from './components/CreateView';
import DashboardView from './components/DashboardView';
import PricingView from './components/PricingView';
import ToolExecutionView from './components/ToolExecutionView';
import Sidebar from './components/Sidebar';
import AdminView from './components/AdminView';
import AdminLogin from './components/AdminLogin';
const INITIAL_TOOLS: Tool[] = [
{ id: '20', name: 'Gemini 3 Pro Intelligence', description: 'Deep logical reasoning for complex business strategies and coding.', category: 'Text', icon: 'M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z', gradient: 'from-blue-600 to-indigo-900', author: 'Google_Cloud', usageCount: 22000, epc: 40.00, isVerified: true, status: 'hot' },
{ id: '18', name: 'Imagen 4.0 Studio', description: 'Next-level 4K photorealism for marketing and digital art.', category: 'Image', icon: 'M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z', gradient: 'from-blue-400 to-indigo-600', author: 'Z-Labs', usageCount: 6500, epc: 60.00, isVerified: true, status: 'new' },
{ id: '15', name: 'Veo Cinematic Lab', description: 'High-fidelity cinematic videos with physically accurate motion.', category: 'Video', icon: 'M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14', gradient: 'from-indigo-400 via-purple-500 to-pink-500', author: 'LumaLabs', usageCount: 4500, epc: 180.00, isVerified: true, status: 'hot' },
{ id: '17', name: 'Gemini Live Voice', description: 'Ultra-low latency human-like voice conversations.', category: 'Voice', icon: 'M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7', gradient: 'from-cyan-400 to-blue-600', author: 'Google_Node', usageCount: 12300, epc: 110.00, isVerified: true, status: 'hot' },
{ id: '21', name: 'MoltBot Multimodal', description: 'Advanced AI agent that sees, hears, and reasons across all media types simultaneously.', category: 'Agent', icon: 'M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z', gradient: 'from-orange-500 via-red-500 to-pink-600', author: 'Omni_Core', usageCount: 8900, epc: 250.00, isVerified: true, status: 'new' },
];
const App: React.FC = () => {
// Hardcoded Primary Founder UPI
const FOUNDER_UPI = 'adityaverma05@ptyes';
const [credits, setCredits] = useState(() => Number(localStorage.getItem('omni_credits')) || 500);
const [earnings, setEarnings] = useState(() => Number(localStorage.getItem('omni_earnings')) || 0);
const [payoutMethod, setPayoutMethod] = useState(() => localStorage.getItem('omni_upi') || FOUNDER_UPI);
const [currentView, setCurrentView] = useState<AppView>(AppView.LANDING);
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
const [activeTool, setActiveTool] = useState<Tool | null>(null);
const [customTools, setCustomTools] = useState<Tool[]>([]);
const [notifications, setNotifications] = useState<{id: number, text: string, type?: 'success' | 'info'}[]>([]);
const [isMasterMode, setIsMasterMode] = useState(false);
const [isAdminAuthenticated, setIsAdminAuthenticated] = useState(false);
const [isNodeActive, setIsNodeActive] = useState(() => {
const saved = localStorage.getItem('omni_node_active');
return saved === null ? true : saved === 'true';
});
const [globalStats, setGlobalStats] = useState<GlobalStats>({
totalUsers: 4820,
activeNodes: 142,
totalPlatformRevenue: 2845000,
totalRuns: 112400,
serverStatus: 'online'
});
const [affiliateStats] = useState<AffiliateStats>({
referralCode: "Nexus-" + Math.random().toString(36).substring(7).toUpperCase(),
totalReferrals: 18,
referralEarnings: 650,
conversionRate: "14%"
});
useEffect(() => {
localStorage.setItem('omni_credits', credits.toString());
localStorage.setItem('omni_earnings', earnings.toString());
localStorage.setItem('omni_upi', payoutMethod);
localStorage.setItem('omni_node_active', isNodeActive.toString());
}, [credits, earnings, payoutMethod, isNodeActive]);
// Passive Income Simulation: Every 30 seconds, add a small royalty if node is active
useEffect(() => {
if (!isNodeActive) return;
const interval = setInterval(() => {
const passiveGain = Math.random() * 0.5 + 0.1;
setEarnings(prev => prev + passiveGain);
addNotification(`Passive Node Yield: +₹${passiveGain.toFixed(2)}`, 'success');
}, 30000);
return () => clearInterval(interval);
}, [isNodeActive]);
const addNotification = (text: string, type: 'success' | 'info' = 'info') => {
const id = Date.now();
setNotifications(prev => [{ id, text, type }, ...prev]);
setTimeout(() => setNotifications(prev => prev.filter(n => n.id !== id)), 4000);
};
useEffect(() => {
const checkHash = () => {
if (window.location.hash === '#master') {
setIsMasterMode(true);
if (!isAdminAuthenticated) setCurrentView(AppView.ADMIN_LOGIN);
else setCurrentView(AppView.ADMIN_PANEL);
} else {
setIsMasterMode(false);
if (currentView === AppView.ADMIN_PANEL || currentView === AppView.ADMIN_LOGIN) {
setCurrentView(AppView.EXPLORER);
}
}
};
checkHash();
window.addEventListener('hashchange', checkHash);
return () => window.removeEventListener('hashchange', checkHash);
}, [currentView, isAdminAuthenticated]);
const handleNavigate = (view: AppView, toolId?: string) => {
setCurrentView(view);
if (toolId) {
const tool = [...INITIAL_TOOLS, ...customTools].find(t => t.id === toolId);
if (tool) setActiveTool(tool);
}
setIsSidebarOpen(false);
};
const handleToolRun = (toolEpc: number) => {
if (credits < 10) {
addNotification("Credits Low! Buy Fuel to continue.", 'info');
setCurrentView(AppView.PRICING);
return false;
}
setCredits(prev => prev - 10);
// Founder Earns 10% of EPC as Passive Income for every tool run
const royalty = (toolEpc || 10) * 0.1;
setEarnings(prev => prev + royalty);
addNotification(`₹${royalty.toFixed(2)} Royalty Added to Vault!`, 'success');
return true;
};
const handleCreateTool = (newTool: Tool) => {
setCustomTools(prev => [newTool, ...prev]);
addNotification(`Asset "${newTool.name}" deployed to Market!`, 'success');
setCurrentView(AppView.EXPLORER);
};
const handleWithdraw = () => {
if (!payoutMethod) {
addNotification("Please set your UPI ID in Vault first.", 'info');
return;
}
const amount = earnings;
if (amount < 100) {
addNotification("Minimum ₹100 required for UPI withdrawal.", 'info');
return;
}
setEarnings(0);
addNotification(`₹${amount.toFixed(2)} Transfer initiated to ${payoutMethod}!`, 'success');
};
const handlePaymentSuccess = (amount: number, creditAmount: number) => {
setCredits(prev => prev + creditAmount);
setGlobalStats(prev => ({ ...prev, totalPlatformRevenue: prev.totalPlatformRevenue + amount }));
addNotification(`${creditAmount} Fuel added to your Node.`, 'success');
setCurrentView(AppView.EXPLORER);
};
// ADMIN SIMULATOR: Allows the owner to simulate global user traffic and see revenue
const simulateGlobalTraffic = () => {
const mockRoyalty = Math.floor(Math.random() * 20) + 5;
setEarnings(prev => prev + mockRoyalty);
setGlobalStats(prev => ({ ...prev, totalRuns: prev.totalRuns + 1 }));
addNotification(`Mock Traffic: ₹${mockRoyalty} Royalty Captured!`, 'success');
};
if (currentView === AppView.ADMIN_LOGIN) {
return <AdminLogin onLoginSuccess={() => setIsAdminAuthenticated(true)} onCancel={() => { window.location.hash = ''; setCurrentView(AppView.EXPLORER); }} />;
}
if (isMasterMode && isAdminAuthenticated) {
return (
<div className="h-screen bg-[#020617] text-slate-100 overflow-y-auto font-sans">
<nav className="flex items-center justify-between px-8 py-6 border-b border-white/5 bg-slate-950 sticky top-0 z-50">
<div className="flex items-center gap-6">
<h2 className="text-xl font-black uppercase italic tracking-tighter">Business Console</h2>
<button
onClick={simulateGlobalTraffic}
className="bg-emerald-500 text-black px-5 py-2 rounded-xl text-[10px] font-black uppercase tracking-widest hover:scale-105 transition-all shadow-lg"
>
Simulate Global Traffic
</button>
</div>
<button onClick={() => { setIsAdminAuthenticated(false); window.location.hash = ''; }} className="text-[10px] font-black uppercase tracking-widest border border-slate-800 px-4 py-2 rounded-xl hover:bg-white hover:text-black transition-all">Exit Console</button>
</nav>
<AdminView stats={globalStats} />
</div>
);
}
if (currentView === AppView.LANDING) {
return <LandingPage onGetStarted={() => setCurrentView(AppView.EXPLORER)} />;
}
return (
<div className="flex h-screen bg-[#020617] text-slate-100 overflow-hidden font-sans">
<Sidebar
currentView={currentView}
onNavigate={handleNavigate}
isOpen={isSidebarOpen}
setIsOpen={setIsSidebarOpen}
credits={credits}
isAdmin={false}
onToggleAdmin={() => {}}
/>
<main className="flex-1 flex flex-col relative overflow-hidden h-full">
<header className="flex items-center justify-between px-8 py-6 border-b border-slate-900/50 bg-[#020617]/80 backdrop-blur-md z-40">
<div className="flex items-center gap-4 lg:hidden">
<button onClick={() => setIsSidebarOpen(true)} className="p-2 text-slate-400">
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16m-7 6h7" /></svg>
</button>
</div>
<div className="flex items-center gap-6">
<h2 className="text-xl font-black text-white tracking-tighter uppercase italic">{currentView.replace('_', ' ')}</h2>
<div className="hidden md:flex items-center gap-2 px-3 py-1 bg-emerald-500/10 rounded-full border border-emerald-500/20">
<span className="w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"></span>
<span className="text-[8px] font-black uppercase text-emerald-400 tracking-widest">Master Node: Active</span>
</div>
</div>
<div className="flex items-center gap-4">
<div className="hidden sm:flex bg-[#0a0f1e] border border-slate-800 px-5 py-2 rounded-2xl items-center gap-2">
<span className="text-xs font-black text-indigo-400">{credits} Fuel</span>
</div>
<button onClick={() => setCurrentView(AppView.CREATE)} className="bg-white text-slate-950 px-6 py-2.5 rounded-2xl text-[10px] font-black uppercase tracking-widest shadow-xl transition-transform hover:scale-105">Deploy Asset</button>
</div>
</header>
<div className="flex-1 overflow-y-auto no-scrollbar bg-[radial-gradient(circle_at_top_right,_var(--tw-gradient-stops))] from-indigo-500/5 via-transparent to-transparent">
{currentView === AppView.EXPLORER && <ExplorerView onSelectTool={(tool) => handleNavigate(AppView.TOOL_EXECUTION, tool.id)} availableTools={[...INITIAL_TOOLS, ...customTools]} />}
{currentView === AppView.CREATE && <CreateView onCreateTool={handleCreateTool} />}
{currentView === AppView.TOOL_EXECUTION && activeTool && <ToolExecutionView tool={activeTool} onRun={() => handleToolRun(activeTool.epc || 10)} />}
{currentView === AppView.DASHBOARD && (
<DashboardView
earnings={earnings}
onWithdraw={handleWithdraw}
payoutMethod={payoutMethod}
setPayoutMethod={setPayoutMethod}
affiliateStats={affiliateStats}
isNodeActive={isNodeActive}
onToggleNode={() => setIsNodeActive(!isNodeActive)}
/>
)}
{currentView === AppView.PRICING && <PricingView onPaymentSuccess={handlePaymentSuccess} />}
</div>
{/* Global Notifications */}
<div className="fixed top-24 right-6 z-[60] flex flex-col gap-3 pointer-events-none">
{notifications.map(n => (
<div key={n.id} className="bg-[#0a0f1e] border border-emerald-500/30 px-6 py-4 rounded-2xl shadow-2xl animate-in slide-in-from-right duration-300 pointer-events-auto">
<p className="text-[10px] font-black uppercase tracking-wider text-slate-200">{n.text}</p>
</div>
))}
</div>
</main>
</div>
);
};
export default App;