import React, { useState, useEffect } from 'react'; import { BookOpen, Users, Lock, Key, LogOut, ExternalLink, ChevronRight, GraduationCap, Beaker, Globe, Calculator, BookText, Languages } from 'lucide-react'; const UnifiedPlatform = () => { const [currentPage, setCurrentPage] = useState('home'); const [isAuthenticated, setIsAuthenticated] = useState(false); const [userType, setUserType] = useState(null); const [schoolCode, setSchoolCode] = useState(''); const [adminPassword, setAdminPassword] = useState(''); const [loginError, setLoginError] = useState(''); const [schoolCodes, setSchoolCodes] = useState([]); const [newCodeName, setNewCodeName] = useState(''); const [generatedCode, setGeneratedCode] = useState(''); const ADMIN_PASSWORD = '@mikaelJ46'; // Platform links const platforms = [ { id: 'chemistry-biology', name: 'Chemistry & Biology', description: 'Deep understanding focus with AI-powered learning', icon: , url: 'https://huggingface.co/spaces/YOUR_USERNAME/chemistry-biology', color: 'bg-green-500', subjects: ['Chemistry', 'Biology'] }, { id: 'geography-history-business', name: 'Geography, History & Business', description: 'Comprehensive humanities and business studies', icon: , url: 'https://huggingface.co/spaces/YOUR_USERNAME/geography-history-business', color: 'bg-blue-500', subjects: ['Geography', 'History', 'Business'] }, { id: 'languages', name: 'French & EFL', description: 'Language learning with AI translation and dictionary', icon: , url: 'https://huggingface.co/spaces/YOUR_USERNAME/languages', color: 'bg-purple-500', subjects: ['French', 'EFL'] }, { id: 'math-physics', name: 'Mathematics & Physics', description: 'Step-by-step problem solving and practice', icon: , url: 'https://huggingface.co/spaces/YOUR_USERNAME/math-physics', color: 'bg-orange-500', subjects: ['Mathematics', 'Physics'] } ]; // Load school codes from storage useEffect(() => { const loadCodes = async () => { try { const result = await window.storage.list('school_code:'); if (result && result.keys) { const codes = []; for (const key of result.keys) { const data = await window.storage.get(key); if (data) { codes.push(JSON.parse(data.value)); } } setSchoolCodes(codes); } } catch (error) { console.log('No codes yet or error loading:', error); } }; loadCodes(); }, []); // Generate random school code const generateCode = () => { const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; let code = ''; for (let i = 0; i < 8; i++) { code += chars.charAt(Math.floor(Math.random() * chars.length)); } return code; }; // Admin: Create new school code const handleCreateCode = async () => { if (!newCodeName.trim()) { alert('Please enter a school/code name'); return; } const code = generateCode(); const codeData = { code: code, name: newCodeName, createdAt: new Date().toISOString(), active: true }; try { await window.storage.set(`school_code:${code}`, JSON.stringify(codeData)); setSchoolCodes([...schoolCodes, codeData]); setGeneratedCode(code); setNewCodeName(''); } catch (error) { alert('Error creating code: ' + error.message); } }; // Admin: Toggle code active status const toggleCodeStatus = async (code) => { try { const result = await window.storage.get(`school_code:${code}`); if (result) { const codeData = JSON.parse(result.value); codeData.active = !codeData.active; await window.storage.set(`school_code:${code}`, JSON.stringify(codeData)); setSchoolCodes(schoolCodes.map(c => c.code === code ? codeData : c)); } } catch (error) { alert('Error updating code: ' + error.message); } }; // Handle admin login const handleAdminLogin = () => { if (adminPassword === ADMIN_PASSWORD) { setIsAuthenticated(true); setUserType('admin'); setCurrentPage('admin-dashboard'); setLoginError(''); } else { setLoginError('Incorrect admin password'); } }; // Handle student login const handleStudentLogin = async () => { if (!schoolCode.trim()) { setLoginError('Please enter a school code'); return; } try { const result = await window.storage.get(`school_code:${schoolCode.toUpperCase()}`); if (result) { const codeData = JSON.parse(result.value); if (codeData.active) { setIsAuthenticated(true); setUserType('student'); setCurrentPage('student-dashboard'); setLoginError(''); } else { setLoginError('This school code has been deactivated'); } } else { setLoginError('Invalid school code'); } } catch (error) { setLoginError('Invalid school code'); } }; // Handle logout const handleLogout = () => { setIsAuthenticated(false); setUserType(null); setCurrentPage('home'); setSchoolCode(''); setAdminPassword(''); setLoginError(''); }; // Open platform in same tab const openPlatform = (url) => { window.location.href = url; }; // HOME PAGE if (currentPage === 'home') { return (
{/* Header */}

IGCSE/GCSE Master

AI-Powered Learning Platform

{/* Hero Section */}

Master Your IGCSE & GCSE Exams with AI

Comprehensive learning platform covering all major subjects with AI tutors, practice questions, past papers, and deep understanding focus.

Multi-AI System Active
8 Subjects Covered
IGCSE & GCSE
{/* Platforms Grid */}

Our Learning Platforms

{platforms.map((platform) => (
{platform.icon}

{platform.name}

{platform.description}

{platform.subjects.map((subject) => ( {subject} ))}
))}
{/* Features */}

Platform Features

AI Tutors

Get personalized help from AI tutors with deep understanding focus

Past Papers

Access and practice with real exam questions indexed by topic

Practice Questions

Generate unlimited practice questions with detailed feedback

{/* Footer */}

© 2024 IGCSE/GCSE Master. Powered by Gemini AI, Cohere, Z.ai & MiniMax

Multi-AI fallback system ensures 24/7 availability

); } // LOGIN CHOICE PAGE if (currentPage === 'login-choice') { return (

