Spaces:
Sleeping
Sleeping
Download components/DashboardView.tsx from aditya9708/omninexus-ai: direct link, hf CLI and curl.
- Browser
- Download file 19 kB
-
https://huggingface.co/spaces/aditya9708/omninexus-ai/resolve/main/components/DashboardView.tsx
- Command line
-
hf download hf://spaces/aditya9708/omninexus-ai/components/DashboardView.tsx
-
curl -L -o DashboardView.tsx https://huggingface.co/spaces/aditya9708/omninexus-ai/resolve/main/components/DashboardView.tsx
19 kB
| import React, { useState } from 'react'; | |
| import { AffiliateStats } from '../types'; | |
| import { GeminiService } from '../geminiService'; | |
| interface DashboardViewProps { | |
| earnings: number; | |
| onWithdraw: () => void; | |
| payoutMethod: string; | |
| setPayoutMethod: (method: string) => void; | |
| affiliateStats: AffiliateStats; | |
| isNodeActive: boolean; | |
| onToggleNode: () => void; | |
| } | |
| const DashboardView: React.FC<DashboardViewProps> = ({ | |
| earnings, | |
| onWithdraw, | |
| payoutMethod, | |
| setPayoutMethod, | |
| affiliateStats, | |
| isNodeActive, | |
| onToggleNode | |
| }) => { | |
| const [isEditingPayout, setIsEditingPayout] = useState(false); | |
| const [tempPayout, setTempPayout] = useState(payoutMethod); | |
| const [copied, setCopied] = useState(false); | |
| const [aiCaption, setAiCaption] = useState(''); | |
| const [isGeneratingCaption, setIsGeneratingCaption] = useState(false); | |
| const referralLink = `${window.location.origin}/#join-${affiliateStats.referralCode}`; | |
| const mockTransactions = [ | |
| { id: 1, type: 'Passive Royalty', tool: 'Gemini 3 Pro', amount: 4.00, date: 'Just Now' }, | |
| { id: 2, type: 'Referral Bonus', tool: 'User_4921 Top-up', amount: 159.90, date: '2 hours ago' }, | |
| { id: 3, type: 'Platform Reward', tool: 'Daily Active Node', amount: 10.00, date: 'Today' }, | |
| { id: 4, type: 'Passive Royalty', tool: 'Imagen 4.0 Pro', amount: 6.00, date: 'Today' }, | |
| ]; | |
| const savePayout = () => { | |
| setPayoutMethod(tempPayout); | |
| setIsEditingPayout(false); | |
| }; | |
| const handleCopy = () => { | |
| navigator.clipboard.writeText(referralLink); | |
| setCopied(true); | |
| setTimeout(() => setCopied(false), 2000); | |
| }; | |
| const generateViralCaption = async () => { | |
| setIsGeneratingCaption(true); | |
| try { | |
| const { text } = await GeminiService.chat( | |
| `Write a super catchy, high-conversion viral WhatsApp/Social Media message in Hinglish to promote my AI store "OmniNexus AI". | |
| The message should sound like a personal recommendation from a successful founder. | |
| Key points: | |
| - Users get 500 FREE credits on signup. | |
| - Access to Gemini 3 Pro, Imagen 4.0, and Veo Video Gen. | |
| - Earn passive income in INR via UPI by sharing. | |
| - Link is: ${referralLink} | |
| Use emojis and make it look like a viral 'loot' deal.` | |
| ); | |
| setAiCaption(text); | |
| } catch (err) { | |
| setAiCaption("Bhai! AI tools use karo aur ghar baithe paise kamao. 500 free credits yahan milenge: " + referralLink); | |
| } finally { | |
| setIsGeneratingCaption(false); | |
| } | |
| }; | |
| const shareOnWhatsApp = (customText?: string) => { | |
| const text = customText || `Bhai! Maine OmniNexus AI use karke passive income kamaana shuru kar diya hai. Aap bhi try karo: ${referralLink}`; | |
| window.open(`https://wa.me/?text=${encodeURIComponent(text)}`, '_blank'); | |
| }; | |
| const shareOnTwitter = (customText?: string) => { | |
| const text = customText || `Bhai! Maine OmniNexus AI use karke passive income kamaana shuru kar diya hai. Aap bhi try karo: ${referralLink}`; | |
| window.open(`https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}`, '_blank'); | |
| }; | |
| const shareOnFacebook = () => { | |
| window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(referralLink)}`, '_blank'); | |
| }; | |
| const [messageCopied, setMessageCopied] = useState(false); | |
| const handleCopyMessage = (text: string) => { | |
| navigator.clipboard.writeText(text); | |
| setMessageCopied(true); | |
| setTimeout(() => setMessageCopied(false), 2000); | |
| }; | |
| return ( | |
| <div className="max-w-6xl mx-auto px-6 py-12 pb-32 animate-in fade-in duration-700"> | |
| <div className="mb-12 flex flex-col md:flex-row md:items-end justify-between gap-6"> | |
| <div> | |
| <h1 className="text-6xl font-black text-white tracking-tighter italic mb-2">The Vault.</h1> | |
| <p className="text-slate-500 font-medium italic">Primary Settlement Hub for {payoutMethod}</p> | |
| </div> | |
| <div className="flex gap-3"> | |
| <div className="bg-emerald-500/10 border border-emerald-500/20 px-6 py-3 rounded-2xl"> | |
| <p className="text-[10px] font-black text-emerald-500 uppercase tracking-widest">UPI Status</p> | |
| <p className="text-xs font-bold text-white">VERIFIED & LIVE</p> | |
| </div> | |
| <div className="bg-amber-500/10 border border-amber-500/20 px-6 py-3 rounded-2xl"> | |
| <p className="text-[10px] font-black text-amber-500 uppercase tracking-widest">Node Level</p> | |
| <p className="text-xs font-bold text-white">FOUNDER ELITE 🚀</p> | |
| </div> | |
| </div> | |
| </div> | |
| <div className="grid grid-cols-1 lg:grid-cols-3 gap-8 mb-12"> | |
| {/* EARNINGS CARD */} | |
| <div className="lg:col-span-2 bg-[#0a0f1e] border border-slate-800 rounded-[48px] p-12 relative overflow-hidden group shadow-3xl"> | |
| <div className="relative z-10"> | |
| <div className="flex justify-between items-start mb-4"> | |
| <p className="text-[10px] font-black text-slate-600 uppercase tracking-widest">Settled Balance (INR)</p> | |
| <span className={`text-[8px] font-black px-3 py-1 rounded-full text-white uppercase tracking-widest ${isNodeActive ? 'bg-emerald-600' : 'bg-slate-800'}`}> | |
| {isNodeActive ? 'Passive Mode Active' : 'Passive Mode Paused'} | |
| </span> | |
| </div> | |
| <h2 className="text-8xl font-black text-white mb-10 italic tracking-tighter">₹{earnings.toFixed(2)}</h2> | |
| <div className="flex flex-col sm:flex-row gap-4"> | |
| <button | |
| onClick={onWithdraw} | |
| disabled={earnings < 100} | |
| className={`flex-1 py-6 rounded-3xl font-black uppercase text-xs tracking-widest transition-all ${earnings >= 100 ? 'bg-indigo-600 text-white shadow-3xl shadow-indigo-600/30 hover:scale-[1.02]' : 'bg-slate-900 text-slate-700 cursor-not-allowed border border-white/5'}`} | |
| > | |
| {earnings < 100 ? 'Min ₹100 for Payout' : 'Instant Withdrawal'} | |
| </button> | |
| <div className="bg-[#020617] border border-slate-800 rounded-3xl p-4 flex flex-col justify-center min-w-[220px] relative group/upi"> | |
| <div className="flex items-center gap-1 mb-1"> | |
| <svg className="w-2 h-2 text-emerald-500" fill="currentColor" viewBox="0 0 20 20"><path fillRule="evenodd" d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z" clipRule="evenodd" /></svg> | |
| <p className="text-[8px] font-black text-slate-600 uppercase tracking-widest">Secure Payout Vault</p> | |
| </div> | |
| <div className="flex items-center justify-between"> | |
| <span className="text-xs font-bold text-emerald-400 truncate max-w-[140px]">{payoutMethod}</span> | |
| <button | |
| onClick={() => setIsEditingPayout(true)} | |
| className="text-[9px] font-black text-indigo-400 uppercase ml-2 hover:text-white transition-colors flex items-center gap-1" | |
| > | |
| <span>Update</span> | |
| <svg className="w-2 h-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={3} d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" /></svg> | |
| </button> | |
| </div> | |
| <div className="absolute -top-2 -right-2 bg-emerald-500 text-[6px] font-black px-2 py-0.5 rounded-full text-black uppercase tracking-tighter opacity-0 group-hover/upi:opacity-100 transition-opacity">Private</div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| {/* PASSIVE INCOME ENGINE */} | |
| <div className="bg-[#0a0f1e] border border-slate-800 rounded-[48px] p-10 flex flex-col justify-between relative overflow-hidden group shadow-3xl"> | |
| <div className="relative z-10"> | |
| <div className="flex items-center gap-2 mb-4"> | |
| <div className={`w-2 h-2 rounded-full ${isNodeActive ? 'bg-emerald-500 animate-pulse' : 'bg-slate-700'}`}></div> | |
| <h3 className="text-xl font-black text-white italic uppercase tracking-tighter">Income Engine</h3> | |
| </div> | |
| <p className="text-slate-500 text-[10px] font-bold uppercase tracking-widest mb-8 leading-relaxed"> | |
| Your node captures micro-royalties from global AI traffic. | |
| </p> | |
| <div className="space-y-4 mb-8"> | |
| <div className="flex justify-between items-center py-3 border-b border-white/5"> | |
| <span className="text-[9px] font-black text-slate-600 uppercase tracking-widest">Node Status</span> | |
| <span className={`text-[9px] font-black uppercase tracking-widest ${isNodeActive ? 'text-emerald-400' : 'text-slate-500'}`}> | |
| {isNodeActive ? 'ACTIVE' : 'PAUSED'} | |
| </span> | |
| </div> | |
| <div className="flex justify-between items-center py-3 border-b border-white/5"> | |
| <span className="text-[9px] font-black text-slate-600 uppercase tracking-widest">Daily Yield</span> | |
| <span className="text-[9px] font-black text-white uppercase tracking-widest">₹45 - ₹120</span> | |
| </div> | |
| <div className="flex justify-between items-center py-3"> | |
| <span className="text-[9px] font-black text-slate-600 uppercase tracking-widest">Referral Royalty</span> | |
| <span className="text-[9px] font-black text-indigo-400 uppercase tracking-widest">10% FIXED</span> | |
| </div> | |
| </div> | |
| </div> | |
| <button | |
| onClick={onToggleNode} | |
| className={`w-full py-4 rounded-2xl font-black text-[10px] uppercase tracking-widest transition-all ${isNodeActive ? 'bg-red-500/10 text-red-500 border border-red-500/20 hover:bg-red-500 hover:text-white' : 'bg-emerald-500 text-black shadow-xl shadow-emerald-500/20 hover:scale-105'}`} | |
| > | |
| {isNodeActive ? 'Deactivate Node' : 'Activate Passive Node'} | |
| </button> | |
| </div> | |
| {/* AI AD ENGINE */} | |
| <div className="bg-indigo-600 p-10 rounded-[48px] shadow-3xl shadow-indigo-600/20 flex flex-col justify-between overflow-hidden relative group"> | |
| <div className="relative z-10"> | |
| <h3 className="text-3xl font-black text-white italic uppercase tracking-tighter mb-4">Viral Kit</h3> | |
| <p className="text-indigo-100/70 text-sm font-medium mb-6">Gemini generates viral scripts to grow your business.</p> | |
| {aiCaption ? ( | |
| <div className="bg-black/20 p-4 rounded-2xl border border-white/10 mb-6 max-h-32 overflow-y-auto no-scrollbar"> | |
| <p className="text-[10px] text-white font-medium italic leading-relaxed">"{aiCaption}"</p> | |
| </div> | |
| ) : ( | |
| <div className="bg-indigo-700/50 p-6 rounded-2xl border border-white/5 mb-6 text-center"> | |
| <p className="text-[8px] font-black text-indigo-200 uppercase tracking-widest leading-relaxed">Refer friends to earn 10% on every Top-up they make</p> | |
| </div> | |
| )} | |
| </div> | |
| <div className="space-y-3 relative z-10"> | |
| <button | |
| onClick={generateViralCaption} | |
| disabled={isGeneratingCaption} | |
| className="w-full bg-white text-indigo-600 py-4 rounded-2xl font-black text-xs uppercase tracking-widest shadow-xl disabled:opacity-50 hover:scale-105 transition-transform" | |
| > | |
| {isGeneratingCaption ? 'Thinking...' : aiCaption ? 'New Script' : 'Generate Viral Ad'} | |
| </button> | |
| {aiCaption && ( | |
| <div className="grid grid-cols-2 gap-2"> | |
| <button onClick={() => shareOnWhatsApp(aiCaption)} className="bg-[#25D366] text-white py-3 rounded-xl font-black text-[10px] uppercase tracking-widest flex items-center justify-center gap-2 hover:scale-105 transition-all"> | |
| </button> | |
| <button onClick={() => shareOnTwitter(aiCaption)} className="bg-black text-white py-3 rounded-xl font-black text-[10px] uppercase tracking-widest flex items-center justify-center gap-2 hover:scale-105 transition-all border border-white/10"> | |
| </button> | |
| <button onClick={shareOnFacebook} className="bg-[#1877F2] text-white py-3 rounded-xl font-black text-[10px] uppercase tracking-widest flex items-center justify-center gap-2 hover:scale-105 transition-all"> | |
| </button> | |
| <button onClick={() => handleCopyMessage(aiCaption)} className="bg-indigo-950 text-white py-3 rounded-xl font-black text-[10px] uppercase tracking-widest flex items-center justify-center gap-2 hover:scale-105 transition-all border border-white/5"> | |
| {messageCopied ? 'Copied!' : 'Copy Text'} | |
| </button> | |
| </div> | |
| )} | |
| </div> | |
| </div> | |
| </div> | |
| {/* REFERRAL LINK */} | |
| <div className="mb-12"> | |
| <h3 className="text-2xl font-black text-white italic uppercase tracking-tighter mb-8">Growth Center</h3> | |
| <div className="grid grid-cols-1 md:grid-cols-4 gap-6"> | |
| <div className="bg-[#0a0f1e] p-8 rounded-3xl border border-white/5 flex flex-col items-center text-center"> | |
| <div className="w-24 h-24 bg-white rounded-2xl mb-4 p-2 flex items-center justify-center shadow-2xl"> | |
| <img src={`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(referralLink)}`} className="w-full h-full object-contain" alt="QR" /> | |
| </div> | |
| <p className="text-[10px] font-black text-white uppercase mb-1 tracking-widest">Business QR</p> | |
| <button onClick={handleCopy} className="text-[8px] font-black text-indigo-400 underline uppercase">{copied ? 'Copied Link' : 'Copy Link'}</button> | |
| </div> | |
| <div className="bg-[#0a0f1e] p-8 rounded-3xl border border-white/5 md:col-span-3 flex flex-col justify-center relative overflow-hidden group"> | |
| <p className="text-[10px] font-black text-slate-600 uppercase mb-4 tracking-widest">Your Permanent Business Link</p> | |
| <div className="flex gap-4 items-center"> | |
| <div className="flex-1 bg-black/50 p-5 rounded-2xl border border-white/5 text-xs text-slate-400 font-bold truncate"> | |
| {referralLink} | |
| </div> | |
| <button onClick={handleCopy} className="bg-indigo-600 text-white px-8 py-5 rounded-2xl font-black text-xs uppercase tracking-widest hover:scale-105 transition-all"> | |
| {copied ? 'Copied' : 'Copy'} | |
| </button> | |
| </div> | |
| <p className="mt-6 text-[10px] text-emerald-400 font-black uppercase italic">Founder Tip: Put this in your Instagram bio to attract global nodes.</p> | |
| </div> | |
| </div> | |
| </div> | |
| {/* TRANSACTION TABLE */} | |
| <div className="bg-[#0a0f1e] border border-slate-800 rounded-[48px] overflow-hidden shadow-3xl"> | |
| <div className="p-10 border-b border-white/5 flex justify-between items-center bg-black/20"> | |
| <h3 className="text-2xl font-black text-white italic uppercase tracking-tighter">Settlement Ledger</h3> | |
| <span className="text-[10px] font-black text-slate-600 uppercase tracking-widest">Real-time Stats</span> | |
| </div> | |
| <div className="overflow-x-auto"> | |
| <table className="w-full text-left border-collapse"> | |
| <thead> | |
| <tr className="bg-black/40"> | |
| <th className="px-10 py-5 text-[9px] font-black text-slate-700 uppercase tracking-widest">Source Description</th> | |
| <th className="px-10 py-5 text-[9px] font-black text-slate-700 uppercase tracking-widest text-right">Income (INR)</th> | |
| <th className="px-10 py-5 text-[9px] font-black text-slate-700 uppercase tracking-widest text-right">Status</th> | |
| </tr> | |
| </thead> | |
| <tbody className="divide-y divide-white/5"> | |
| {mockTransactions.map((tx) => ( | |
| <tr key={tx.id} className="hover:bg-white/5 transition-colors group"> | |
| <td className="px-10 py-6"> | |
| <p className="text-sm font-bold text-white group-hover:text-indigo-400 transition-colors">{tx.tool}</p> | |
| <p className="text-[8px] text-slate-600 uppercase font-black tracking-widest mt-1">{tx.type} • {tx.date}</p> | |
| </td> | |
| <td className="px-10 py-6 text-right"> | |
| <p className="text-sm font-black text-emerald-400">+₹{tx.amount.toFixed(2)}</p> | |
| </td> | |
| <td className="px-10 py-6 text-right"> | |
| <span className="text-[8px] font-black text-emerald-500 bg-emerald-500/5 border border-emerald-500/20 px-3 py-1 rounded-md uppercase">Settled</span> | |
| </td> | |
| </tr> | |
| ))} | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| {isEditingPayout && ( | |
| <div className="fixed inset-0 z-[100] flex items-center justify-center p-6 bg-black/90 backdrop-blur-xl"> | |
| <div className="w-full max-w-md bg-[#0a0f1e] border border-indigo-500/20 rounded-[40px] p-10 animate-in zoom-in duration-300"> | |
| <h3 className="text-2xl font-black text-white mb-2 uppercase italic tracking-tighter">Vault Update</h3> | |
| <p className="text-[9px] font-black text-slate-600 uppercase tracking-widest mb-8">Configure your INR Payout Address</p> | |
| <input | |
| type="text" | |
| value={tempPayout} | |
| onChange={(e) => setTempPayout(e.target.value)} | |
| placeholder="aditya@ptyes" | |
| className="w-full bg-[#020617] border border-slate-800 rounded-2xl px-6 py-5 text-white font-black uppercase text-xs focus:border-indigo-500 outline-none transition-all mb-6" | |
| /> | |
| <div className="flex gap-4"> | |
| <button onClick={savePayout} className="flex-1 bg-white text-black py-4 rounded-2xl font-black uppercase text-xs tracking-widest shadow-xl hover:scale-105 transition-all">Save Wallet</button> | |
| <button onClick={() => setIsEditingPayout(false)} className="px-6 text-slate-600 font-black uppercase text-[10px]">Cancel</button> | |
| </div> | |
| </div> | |
| </div> | |
| )} | |
| </div> | |
| ); | |
| }; | |
| export default DashboardView; | |