import React, { useState, useEffect } from 'react';
import {
Users, School, BookOpen, FileSpreadsheet, Settings,
LogOut, Home, User, Bell, ChevronDown, Edit, Trash,
Eye, Download, Upload, CheckCircle, XCircle, AlertCircle,
PlusCircle, Search, Filter, BarChart, FileText, Send,
Play
} from 'lucide-react';
// Main App Component
export default function App() {
const [currentUser, setCurrentUser] = useState(null);
const [activeView, setActiveView] = useState('login');
const [isPreviewMode, setIsPreviewMode] = useState(false);
// Handle login
const handleLogin = (user, preview = false) => {
setCurrentUser(user);
setActiveView('dashboard');
setIsPreviewMode(preview);
};
// Handle logout
const handleLogout = () => {
setCurrentUser(null);
setActiveView('login');
setIsPreviewMode(false);
};
return (
{!currentUser ? (
) : (
)}
);
}
// Login Screen Component
function LoginScreen({ onLogin }) {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const [userType, setUserType] = useState('superadmin');
const [error, setError] = useState('');
const [isLoading, setIsLoading] = useState(false);
const handleSubmit = (e) => {
e.preventDefault();
setError('');
setIsLoading(true);
// Simple validation
if (!username || !password) {
setError('Please enter both username and password');
setIsLoading(false);
return;
}
// Check for the specific super admin account
if (username === "kisscossk@gmail.com" && password === "@Kreegy") {
setTimeout(() => {
const user = {
id: 1,
name: 'Super Admin',
role: 'superadmin',
email: 'kisscossk@gmail.com'
};
onLogin(user, false);
setIsLoading(false);
}, 1000);
return;
}
// Mock login logic for other accounts
setTimeout(() => {
let user;
if (userType === 'superadmin' && username === 'admin' && password === 'admin') {
user = { id: 1, name: 'Super Admin', role: 'superadmin' };
} else if (userType === 'schooladmin' && username === 'school' && password === 'admin') {
user = { id: 2, name: 'School Admin', role: 'schooladmin', schoolId: 1, schoolName: 'Cambridge International School' };
} else if (userType === 'teacher' && username === 'teacher' && password === 'teacher') {
user = { id: 3, name: 'John Smith', role: 'teacher', schoolId: 1, schoolName: 'Cambridge International School', subjects: ['Mathematics', 'Physics'] };
} else if (userType === 'student' && username === 'S1001' && password === 'student') {
user = { id: 4, name: 'Alice Johnson', role: 'student', admissionNumber: 'S1001', class: '10A', schoolId: 1, schoolName: 'Cambridge International School' };
} else {
setError('Invalid credentials. Try admin/admin for Super Admin, school/admin for School Admin, teacher/teacher for Teacher, or S1001/student for Student.');
setIsLoading(false);
return;
}
onLogin(user, false);
setIsLoading(false);
}, 1000);
};
const handleLivePreview = (role) => {
setIsLoading(true);
setTimeout(() => {
let user;
switch(role) {
case 'superadmin':
user = { id: 1, name: 'Super Admin', role: 'superadmin' };
break;
case 'schooladmin':
user = { id: 2, name: 'School Admin', role: 'schooladmin', schoolId: 1, schoolName: 'Cambridge International School' };
break;
case 'teacher':
user = { id: 3, name: 'John Smith', role: 'teacher', schoolId: 1, schoolName: 'Cambridge International School', subjects: ['Mathematics', 'Physics'] };
break;
case 'student':
user = { id: 4, name: 'Alice Johnson', role: 'student', admissionNumber: 'S1001', class: '10A', schoolId: 1, schoolName: 'Cambridge International School' };
break;
default:
user = { id: 1, name: 'Super Admin', role: 'superadmin' };
}
onLogin(user, true);
setIsLoading(false);
}, 1000);
};
return (
KIA
Schools Portal
Sign in to your account
{error && (
{error}
)}
Or try a live preview
handleLivePreview('superadmin')}
className="px-3 py-2 text-xs text-indigo-600 bg-indigo-50 rounded-md hover:bg-indigo-100 flex items-center justify-center"
disabled={isLoading}
>
Super Admin
handleLivePreview('schooladmin')}
className="px-3 py-2 text-xs text-green-600 bg-green-50 rounded-md hover:bg-green-100 flex items-center justify-center"
disabled={isLoading}
>
School Admin
handleLivePreview('teacher')}
className="px-3 py-2 text-xs text-blue-600 bg-blue-50 rounded-md hover:bg-blue-100 flex items-center justify-center"
disabled={isLoading}
>
Teacher
handleLivePreview('student')}
className="px-3 py-2 text-xs text-purple-600 bg-purple-50 rounded-md hover:bg-purple-100 flex items-center justify-center"
disabled={isLoading}
>
Student
);
}
// Dashboard Layout Component
function DashboardLayout({ user, activeView, setActiveView, onLogout, isPreviewMode }) {
const [isSidebarOpen, setIsSidebarOpen] = useState(true);
// Define navigation items based on user role
const getNavItems = () => {
switch (user.role) {
case 'superadmin':
return [
{ id: 'dashboard', label: 'Dashboard', icon: },
{ id: 'schools', label: 'Schools', icon: },
{ id: 'templates', label: 'Report Templates', icon: },
{ id: 'exams', label: 'Exams', icon: },
{ id: 'classes', label: 'Classes & Subjects', icon: },
{ id: 'settings', label: 'System Settings', icon: }
];
case 'schooladmin':
return [
{ id: 'dashboard', label: 'Dashboard', icon: },
{ id: 'teachers', label: 'Teachers', icon: },
{ id: 'students', label: 'Students', icon: },
{ id: 'classes', label: 'Classes & Subjects', icon: },
{ id: 'reports', label: 'Report Cards', icon: },
{ id: 'settings', label: 'School Settings', icon: }
];
case 'teacher':
return [
{ id: 'dashboard', label: 'Dashboard', icon: },
{ id: 'scores', label: 'Enter Scores', icon: },
{ id: 'marksheets', label: 'Marksheets', icon: },
{ id: 'queries', label: 'Student Queries', icon: }
];
case 'student':
return [
{ id: 'dashboard', label: 'Dashboard', icon: },
{ id: 'reportcards', label: 'Report Cards', icon: },
{ id: 'marksheets', label: 'Marksheets', icon: },
{ id: 'queries', label: 'Queries', icon: }
];
default:
return [];
}
};
const navItems = getNavItems();
return (
{/* Sidebar */}
KIA Portal
setIsSidebarOpen(!isSidebarOpen)}
className="p-1 rounded-md hover:bg-indigo-700"
>
{navItems.map((item) => (
setActiveView(item.id)}
className={`flex items-center w-full px-4 py-3 mb-1 rounded-md transition-colors ${
activeView === item.id
? 'bg-indigo-700 text-white'
: 'text-indigo-100 hover:bg-indigo-700'
}`}
>
{item.icon}
{isSidebarOpen && {item.label} }
))}
{isSidebarOpen && Logout }
{/* Main Content */}
{/* Header */}
{navItems.find(item => item.id === activeView)?.label || 'Dashboard'}
{isPreviewMode && (
Preview Mode
)}
{/* Content Area */}
{renderContent(activeView, user)}
);
}
// Function to render content based on active view and user role
function renderContent(activeView, user) {
// Super Admin Views
if (user.role === 'superadmin') {
switch (activeView) {
case 'dashboard':
return ;
case 'schools':
return ;
case 'templates':
return ;
case 'exams':
return ;
case 'classes':
return ;
case 'settings':
return ;
default:
return ;
}
}
// School Admin Views
if (user.role === 'schooladmin') {
switch (activeView) {
case 'dashboard':
return ;
case 'teachers':
return ;
case 'students':
return ;
case 'classes':
return ;
case 'reports':
return ;
case 'settings':
return ;
default:
return ;
}
}
// Teacher Views
if (user.role === 'teacher') {
switch (activeView) {
case 'dashboard':
return ;
case 'scores':
return ;
case 'marksheets':
return ;
case 'queries':
return ;
default:
return ;
}
}
// Student Views
if (user.role === 'student') {
switch (activeView) {
case 'dashboard':
return ;
case 'reportcards':
return ;
case 'marksheets':
return ;
case 'queries':
return ;
default:
return ;
}
}
return Content not found
;
}
// Super Admin Components
function SuperAdminDashboard({ user }) {
const stats = [
{ label: 'Total Schools', value: 24, icon: },
{ label: 'Active Schools', value: 22, icon: },
{ label: 'Suspended Schools', value: 2, icon: },
{ label: 'Total Students', value: 12450, icon: },
];
return (
Welcome, {user.email ? user.email : 'Super Admin'}
Manage all schools, templates, and system settings from your dashboard.
{stats.map((stat, index) => (
{stat.label}
{stat.value.toLocaleString()}
{stat.icon}
))}
Recent Schools
School Name
Status
Students
Actions
{[
{ name: 'Cambridge International School', status: 'Active', students: 850 },
{ name: 'St. Mary\'s Academy', status: 'Active', students: 720 },
{ name: 'Westfield High School', status: 'Active', students: 930 },
{ name: 'Lincoln Elementary', status: 'Suspended', students: 450 },
].map((school, index) => (
{school.name}
{school.status}
{school.students}
))}
System Activity
{[
{ action: 'New school registered', time: '2 hours ago', user: 'System' },
{ action: 'Report template updated', time: '5 hours ago', user: 'Admin' },
{ action: 'Exam schedule published', time: '1 day ago', user: 'Admin' },
{ action: 'System maintenance completed', time: '2 days ago', user: 'System' },
{ action: 'New grading system added', time: '3 days ago', user: 'Admin' },
].map((activity, index) => (
{activity.action}
{activity.time} by {activity.user}
))}
);
}
// Placeholder components for other views
function SchoolsManagement() {
return Schools Management Content
;
}
function ReportTemplates() {
return Report Templates Content
;
}
function ExamsManagement() {
return Exams Management Content
;
}
function ClassesSubjectsManagement() {
return Classes & Subjects Management Content
;
}
function SystemSettings({ user }) {
return (
System Settings
Save Changes
);
}
// School Admin Components
function SchoolAdminDashboard({ user }) {
return School Admin Dashboard Content
;
}
function TeachersManagement() {
return Teachers Management Content
;
}
function StudentsManagement() {
return Students Management Content
;
}
function SchoolClassesManagement() {
return School Classes Management Content
;
}
function ReportCardsManagement() {
return Report Cards Management Content
;
}
function SchoolSettings({ user }) {
return School Settings Content
;
}
// Teacher Components
function TeacherDashboard({ user }) {
return Teacher Dashboard Content
;
}
function EnterScores({ user }) {
return Enter Scores Content
;
}
function TeacherMarksheets({ user }) {
return Teacher Marksheets Content
;
}
function StudentQueries({ user }) {
return Student Queries Content
;
}
// Student Components
function StudentDashboard({ user }) {
return Student Dashboard Content
;
}
function StudentReportCards({ user }) {
return Student Report Cards Content
;
}
function StudentMarksheets({ user }) {
const marksheets = [
{ id: 1, subject: 'Mathematics', term: 'Term 1', year: '2023-2024', date: 'Jan 15, 2024' },
{ id: 2, subject: 'Physics', term: 'Term 1', year: '2023-2024', date: 'Jan 12, 2024' },
{ id: 3, subject: 'Chemistry', term: 'Term 1', year: '2023-2024', date: 'Jan 10, 2024' },
{ id: 4, subject: 'Biology', term: 'Term 1', year: '2023-2024', date: 'Jan 8, 2024' },
{ id: 5, subject: 'English Language', term: 'Term 1', year: '2023-2024', date: 'Jan 5, 2024' },
];
const [selectedMarksheet, setSelectedMarksheet] = useState(null);
return (
My Marksheets
Subject
Term
Academic Year
Date
Actions
{marksheets.map((marksheet) => (
{marksheet.subject}
{marksheet.term}
{marksheet.year}
{marksheet.date}
setSelectedMarksheet(marksheet)}
>
))}
{/* Marksheet Preview Modal */}
{selectedMarksheet && (
{selectedMarksheet.subject} Marksheet: {selectedMarksheet.term} ({selectedMarksheet.year})
setSelectedMarksheet(null)}
className="text-gray-500 hover:text-gray-700"
>
Student: {user.name}
Admission No: {user.admissionNumber}
Class: {user.class}
Subject: {selectedMarksheet.subject}
Term: {selectedMarksheet.term}
Academic Year: {selectedMarksheet.year}
Topic
Exam Type
Score
Max Score
Percentage
Grade
{selectedMarksheet.subject === 'Mathematics' ? (
<>
Algebra
Quiz
18
20
90%
A
Geometry
Quiz
16
20
80%
A
Calculus
Mid-Term Exam
42
50
84%
A
All Topics
End-Term Exam
85
100
85%
A
>
) : (
<>
Topic 1
Quiz
17
20
85%
A
Topic 2
Quiz
15
20
75%
B
Topic 3
Mid-Term Exam
38
50
76%
B
All Topics
End-Term Exam
78
100
78%
B
>
)}
Summary
Total Score:
161/190
Average Percentage:
84.7%
Overall Grade:
A
Class Average:
76.2%
Position in Class:
3 out of 32
Teacher:
Mr. John Smith
setSelectedMarksheet(null)}
className="px-4 py-2 border border-gray-300 rounded-md text-sm text-gray-700 hover:bg-gray-50"
>
Close
Download PDF
)}
);
}