import React, { useState, useEffect, useMemo } from 'react'; import { LucideLayoutDashboard, LucideUsers, LucideBox, LucideCalendar, LucideShieldCheck, LucideBriefcase, LucideLogOut, LucidePlus, LucideSearch, LucideAlertTriangle, LucideCheckCircle, LucideXCircle, LucideClock, LucideFileText, LucideUserPlus, LucideSettings, LucideMenu, LucideX, LucideBell, LucideChevronRight, LucideFilter, LucideDownload, LucideTrash2, LucideEdit, LucideTrophy, LucideActivity, LucideVideo, LucideDollarSign, LucideGamepad2, LucideShare2, LucideCreditCard, LucideChevronDown, LucideInstagram, LucideYoutube, LucideUpload, LucideMoreHorizontal, LucideTarget, LucideArrowRight, LucideTruck, LucideSave, LucideUserMinus, LucideFileCheck, LucidePieChart, LucideTrendingUp, LucideBriefcase as LucideOrg, LucidePercent, LucideReceipt } from 'lucide-react'; import { initializeApp } from 'firebase/app'; import { getAuth, onAuthStateChanged, signInWithCustomToken, signInAnonymously, signOut } from 'firebase/auth'; import { getFirestore, collection, doc, addDoc, updateDoc, deleteDoc, onSnapshot, query, orderBy, serverTimestamp, setDoc, getDoc, where, arrayUnion, arrayRemove } from 'firebase/firestore'; // --- Firebase Initialization --- const firebaseConfig = JSON.parse(__firebase_config); const app = initializeApp(firebaseConfig); const auth = getAuth(app); const db = getFirestore(app); const appId = typeof __app_id !== 'undefined' ? __app_id : 'dot-exe-v9'; // --- Interfaces --- interface Log { id: string; action: string; user: string; timestamp: any; details: string; } interface Employee { id: string; name: string; role: string; salary: number; status: string; method: string; utr: string; joined: string; contract: string; } interface Transaction { id: string; title: string; type: 'income' | 'expense'; amount: number; date: any; category: string; } interface Deal { id: string; title: string; client: string; value: number; status: 'Sign Deal' | 'Asset Delivery' | 'Campaign Live' | 'Invoice' | 'Payment'; assigneeType: 'ORG' | 'Creator'; assigneeId?: string; assigneeName?: string; commission: number; invoiceUrl?: string; paymentInfo?: { txId: string; date: string; proofUrl: string }; } interface Event { id: string; title: string; type: string; time: string; date: string; description: string; } interface Scrim { id: string; date: any; opponent: string; map: string; result: 'Won' | 'Lost' | 'Draw'; score: string; stats: string; updatedBy: string; } interface Asset { id: string; name: string; category: string; assignedTo: string; location: string; status: 'Active' | 'Repair' | 'Lost'; } interface ContentTask { id: string; title: string; type: string; stage: string; priority: 'High' | 'Medium' | 'Low'; dueDate: string; assignee: string; } interface Role { id: string; name: string; desc: string; members: string[]; } // --- Shared Components --- function NavSection({ title }: { title: string }) { return (

{title}

); } function NavItem({ active, onClick, label, icon: Icon, hasNotification }: any) { return ( ); } function StatusBadge({ status }: { status: string }) { let color = 'bg-slate-500/20 text-slate-400'; const s = status.toLowerCase(); if (['payment', 'paid', 'approved', 'won', 'completed', 'income', 'signed'].includes(s)) color = 'bg-emerald-500/20 text-emerald-400'; if (['sign deal', 'asset delivery', 'campaign live', 'pending', 'processing', 'scheduled', 'review', 'in progress', 'ideation', 'scripting'].includes(s)) color = 'bg-amber-500/20 text-amber-400'; if (['invoice', 'rejected', 'lost', 'overdue', 'unpaid', 'expense', 'repair', 'missing'].includes(s)) color = 'bg-blue-500/20 text-blue-400'; return ( {status} ); } function MetricCard({ title, value, subtitle, icon: Icon, colorClass, iconBgClass }: any) { return (

{title}

{value}

{subtitle}

); } function ActivityItem({ title, value, timestamp }: any) { return (

{title}

{value} • {timestamp}

); } function Modal({ isOpen, onClose, title, children }: any) { if (!isOpen) return null; return (
{/* Backdrop */}
{/* Modal Card */}
e.stopPropagation()} > {/* Header - Fixed */}

{title}

{/* Body - Scrollable */}
{children}
); } // --- Specific Views --- // 3. Payroll Center function PayrollView({ employees, updateEmployee, logAction, appId }: any) { return (