Welcome Back!

Choose how you'd like to login

); } // STUDENT LOGIN PAGE if (currentPage === 'student-login') { return (

Student Login

Enter your school code to access all platforms

{loginError && (
{loginError}
)}
setSchoolCode(e.target.value.toUpperCase())} onKeyPress={(e) => e.key === 'Enter' && handleStudentLogin()} placeholder="Enter 8-character code" className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-center text-xl font-mono tracking-wider" maxLength={8} />
); } // ADMIN LOGIN PAGE if (currentPage === 'admin-login') { return (

Admin Login

Enter admin password to manage school codes

{loginError && (
{loginError}
)}
setAdminPassword(e.target.value)} onKeyPress={(e) => e.key === 'Enter' && handleAdminLogin()} placeholder="Enter password" className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent" />
); } // STUDENT DASHBOARD if (currentPage === 'student-dashboard' && isAuthenticated && userType === 'student') { return (

Student Dashboard

Code: {schoolCode}

Choose Your Subject Platform

{platforms.map((platform) => (
{platform.icon}

{platform.name}

{platform.description}

{platform.subjects.map((subject) => ( {subject} ))}
))}

📚 Platform Features Available:

  • AI Tutors with deep understanding focus
  • Past papers indexed by topic
  • Unlimited practice questions
  • Detailed feedback and marking
  • Multi-AI fallback system
  • 24/7 availability
); } // ADMIN DASHBOARD if (currentPage === 'admin-dashboard' && isAuthenticated && userType === 'admin') { return (

Admin Panel

Manage school access codes

{/* Create New Code */}

Generate New School Code

setNewCodeName(e.target.value)} placeholder="Enter school or code name" className="flex-1 px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500" />
{generatedCode && (

✅ New code generated successfully!

{generatedCode}
)}
{/* Active Codes List */}

All School Codes ({schoolCodes.length})

{schoolCodes.length === 0 ? (

No school codes generated yet

) : (
{schoolCodes.map((codeData) => (
{codeData.code}

{codeData.name}

Created: {new Date(codeData.createdAt).toLocaleString()}