import React, { useState, useEffect, useCallback } from 'react'; import { ArrowRight, Brain, Calculator, PresentationChart, TrendingUp, User, LogOut, Settings, Users, DollarSign, BarChart, Lock, CheckCircle, X, Moon, Sun, Globe, ChevronDown, HelpCircle, Bell, FileText, CreditCard, Activity, Menu, Home } from 'lucide-react'; // Main App Component const App = () => { // State management const [currentModule, setCurrentModule] = useState('home'); const [isLoggedIn, setIsLoggedIn] = useState(false); const [isAdmin, setIsAdmin] = useState(false); const [user, setUser] = useState(null); const [showLoginModal, setShowLoginModal] = useState(false); const [showRegisterModal, setShowRegisterModal] = useState(false); const [showSubscribeModal, setShowSubscribeModal] = useState(false); const [showProfileModal, setShowProfileModal] = useState(false); const [showMobileMenu, setShowMobileMenu] = useState(false); const [remainingQueries, setRemainingQueries] = useState(20); const [loginEmail, setLoginEmail] = useState(''); const [loginPassword, setLoginPassword] = useState(''); const [registerEmail, setRegisterEmail] = useState(''); const [registerPassword, setRegisterPassword] = useState(''); const [registerConfirmPassword, setRegisterConfirmPassword] = useState(''); const [darkMode, setDarkMode] = useState(true); const [currentLanguage, setCurrentLanguage] = useState('en'); const [showLanguageDropdown, setShowLanguageDropdown] = useState(false); const [showUserDropdown, setShowUserDropdown] = useState(false); const [showTutorial, setShowTutorial] = useState(false); const [tutorialStep, setTutorialStep] = useState(1); const [error, setError] = useState(null); // Math AI state const [mathQuery, setMathQuery] = useState(''); const [mathResult, setMathResult] = useState(null); const [mathLoading, setMathLoading] = useState(false); const [mathHistory, setMathHistory] = useState([]); // Presentation AI state const [presentationTopic, setPresentationTopic] = useState(''); const [presentationResult, setPresentationResult] = useState(null); const [presentationLoading, setPresentationLoading] = useState(false); const [presentationHistory, setPresentationHistory] = useState([]); const [presentationStyle, setPresentationStyle] = useState('professional'); const [presentationLength, setPresentationLength] = useState('medium'); // Crypto/Stock AI state const [cryptoSymbol, setCryptoSymbol] = useState(''); const [cryptoResult, setCryptoResult] = useState(null); const [cryptoLoading, setCryptoLoading] = useState(false); const [cryptoHistory, setCryptoHistory] = useState([]); const [timeframe, setTimeframe] = useState('1month'); const [analysisType, setAnalysisType] = useState('technical'); // Admin state const [adminTab, setAdminTab] = useState('users'); const [subscriptionPrice, setSubscriptionPrice] = useState(6.99); const [users, setUsers] = useState([ { id: 1, email: 'user1@example.com', subscribed: true, queriesUsed: 'Unlimited', dateJoined: '2023-01-15' }, { id: 2, email: 'user2@example.com', subscribed: false, queriesUsed: 12, dateJoined: '2023-02-20' }, { id: 3, email: 'l.brandmaehl@web.de', subscribed: true, queriesUsed: 'Unlimited', dateJoined: '2022-12-01', isAdmin: true } ]); const [moduleSettings, setModuleSettings] = useState({ math: true, presentation: true, crypto: true }); const [systemStats, setSystemStats] = useState({ totalUsers: 156, activeSubscriptions: 78, queriesThisMonth: 2345, revenue: 545.22 }); // Language options const languages = [ { code: 'en', name: 'English' }, { code: 'de', name: 'Deutsch' }, { code: 'fr', name: 'Français' }, { code: 'es', name: 'Español' } ]; // Translations (simplified for demo) const translations = { en: { home: 'Home', mathAI: 'Mathematics AI', presentationAI: 'Presentation AI', cryptoAI: 'Crypto/Stock AI', admin: 'Admin', login: 'Log in', register: 'Register', logout: 'Sign out', subscribe: 'Subscribe Now', queriesLeft: 'queries left', welcomeTitle: 'Welcome to Lomney AI', welcomeSubtitle: 'Harness the power of artificial intelligence with our three specialized modules' }, de: { home: 'Startseite', mathAI: 'Mathematik-KI', presentationAI: 'Präsentations-KI', cryptoAI: 'Krypto/Aktien-KI', admin: 'Admin', login: 'Anmelden', register: 'Registrieren', logout: 'Abmelden', subscribe: 'Jetzt abonnieren', queriesLeft: 'Anfragen übrig', welcomeTitle: 'Willkommen bei Lomney AI', welcomeSubtitle: 'Nutzen Sie die Kraft künstlicher Intelligenz mit unseren drei spezialisierten Modulen' }, fr: { home: 'Accueil', mathAI: 'IA Mathématique', presentationAI: 'IA Présentation', cryptoAI: 'IA Crypto/Actions', admin: 'Admin', login: 'Connexion', register: 'S\'inscrire', logout: 'Déconnexion', subscribe: 'S\'abonner', queriesLeft: 'requêtes restantes', welcomeTitle: 'Bienvenue sur Lomney AI', welcomeSubtitle: 'Exploitez la puissance de l\'intelligence artificielle avec nos trois modules spécialisés' }, es: { home: 'Inicio', mathAI: 'IA Matemática', presentationAI: 'IA Presentación', cryptoAI: 'IA Cripto/Acciones', admin: 'Admin', login: 'Iniciar sesión', register: 'Registrarse', logout: 'Cerrar sesión', subscribe: 'Suscribirse', queriesLeft: 'consultas restantes', welcomeTitle: 'Bienvenido a Lomney AI', welcomeSubtitle: 'Aprovecha el poder de la inteligencia artificial con nuestros tres módulos especializados' } }; // Get translation const t = (key) => { return translations[currentLanguage][key] || translations['en'][key] || key; }; // Check if user is admin useEffect(() => { if (isLoggedIn && user && user.email === 'l.brandmaehl@web.de') { setIsAdmin(true); } else { setIsAdmin(false); } }, [isLoggedIn, user]); // Close dropdowns when clicking outside useEffect(() => { const handleClickOutside = (event) => { if (showLanguageDropdown || showUserDropdown) { setShowLanguageDropdown(false); setShowUserDropdown(false); } }; document.addEventListener('mousedown', handleClickOutside); return () => { document.removeEventListener('mousedown', handleClickOutside); }; }, [showLanguageDropdown, showUserDropdown]); // Handle theme change useEffect(() => { document.body.classList.toggle('light-mode', !darkMode); }, [darkMode]); // Mock login function const handleLogin = (e) => { e.preventDefault(); try { // In a real app, this would validate against a backend const foundUser = users.find(u => u.email === loginEmail); if (foundUser) { setUser({ email: loginEmail, subscribed: foundUser.subscribed, isAdmin: foundUser.isAdmin || false }); setIsLoggedIn(true); setShowLoginModal(false); setLoginEmail(''); setLoginPassword(''); setRemainingQueries(20); // Show tutorial for new users if (!localStorage.getItem('tutorialShown')) { setShowTutorial(true); localStorage.setItem('tutorialShown', 'true'); } } else { // Simulate user creation for demo setUser({ email: loginEmail, subscribed: false }); setIsLoggedIn(true); setShowLoginModal(false); setLoginEmail(''); setLoginPassword(''); setRemainingQueries(20); } } catch (error) { setError("Login failed. Please try again."); setTimeout(() => setError(null), 3000); } }; // Mock register function const handleRegister = (e) => { e.preventDefault(); try { if (registerPassword !== registerConfirmPassword) { setError("Passwords do not match"); setTimeout(() => setError(null), 3000); return; } // In a real app, this would create a user in the backend setUser({ email: registerEmail, subscribed: false }); setIsLoggedIn(true); setShowRegisterModal(false); setRegisterEmail(''); setRegisterPassword(''); setRegisterConfirmPassword(''); setRemainingQueries(20); // Show tutorial for new users setShowTutorial(true); } catch (error) { setError("Registration failed. Please try again."); setTimeout(() => setError(null), 3000); } }; // Mock logout function const handleLogout = () => { setIsLoggedIn(false); setUser(null); setIsAdmin(false); setCurrentModule('home'); setShowUserDropdown(false); }; // Mock subscribe function const handleSubscribe = () => { try { // In a real app, this would integrate with Stripe setUser({ ...user, subscribed: true }); setShowSubscribeModal(false); // Show success message setError({ type: 'success', message: "Successfully subscribed to Premium!" }); setTimeout(() => setError(null), 3000); } catch (error) { setError("Subscription failed. Please try again."); setTimeout(() => setError(null), 3000); } }; // Check if user can use AI const canUseAI = useCallback(() => { if (!isLoggedIn) { setShowLoginModal(true); return false; } if (remainingQueries <= 0 && !user.subscribed) { setShowSubscribeModal(true); return false; } return true; }, [isLoggedIn, remainingQueries, user]); // Decrement remaining queries const useQuery = useCallback(() => { if (user && !user.subscribed) { setRemainingQueries(prev => prev - 1); } }, [user]); // Math AI handler const handleMathQuery = async (e) => { e.preventDefault(); if (!canUseAI() || !moduleSettings.math) return; setMathLoading(true); try { // Simulate API call setTimeout(() => { // Example result for a quadratic equation if (mathQuery.includes('x^2')) { const result = { original: mathQuery, result: 'x = 2 or x = -3', steps: [ 'Step 1: Identify the quadratic equation in standard form: ax² + bx + c = 0', 'Step 2: Use the quadratic formula: x = (-b ± √(b² - 4ac)) / 2a', 'Step 3: Substitute the values and calculate', 'Step 4: Simplify to get the roots: x = 2 or x = -3' ] }; setMathResult(result); setMathHistory(prev => [result, ...prev].slice(0, 5)); } else if (mathQuery.includes('+') || mathQuery.includes('-') || mathQuery.includes('*') || mathQuery.includes('/')) { // Basic arithmetic try { // NEVER use eval in production - this is just for demo const calculatedResult = eval(mathQuery.replace('^', '**')); const result = { original: mathQuery, result: calculatedResult.toString(), steps: [ 'Step 1: Parse the expression', `Step 2: Calculate the result: ${calculatedResult}` ] }; setMathResult(result); setMathHistory(prev => [result, ...prev].slice(0, 5)); } catch (error) { const result = { original: mathQuery, result: 'Error in calculation', steps: ['Invalid expression. Please check your input.'] }; setMathResult(result); } } else { const result = { original: mathQuery, result: 'Please provide a mathematical expression or equation.', steps: ['Try something like "2 + 2" or "x^2 - 5x + 6 = 0"'] }; setMathResult(result); } setMathLoading(false); useQuery(); }, 1500); } catch (error) { setMathLoading(false); setError("An error occurred. Please try again."); setTimeout(() => setError(null), 3000); } }; // Presentation AI handler const handlePresentationQuery = async (e) => { e.preventDefault(); if (!canUseAI() || !moduleSettings.presentation) return; setPresentationLoading(true); try { // Simulate API call setTimeout(() => { const result = { topic: presentationTopic, style: presentationStyle, length: presentationLength, slides: [ { title: presentationTopic, content: 'Introduction to the topic', imageUrl: 'https://source.unsplash.com/random/800x600/?presentation' }, { title: 'Key Points', content: '• First important point\n• Second important point\n• Third important point', imageUrl: 'https://source.unsplash.com/random/800x600/?chart' }, { title: 'Data Analysis', content: 'Examination of relevant statistics and trends', imageUrl: 'https://source.unsplash.com/random/800x600/?data' }, { title: 'Conclusion', content: 'Summary of findings and next steps', imageUrl: 'https://source.unsplash.com/random/800x600/?success' } ], exportFormats: ['PowerPoint', 'Canva', 'OpenOffice'] }; // Add more slides for longer presentations if (presentationLength === 'long') { result.slides.splice(3, 0, { title: 'Detailed Analysis', content: 'In-depth examination of the subject matter', imageUrl: 'https://source.unsplash.com/random/800x600/?analysis' }, { title: 'Case Studies', content: 'Real-world examples and applications', imageUrl: 'https://source.unsplash.com/random/800x600/?case-study' } ); } setPresentationResult(result); setPresentationHistory(prev => [result, ...prev].slice(0, 5)); setPresentationLoading(false); useQuery(); }, 2000); } catch (error) { setPresentationLoading(false); setError("An error occurred. Please try again."); setTimeout(() => setError(null), 3000); } }; // Crypto/Stock AI handler const handleCryptoQuery = async (e) => { e.preventDefault(); if (!canUseAI() || !moduleSettings.crypto) return; setCryptoLoading(true); try { // Simulate API call setTimeout(() => { const randomTrend = Math.random() > 0.5; const randomPercentage = (Math.random() * 15).toFixed(2); const result = { symbol: cryptoSymbol.toUpperCase(), currentPrice: '$' + (Math.random() * 10000).toFixed(2), prediction: randomTrend ? 'Upward Trend' : 'Downward Trend', confidencePercentage: randomPercentage + '%', riskLevel: randomPercentage > 10 ? 'High' : randomPercentage > 5 ? 'Medium' : 'Low', timeframe: timeframe, analysisType: analysisType, chartData: generateChartData(timeframe, randomTrend), analysis: `Based on ${analysisType === 'technical' ? 'technical indicators' : 'fundamental factors'} and ${timeframe} market trends, ${cryptoSymbol.toUpperCase()} is showing a ${randomTrend ? 'positive' : 'negative'} momentum. The confidence level for this prediction is ${randomPercentage}%, indicating a ${randomPercentage > 10 ? 'high' : randomPercentage > 5 ? 'medium' : 'low'} risk investment.` }; setCryptoResult(result); setCryptoHistory(prev => [result, ...prev].slice(0, 5)); setCryptoLoading(false); useQuery(); }, 1800); } catch (error) { setCryptoLoading(false); setError("An error occurred. Please try again."); setTimeout(() => setError(null), 3000); } }; // Generate chart data based on timeframe const generateChartData = (timeframe, uptrend) => { let dataPoints = []; let pointCount = 0; switch(timeframe) { case '1week': pointCount = 7; break; case '1month': pointCount = 30; break; case '3months': pointCount = 90; break; case '1year': pointCount = 365; break; default: pointCount = 30; } // Generate random data with a trend let lastValue = 50 + Math.random() * 20; for (let i = 0; i < pointCount; i++) { // Add some randomness but maintain the trend const change = (Math.random() - (uptrend ? 0.4 : 0.6)) * 5; lastValue = Math.max(10, Math.min(90, lastValue + change)); dataPoints.push(lastValue); } return dataPoints; }; // Handle tutorial navigation const handleTutorialNext = () => { if (tutorialStep < 4) { setTutorialStep(tutorialStep + 1); } else { setShowTutorial(false); setTutorialStep(1); } }; // Handle tutorial skip const handleTutorialSkip = () => { setShowTutorial(false); setTutorialStep(1); }; // Render different modules based on current selection const renderModule = () => { switch (currentModule) { case 'math': return (
Enter any mathematical problem, and our AI will solve it with step-by-step explanations.
{mathResult && (Problem:
{mathResult.original}
Result:
{mathResult.result}
Step-by-step solution:
{item.original}
{item.result}
Enter a topic, and our AI will create a complete presentation with text, images, and animations.
{presentationResult && ({slide.content}
{item.topic}
{item.slides.length} slides • {item.style} style
Enter a cryptocurrency or stock symbol, and our AI will analyze trends and provide predictions.
{cryptoResult && ({cryptoResult.currentPrice}
{cryptoResult.analysis}
Analysis type: {cryptoResult.analysisType === 'technical' ? 'Technical Analysis' : 'Fundamental Analysis'}
{item.symbol}
{item.timeframe === '1week' ? 'Past week' : item.timeframe === '1month' ? 'Past month' : item.timeframe === '3months' ? 'Past 3 months' : 'Past year'} • {item.analysisType === 'technical' ? 'Technical' : 'Fundamental'}
| Status | Queries Used | Date Joined | Actions | |
|---|---|---|---|---|
| {user.email} | {user.isAdmin ? ( Admin ) : user.subscribed ? ( Subscribed ) : ( Free Tier )} | {user.queriesUsed} | {user.dateJoined} | {user.isAdmin ? ( ) : user.subscribed ? ( ) : ( )} |
| Code | Discount | Status | Actions |
|---|---|---|---|
| WELCOME10 | 10% | Active | |
| SUMMER2023 | 25% | Inactive |
Solve mathematical problems with step-by-step explanations
Generate complete presentations with text, images, and animations
Analyze and predict trends for cryptocurrencies and stocks
{systemStats.totalUsers}
+12% from last month
{systemStats.activeSubscriptions}
+8% from last month
{systemStats.queriesThisMonth}
+15% from last month
€{systemStats.revenue}
+10% from last month
Math AI
42%
Presentation AI
27%
Crypto AI
31%
{new Date(2023, index).toLocaleString('default', { month: 'short' })}
{t('welcomeSubtitle')}
Solve complex mathematical problems with step-by-step explanations
Generate complete presentations with text, images, and animations
Analyze and predict trends for cryptocurrencies and stocks
Get unlimited access to all our AI modules with a premium subscription.
Try before you subscribe
Free queries per month
{!isLoggedIn && ( )}Select from our three specialized AI modules based on your needs.
Enter your math problem, presentation topic, or crypto/stock symbol.
Receive detailed, accurate results powered by advanced AI technology.
John Doe
Student
"The Mathematics AI has been a game-changer for my studies. It not only gives me the answers but explains the steps so I can learn."
Alice Smith
Marketing Manager
"I create professional presentations in minutes with the Presentation AI. It saves me hours of work and the results are always impressive."
Robert Johnson
Investor
"The Crypto/Stock AI gives me insights I wouldn't have found on my own. It's become an essential tool for my investment decisions."