Payroll Center

Manage salaries and transaction details

{employees.map((e: any) => ( ))} {employees.length === 0 && ( )}
Employee Method Transaction Details (UTR/TRX) Amount Status Actions

{e.name}

{e.role}

updateEmployee(e.id, { utr: ev.target.value })} onBlur={() => logAction(`Updated UTR for ${e.name}`)} className="bg-[#0a0a0c] border border-[#232329] rounded px-3 py-1.5 text-xs text-white w-full outline-none focus:border-purple-500 placeholder-slate-600" /> ₹{e.salary.toLocaleString()} {e.status === 'Unpaid' ? ( ) : ( )}
No employees found. Add them in Roster view.
); } // 4. Team Access (Permissions) - FIXED PREDEFINED ROLES function AccessView({ roles, addRole, updateRole, logAction, employees }: any) { const [addMemberToRole, setAddMemberToRole] = useState(null); const [selectedMember, setSelectedMember] = useState(''); // Predefined Role Definitions (Static Descriptions) const PREDEFINED_ROLES = [ { name: 'Management (SuperAdmin)', desc: 'Full System Access & Financial Control' }, { name: 'Manager', desc: 'Team Rosters, Scrims & Content Management' }, { name: 'Male Roster', desc: 'Scrims, Schedule & Asset Requests' }, { name: 'Female Roster', desc: 'Scrims, Schedule & Asset Requests' }, { name: 'Content Creators', desc: 'Social Pulse, Schedule & Content Pipeline' }, { name: 'Editors', desc: 'Content Pipeline & Asset Management' } ]; const handleAddMember = async (e: any) => { e.preventDefault(); if(!selectedMember) return; // Check if role exists in DB, if not create it first const existingRole = roles.find((r: any) => r.name === addMemberToRole.name); if (existingRole) { await updateRole(existingRole.id, { members: arrayUnion(selectedMember) }); } else { await addRole({ name: addMemberToRole.name, desc: addMemberToRole.desc, members: [selectedMember] }); } setAddMemberToRole(null); setSelectedMember(''); logAction(`Added ${selectedMember} to ${addMemberToRole.name}`); }; const handleRemoveMember = (roleId: string, memberName: string) => { if(confirm(`Remove ${memberName} from this role?`)) { updateRole(roleId, { members: arrayRemove(memberName) }); logAction(`Removed ${memberName} from role`); } }; return (

Team Access

Predefined Role Assignments

{/* Add Member Modal */} setAddMemberToRole(null)} title={`Add Member to ${addMemberToRole?.name}`}>

Only employees added to the Roster & Staff list can be assigned a role here.

