import React, { useState, useEffect } from 'react'; import { Database, FileText, Settings, Users, Network, Clock, CheckCircle2, AlertCircle, Save, Info, Layers, CheckSquare } from 'lucide-react'; import Card from '../../components/ui/Card'; import Tag from '../../components/ui/Tag'; import Button from '../../components/ui/Button'; import Input from '../../components/ui/Input'; import { storage } from '../../lib/storage'; import * as db from '../../lib/db'; import UploadZone from '../../components/admin/UploadZone'; import KnowledgeGraph from '../../components/admin/KnowledgeGraph'; import ContentManager from '../../components/admin/ContentManager'; import TestManager from '../../components/admin/TestManager'; import TeamManager from '../../components/admin/TeamManager'; import { Trash2 } from 'lucide-react'; const Admin = () => { const [activeTab, setActiveTab] = useState('sources'); const [sources, setSources] = useState([]); const [model, setModel] = useState(''); const [useSimulation, setUseSimulation] = useState(false); const [saveStatus, setSaveStatus] = useState(null); const loadSources = async () => { const data = await db.getSources(); setSources(data); }; useEffect(() => { if (activeTab === 'sources') { loadSources(); } if (activeTab === 'settings') { setModel(storage.get('admin:model', 'claude-sonnet-4-20250514')); setUseSimulation(storage.get('admin:use_simulation', false)); } }, [activeTab]); const saveSettings = async (e) => { e.preventDefault(); storage.set('admin:model', model.trim()); storage.set('admin:use_simulation', useSimulation); setSaveStatus('Saved!'); setTimeout(() => setSaveStatus(null), 3000); }; const handleDeleteSource = async (id) => { if (confirm('Are you sure you want to delete this source? This will not delete topics already extracted.')) { await db.deleteSource(id); await loadSources(); } }; const navItems = [ { key: 'sources', icon: Database, label: 'Sources' }, { key: 'content', icon: Layers, label: 'Content' }, { key: 'tests', icon: CheckSquare, label: 'Quizzes' }, { key: 'graph', icon: Network, label: 'Graph' }, { key: 'team', icon: Users, label: 'Team' }, { key: 'settings', icon: Settings, label: 'Settings', bottom: true }, ]; return (

Knowledge Mgmt

{navItems.map(({ key, icon: Icon, label, bottom }) => ( ))}
{activeTab === 'sources' && (

Source Material

Upload files to feed the AI knowledge extraction pipeline.

Recent Sources

{sources.length === 0 ? (
No sources uploaded yet.
) : ( sources.map((source) => (

{source.name}

{source.created ? new Date(source.created).toLocaleString() : '—'}

{source.status === 'completed' && Completed} {source.status === 'processing' && Processing} {source.status === 'failed' && Failed}
)) )}
)} {activeTab === 'content' && (

Learning Content

Manage, refine, or regenerate AI-generated learning modules for each knowledge topic.

)} {activeTab === 'tests' && (

Question Banks

Pre-generate and review quiz questions for each topic to eliminate loading times for users.

)} {activeTab === 'graph' && (

Knowledge Graph

Visual map of all extracted Respellion knowledge.

)} {activeTab === 'team' && (

Team Management

Manage team members, roles, and login PINs.

)} {activeTab === 'settings' && (

Settings

Manage API keys and application configuration.

AI Configuration

setModel(e.target.value)} />

Leave blank for the default. Check your Anthropic Console for available models.

Note: Your Anthropic API key is securely managed on the server side via environment variables.

Simulation Mode

Use simulated AI responses when the API is unavailable.

{useSimulation && (

When enabled, the platform will simulate AI processing without making real API calls. Ideal for UI testing.

)}
{saveStatus && {saveStatus}}
)}
); }; export default Admin;