{PREDEFINED_ROLES.map((defRole) => { // Find actual DB data for this role const dbRole = roles.find((r: any) => r.name === defRole.name); const members = dbRole ? dbRole.members : []; const roleId = dbRole ? dbRole.id : null; return (
Fixed Role

{defRole.name}

{defRole.desc}

Members ({members.length})
{members.map((m: string, idx: number) => (
{m[0]}
{m} {roleId && ( )}
))} {members.length === 0 && No members assigned}
); })}
); } // 5. Roster View - UPDATED WITH DELETE function RosterView({ employees, addEmployee, updateEmployee, deleteEmployee, logAction }: any) { const [isAdding, setIsAdding] = useState(false); const [isUpdatingContract, setIsUpdatingContract] = useState(null); const [newEmp, setNewEmp] = useState({ name: '', role: 'Editor', salary: 0, joined: new Date().toISOString().split('T')[0], contract: '' }); const [contractFile, setContractFile] = useState(null); const handleFileChange = (e: any, setFileState: any, setStatusState: any) => { const file = e.target.files[0]; if (file) { setFileState(file); setStatusState(prev => ({...prev, contract: `Uploaded: ${file.name}`})); } }; const handleAddSubmit = (e: any) => { e.preventDefault(); addEmployee({ ...newEmp, status: 'Unpaid', method: 'UPI', utr: '' }); setIsAdding(false); setNewEmp({ name: '', role: 'Editor', salary: 0, joined: new Date().toISOString().split('T')[0], contract: '' }); setContractFile(null); logAction(`Added new employee: ${newEmp.name}`); }; const handleContractUpdate = (e: any) => { e.preventDefault(); if (contractFile) { updateEmployee(isUpdatingContract.id, { contract: `Uploaded: ${contractFile.name}` }); logAction(`Updated contract for ${isUpdatingContract.name}`); setIsUpdatingContract(null); setContractFile(null); } }; const handleDelete = (e: React.MouseEvent, id: string, name: string) => { e.stopPropagation(); if(window.confirm(`Are you sure you want to remove ${name} from the roster? This action is permanent.`)) { deleteEmployee(id); logAction(`Deleted employee: ${name}`); } }; return (

Rosters & Staff

Employee contracts and onboarding

{/* Add Employee Modal */} setIsAdding(false)} title="Add New Employee">
setNewEmp({...newEmp, name: e.target.value})} />
setNewEmp({...newEmp, salary: Number(e.target.value)})} />
setNewEmp({...newEmp, joined: e.target.value})} />
handleFileChange(e, setContractFile, setNewEmp)} className="w-full text-xs text-slate-400 file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-xs file:font-semibold file:bg-blue-600 file:text-white hover:file:bg-blue-500 cursor-pointer" /> {newEmp.contract &&

{newEmp.contract}

}
{/* Update Contract Modal */} setIsUpdatingContract(null)} title={`Update Contract: ${isUpdatingContract?.name}`}>
setContractFile(e.target.files?.[0])} className="w-full text-xs text-slate-400 file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-xs file:font-semibold file:bg-blue-600 file:text-white hover:file:bg-blue-500 cursor-pointer" />

Uploading will overwrite the existing contract status.

{employees.map((e: any) => ( ))}
Name/Role Joining Date Salary Contract Actions
{e.name[0]}

{e.name}

{e.role}

{e.joined} ₹{e.salary.toLocaleString()} {e.contract ? ( Signed ) : ( Pending )}
); } // 6. Finance View - UPDATED FOR COMMISSION LOGIC function FinanceView({ transactions, addTransaction, logAction, employees, deals }: any) { const [isAdding, setIsAdding] = useState(false); const [newTx, setNewTx] = useState({ title: '', type: 'expense', amount: 0, category: 'Ops' }); // --- Aggregated Stats --- // Deals Value - NOW ACCOUNTS FOR COMMISSION const activeDealsValue = deals.reduce((acc: number, d: any) => { const rawValue = Number(d.value) || 0; // If Org deal, take 100%. If Creator deal, take commission %. const commissionRate = d.assigneeType === 'Creator' ? (d.commission || 0) : 100; const orgShare = rawValue * (commissionRate / 100); return acc + orgShare; }, 0); // Payroll const totalMonthlyPayroll = employees.reduce((acc: number, e: any) => acc + (Number(e.salary) || 0), 0); // Logged const loggedIncome = transactions.filter((t: any) => t.type === 'income').reduce((acc: number, curr: any) => acc + curr.amount, 0); const loggedExpenses = transactions.filter((t: any) => t.type === 'expense').reduce((acc: number, curr: any) => acc + curr.amount, 0); const totalRevenue = loggedIncome + activeDealsValue; const totalExpenses = loggedExpenses + totalMonthlyPayroll; const netProfit = totalRevenue - totalExpenses; const runRate = totalExpenses * 12; // Expense Breakdown Calculation const expenseBreakdown = { Payroll: totalMonthlyPayroll, Ops: transactions.filter((t: any) => t.type === 'expense' && t.category === 'Ops').reduce((a,b) => a+b.amount, 0), Travel: transactions.filter((t: any) => t.type === 'expense' && t.category === 'Travel').reduce((a,b) => a+b.amount, 0), Equipment: transactions.filter((t: any) => t.type === 'expense' && t.category === 'Equipment').reduce((a,b) => a+b.amount, 0), PrizeMoney: transactions.filter((t: any) => t.type === 'expense' && t.category === 'Prize Money').reduce((a,b) => a+b.amount, 0), }; const handleSubmit = (e: any) => { e.preventDefault(); addTransaction(newTx); setIsAdding(false); setNewTx({ title: '', type: 'expense', amount: 0, category: 'Ops' }); }; return (

Finance Master

Real-time P&L (Includes Org Share of Deals & Payroll)

setIsAdding(false)} title="Log Transaction">
setNewTx({...newTx, title: e.target.value})} />
setNewTx({...newTx, amount: Number(e.target.value)})} />
{/* Top Cards */}

Total Revenue

₹{totalRevenue.toLocaleString()}

Deals (Org Share): ₹{activeDealsValue.toLocaleString()} | Logs: ₹{loggedIncome.toLocaleString()}

Total Expenses

₹{totalExpenses.toLocaleString()}

Payroll: ₹{totalMonthlyPayroll.toLocaleString()} | Logs: ₹{loggedExpenses.toLocaleString()}

Net Profit/Loss

= 0 ? 'text-white' : 'text-red-500'}`}> {netProfit < 0 ? '-' : ''}₹{Math.abs(netProfit).toLocaleString()}

= 0 ? 'bg-blue-500' : 'bg-red-500'}`}>
{/* Financial Overview & Breakdown */}

Expense Breakdown

{Object.entries(expenseBreakdown).map(([key, val]) => (
{key} ₹{val.toLocaleString()}
))}

Financial Health Deep Dive

Annual Run Rate

₹{runRate.toLocaleString()}

Deal Volume (Gross)

₹{deals.reduce((a:number,b:any)=>a+(Number(b.value)||0),0).toLocaleString()}

Org Commission

₹{activeDealsValue.toLocaleString()}

Fixed Burn

₹{totalMonthlyPayroll.toLocaleString()}

{/* Transaction Log */}

Recent Transactions

{transactions.map((t: any) => (

{t.title}

{t.category} • {t.date?.toDate ? t.date.toDate().toLocaleDateString() : 'Just now'}

{t.type === 'income' ? '+' : '-'}₹{t.amount.toLocaleString()}
))} {transactions.length === 0 &&

No transactions logged.

}
); } // 7. CRM View - UPDATED FOR ASSIGNMENT & COMMISSION & PIPELINE function CRMView({ deals, addDeal, updateDeal, employees }: any) { const [isAdding, setIsAdding] = useState(false); const [editingDeal, setEditingDeal] = useState(null); const [newDeal, setNewDeal] = useState({ title: '', client: '', value: 0, status: 'Sign Deal', assigneeType: 'ORG', assigneeId: '', assigneeName: '', commission: 100 }); // File Mock States for Uploads const [invoiceFile, setInvoiceFile] = useState(null); const [proofFile, setProofFile] = useState(null); const handleSave = async (e: any, isEdit: boolean) => { e.preventDefault(); const dealData = isEdit ? editingDeal : newDeal; // Resolve Name if (dealData.assigneeType === 'Creator' && dealData.assigneeId) { const creator = employees.find((e: any) => e.id === dealData.assigneeId); dealData.assigneeName = creator ? creator.name : 'Unknown'; } else { dealData.assigneeId = ''; dealData.assigneeName = 'Organization'; dealData.commission = 100; // Org deals are 100% revenue } // Handle File Mocking if (dealData.status === 'Invoice' && invoiceFile) { dealData.invoiceUrl = `uploaded_${invoiceFile.name}`; } if (dealData.status === 'Payment' && proofFile) { dealData.paymentInfo = { ...dealData.paymentInfo, proofUrl: `uploaded_${proofFile.name}` }; } if (isEdit) { await updateDeal(dealData.id, dealData); setEditingDeal(null); } else { await addDeal(dealData); setIsAdding(false); setNewDeal({ title: '', client: '', value: 0, status: 'Sign Deal', assigneeType: 'ORG', assigneeId: '', commission: 100 }); } setInvoiceFile(null); setProofFile(null); }; const renderForm = (data: any, setData: any, isEdit: boolean) => (
handleSave(e, isEdit)} className="space-y-4">
setData({...data, title: e.target.value})} />
setData({...data, client: e.target.value})} />
setData({...data, value: Number(e.target.value)})} />
{/* Conditional Uploads based on Status */} {data.status === 'Invoice' && (
setInvoiceFile(e.target.files?.[0])} />
)} {data.status === 'Payment' && (

Payment Details

setData({...data, paymentInfo: {...data.paymentInfo, txId: e.target.value}})} /> setData({...data, paymentInfo: {...data.paymentInfo, date: e.target.value}})} />
setProofFile(e.target.files?.[0])} />
)}
{data.assigneeType === 'Creator' && (
setData({...data, commission: Number(e.target.value)})} min="0" max="100" /> % Org
)}
); const stages = ['Sign Deal', 'Asset Delivery', 'Campaign Live', 'Invoice', 'Payment']; return (

CRM & Deals

Brand deal timelines and assignments

setIsAdding(false)} title="New Brand Deal"> {renderForm(newDeal, setNewDeal, false)} setEditingDeal(null)} title="Edit Deal"> {editingDeal && renderForm(editingDeal, setEditingDeal, true)}
{deals.map((d: any) => { const currentStageIndex = stages.indexOf(d.status); return (

Campaign: {d.title}

{d.assigneeType === 'ORG' ? ( ORG ) : ( {d.assigneeName} ({d.commission}% Org) )} {d.invoiceUrl && } {d.paymentInfo?.proofUrl && }

Client: {d.client} • Value: ₹{d.value.toLocaleString()} | Org Rev: ₹{(d.value * ((d.commission||100)/100)).toLocaleString()}

{stages.map((stage, idx) => ( {stage} ))}
); })} {deals.length === 0 &&

No active deals.

}
); } // 8. Schedule function ScheduleView({ schedule, addEvent }: any) { const [isAdding, setIsAdding] = useState(false); const [newEvent, setNewEvent] = useState({ title: '', time: '10:00', type: 'Meeting', description: '' }); const handleSubmit = (e: any) => { e.preventDefault(); addEvent(newEvent); setIsAdding(false); setNewEvent({ title: '', time: '10:00', type: 'Meeting', description: '' }); }; return (

Ops Schedule

Matches, meetings, and deadlines

setIsAdding(false)} title="Add Schedule Event">
setNewEvent({...newEvent, time: e.target.value})} />
setNewEvent({...newEvent, title: e.target.value})} />
setNewEvent({...newEvent, description: e.target.value})} />
{schedule.sort((a: any, b: any) => a.time.localeCompare(b.time)).map((ev: any) => (
{ev.time}

{ev.title}

{ev.description}

))} {schedule.length === 0 &&

Schedule is clear.

}
); } // 9. Scrims function ScrimsView({ scrims, addScrim }: any) { const [isAdding, setIsAdding] = useState(false); const [newScrim, setNewScrim] = useState({ opponent: '', map: 'Ascent', result: 'Won', score: '13-0', stats: 'Duelist: 20/5', updatedBy: 'Coach' }); const handleSubmit = (e: any) => { e.preventDefault(); addScrim(newScrim); setIsAdding(false); setNewScrim({ opponent: '', map: 'Ascent', result: 'Won', score: '13-0', stats: 'Duelist: 20/5', updatedBy: 'Coach' }); }; return (

Scrim Results

Daily match performance log

setIsAdding(false)} title="Log Scrim Result">
setNewScrim({...newScrim, opponent: e.target.value})} />
setNewScrim({...newScrim, map: e.target.value})} />
setNewScrim({...newScrim, score: e.target.value})} />
setNewScrim({...newScrim, stats: e.target.value})} />
{scrims.map((s: any) => ( ))} {scrims.length === 0 && }
Date Opponent Map Result K/D Stats Updated By
{s.date?.toDate ? s.date.toDate().toLocaleDateString() : 'Today'} {s.opponent} {s.map} {s.score} {s.stats} {s.updatedBy}
No logs found.
); } // 10. Inventory function InventoryView({ inventory, addAsset, updateAsset }: any) { const [isAdding, setIsAdding] = useState(false); const [newAsset, setNewAsset] = useState({ name: '', category: 'Hardware', assignedTo: '', location: 'Office', status: 'Active' }); const handleSubmit = (e: any) => { e.preventDefault(); addAsset(newAsset); setIsAdding(false); setNewAsset({ name: '', category: 'Hardware', assignedTo: '', location: 'Office', status: 'Active' }); }; return (

Inventory & Assets

Track org equipment and devices

setIsAdding(false)} title="Register New Asset">
setNewAsset({...newAsset, name: e.target.value})} />
setNewAsset({...newAsset, assignedTo: e.target.value})} />
setNewAsset({...newAsset, location: e.target.value})} />
{inventory.map((item: any) => ( ))} {inventory.length === 0 && }
Asset Name Category Assigned To Location Status Actions
{item.name} {item.category}
{item.assignedTo?.[0] || '?'}
{item.assignedTo || 'Unassigned'}
{item.location}
No assets found.
); } // 11. Content Pipeline function ContentView({ content, addContent, updateContentStage }: any) { const [isAdding, setIsAdding] = useState(false); const [newTask, setNewTask] = useState({ title: '', type: 'Vlog', priority: 'Medium' }); const handleSubmit = (e: any) => { e.preventDefault(); addContent(newTask); setIsAdding(false); setNewTask({ title: '', type: 'Vlog', priority: 'Medium' }); }; const stages = ['Ideation', 'Scripting', 'Filming', 'Editing', 'Ready to Post']; return (

Content Pipeline

Production status and scheduling

setIsAdding(false)} title="New Content Task">
setNewTask({...newTask, title: e.target.value})} />
{stages.map((stage, i) => (

{stage}

{content.filter((c: any) => c.stage === stage).length}
{content.filter((c: any) => c.stage === stage).map((card: any) => (
{card.priority} {card.type}

{card.title}

{i > 0 && } {i < stages.length - 1 && }
))}
))}
); } // --- Main App Component --- export default function DotExeDashboardV9() { const [user, setUser] = useState(null); const [activeTab, setActiveTab] = useState('overview'); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); // Data States const [employees, setEmployees] = useState([]); const [transactions, setTransactions] = useState([]); const [deals, setDeals] = useState([]); const [schedule, setSchedule] = useState([]); const [scrims, setScrims] = useState([]); const [inventory, setInventory] = useState([]); const [content, setContent] = useState([]); const [roles, setRoles] = useState([]); const [recentActivity, setRecentActivity] = useState([]); // Auth useEffect(() => { const initAuth = async () => { if (typeof __initial_auth_token !== 'undefined' && __initial_auth_token) { await signInWithCustomToken(auth, __initial_auth_token); } else { await signInAnonymously(auth); } }; initAuth(); const unsubscribe = onAuthStateChanged(auth, (u) => { if (u) setUser({ ...u, role: 'admin' }); else setUser(null); }); return () => unsubscribe(); }, []); // Data Listeners useEffect(() => { if (!user) return; const unsubRoster = onSnapshot(collection(db, 'artifacts', appId, 'public', 'data', 'roster'), (s) => setEmployees(s.docs.map(d => ({id: d.id, ...d.data()})))); const unsubFinance = onSnapshot(query(collection(db, 'artifacts', appId, 'public', 'data', 'finance'), orderBy('date', 'desc')), (s) => setTransactions(s.docs.map(d => ({id: d.id, ...d.data()})))); const unsubDeals = onSnapshot(collection(db, 'artifacts', appId, 'public', 'data', 'deals'), (s) => setDeals(s.docs.map(d => ({id: d.id, ...d.data()})))); const unsubSchedule = onSnapshot(collection(db, 'artifacts', appId, 'public', 'data', 'schedule'), (s) => setSchedule(s.docs.map(d => ({id: d.id, ...d.data()})))); const unsubScrims = onSnapshot(query(collection(db, 'artifacts', appId, 'public', 'data', 'scrims'), orderBy('date', 'desc')), (s) => setScrims(s.docs.map(d => ({id: d.id, ...d.data()})))); const unsubInventory = onSnapshot(collection(db, 'artifacts', appId, 'public', 'data', 'inventory'), (s) => setInventory(s.docs.map(d => ({id: d.id, ...d.data()})))); const unsubContent = onSnapshot(collection(db, 'artifacts', appId, 'public', 'data', 'content'), (s) => setContent(s.docs.map(d => ({id: d.id, ...d.data()})))); const unsubRoles = onSnapshot(collection(db, 'artifacts', appId, 'public', 'data', 'roles'), (s) => setRoles(s.docs.map(d => ({id: d.id, ...d.data()})))); return () => { unsubRoster(); unsubFinance(); unsubDeals(); unsubSchedule(); unsubScrims(); unsubInventory(); unsubContent(); unsubRoles(); }; }, [user]); // Derived Activity Log useEffect(() => { const activities: any[] = []; scrims.slice(0, 3).forEach(s => activities.push({ title: 'Scrim Result', value: `${s.result} vs ${s.opponent}`, timestamp: 'Today' })); transactions.slice(0, 3).forEach(t => activities.push({ title: 'Transaction', value: `${t.type === 'income' ? '+' : '-'}₹${t.amount} (${t.category})`, timestamp: 'Today' })); setRecentActivity(activities.slice(0, 5)); }, [scrims, transactions]); const logAction = (action: string) => console.log("Log:", action); // Placeholder for audit log write // Action Handlers const addEmployee = async (data: any) => await addDoc(collection(db, 'artifacts', appId, 'public', 'data', 'roster'), data); const updateEmployee = async (id: string, data: any) => await updateDoc(doc(db, 'artifacts', appId, 'public', 'data', 'roster', id), data); const deleteEmployee = async (id: string) => await deleteDoc(doc(db, 'artifacts', appId, 'public', 'data', 'roster', id)); const addTransaction = async (data: any) => await addDoc(collection(db, 'artifacts', appId, 'public', 'data', 'finance'), { ...data, date: serverTimestamp() }); const addDeal = async (data: any) => await addDoc(collection(db, 'artifacts', appId, 'public', 'data', 'deals'), data); const updateDeal = async (id: string, data: any) => await updateDoc(doc(db, 'artifacts', appId, 'public', 'data', 'deals', id), data); const addEvent = async (data: any) => await addDoc(collection(db, 'artifacts', appId, 'public', 'data', 'schedule'), data); const addScrim = async (data: any) => await addDoc(collection(db, 'artifacts', appId, 'public', 'data', 'scrims'), { ...data, date: serverTimestamp() }); const addAsset = async (data: any) => await addDoc(collection(db, 'artifacts', appId, 'public', 'data', 'inventory'), data); const updateAsset = async (id: string, data: any) => await updateDoc(doc(db, 'artifacts', appId, 'public', 'data', 'inventory', id), data); const addContent = async (data: any) => await addDoc(collection(db, 'artifacts', appId, 'public', 'data', 'content'), { ...data, stage: 'Ideation' }); const updateContentStage = async (id: string, stage: string) => await updateDoc(doc(db, 'artifacts', appId, 'public', 'data', 'content', id), { stage }); const addRole = async (data: any) => await addDoc(collection(db, 'artifacts', appId, 'public', 'data', 'roles'), data); const updateRole = async (id: string, data: any) => await updateDoc(doc(db, 'artifacts', appId, 'public', 'data', 'roles', id), data); // Seeder const seedData = async () => { // Seed roles if empty - EXACT MATCH TO REQ if (roles.length === 0) { await addRole({ name: 'Management (SuperAdmin)', desc: 'Full System Access', members: [] }); await addRole({ name: 'Manager', desc: 'Team & CC Management', members: [] }); await addRole({ name: 'Male Roster', desc: 'Esports Athletes', members: [] }); await addRole({ name: 'Female Roster', desc: 'Esports Athletes', members: [] }); await addRole({ name: 'Content Creators', desc: 'Streamers & Influencers', members: [] }); await addRole({ name: 'Editors', desc: 'Post-Production', members: [] }); } if (employees.length > 0) return; // Only seed other data if empty await addEmployee({ name: 'Jonathan Wick', role: 'Male Roster', salary: 50000, joined: '2023-01-15', status: 'Paid', method: 'UPI', utr: 'AXIS123', contract: 'Uploaded: contract.pdf' }); await addTransaction({ title: 'Bootcamp Internet', type: 'expense', amount: 4500, category: 'Ops' }); await addDeal({ title: 'Monster Energy Q4', client: 'Monster', value: 1200000, status: 'Sign Deal', assigneeType: 'ORG', commission: 100 }); await addEvent({ title: 'Team Sync', time: '10:00', description: 'Weekly roadmap', type: 'Meeting' }); await addScrim({ opponent: 'Global Esports', map: 'Ascent', result: 'Won', score: '13-9', stats: 'Top Frag: Jett', updatedBy: 'Coach' }); await addAsset({ name: 'Streaming PC 1', category: 'Hardware', location: 'Booth A', status: 'Active', assignedTo: 'Streamer' }); await addContent({ title: 'Vlog: Day 1', type: 'Vlog', priority: 'High', stage: 'Editing' }); alert("Database Seeded!"); }; if (!user) return
INITIALIZING SYSTEM...
; const OverviewView = () => (

Command Center

System Overview • All Systems Operational

t.type === 'expense').reduce((a,b) => a+b.amount, 0) + employees.reduce((a,e) => a+(Number(e.salary)||0),0)).toLocaleString()}`} subtitle="Payroll + Ops" icon={LucideActivity} colorClass="text-red-400" iconBgClass="bg-red-500/20" /> 0 ? Math.round((scrims.filter(s => s.result === 'Won').length / scrims.length) * 100) + '%' : '0%'} subtitle={`Last ${scrims.length} Matches`} icon={LucideTrophy} colorClass="text-yellow-400" iconBgClass="bg-yellow-500/20" />

Live Operations Feed

{recentActivity.map((act, i) => ( ))} {recentActivity.length === 0 &&

No recent activity recorded.

}

Upcoming Schedule

{schedule.slice(0, 3).map((ev: any) => (
{ev.time} {ev.title}
))} {schedule.length === 0 &&

No upcoming events.

}
); return (
{mobileMenuOpen &&
setMobileMenuOpen(false)} />}
DXE

DOTEXE

ONLINE

View As Role

{activeTab === 'crm' ? 'CRM & Deals' : activeTab.charAt(0).toUpperCase() + activeTab.slice(1)}

Management View
{activeTab === 'overview' && } {activeTab === 'payroll' && } {activeTab === 'access' && } {activeTab === 'rosters' && } {activeTab === 'finance' && } {activeTab === 'crm' && } {activeTab === 'schedule' && } {activeTab === 'scrims' && } {activeTab === 'inventory' && } {activeTab === 'content' && }
); }