diff --git a/src/pages/Admin/AdminDashboard.tsx b/src/pages/Admin/AdminDashboard.tsx index 43a7016..7f9fa54 100644 --- a/src/pages/Admin/AdminDashboard.tsx +++ b/src/pages/Admin/AdminDashboard.tsx @@ -89,7 +89,51 @@ export default function AdminDashboard() { const [loadingLogin, setLoadingLogin] = useState(false); // Active Tab - const [activeTab, setActiveTab] = useState<'transport' | 'telegram' | 'notes' | 'community' | 'subscribers'>('transport'); + const [activeTab, setActiveTab] = useState<'transport' | 'telegram' | 'notes' | 'community' | 'subscribers' | 'faculty' | 'clubs' | 'curriculum'>('transport'); + + // Faculty State + const [facultyList, setFacultyList] = useState([]); + const [loadingFaculty, setLoadingFaculty] = useState(false); + const [facultySearch, setFacultySearch] = useState(''); + const [isFacultyModalOpen, setIsFacultyModalOpen] = useState(false); + const [editingFaculty, setEditingFaculty] = useState(null); + const [facultyFormData, setFacultyFormData] = useState({ + name: '', + designation: 'Assistant Professor', + department: 'Computer Science & Engineering', + email: '', + office: '', + specialization: '', + isClassIncharge: false, + }); + + // Clubs & Centers State + const [clubsList, setClubsList] = useState([]); + const [loadingClubs, setLoadingClubs] = useState(false); + const [clubsSearch, setClubsSearch] = useState(''); + const [isClubModalOpen, setIsClubModalOpen] = useState(false); + const [editingClub, setEditingClub] = useState(null); + const [clubFormData, setClubFormData] = useState({ + name: '', + description: '', + category: 'Center of Excellence', + type: 'Center' as 'Club' | 'Center', + coordinatorName: '', + contactEmail: '', + details: '', + }); + + // Curriculum & GPA State + const [selectedGpaDept, setSelectedGpaDept] = useState('CSE'); + const [selectedGpaSem, setSelectedGpaSem] = useState(1); + const [curriculumMap, setCurriculumMap] = useState>>({}); + const [isCourseModalOpen, setIsCourseModalOpen] = useState(false); + const [editingCourseIndex, setEditingCourseIndex] = useState(null); + const [courseFormData, setCourseFormData] = useState({ + name: '', + credits: 3, + isElective: false, + }); // Transport State const [routes, setRoutes] = useState([]); diff --git a/src/pages/Notes/Notes.tsx b/src/pages/Notes/Notes.tsx index df6dbf5..927bb15 100644 --- a/src/pages/Notes/Notes.tsx +++ b/src/pages/Notes/Notes.tsx @@ -1337,29 +1337,39 @@ export default function Notes() { useEffect(() => { const fetchNotes = async () => { + let localFallback = NOTES_DATA; + try { + const saved = localStorage.getItem('RIT_LOCAL_NOTES'); + if (saved) { + const parsed = JSON.parse(saved); + if (Array.isArray(parsed) && parsed.length > 0) localFallback = parsed; + } + } catch {} + try { const response = await fetch(getBackendUrl('/api/notes')); if (response.ok) { const data = await response.json(); - const mappedData = data.map((n: any) => ({ - id: String(n.id), - title: n.title, - subject: n.subject, - department: n.department, - semester: n.semester, - type: n.fileType, - downloads: n.downloadsCount || 0, - fileSize: n.fileSize, - uploadedAt: n.uploadedAt ? n.uploadedAt.split('T')[0] : '', - downloadUrl: n.downloadUrl - })); - setNotes(mappedData); - } else { - setNotes(NOTES_DATA); + if (Array.isArray(data) && data.length > 0) { + const mappedData = data.map((n: any) => ({ + id: String(n.id), + title: n.title, + subject: n.subject, + department: n.department, + semester: n.semester, + type: n.fileType || 'notes', + downloads: n.downloadsCount || 0, + fileSize: n.fileSize || '2.4 MB', + uploadedAt: n.uploadedAt ? n.uploadedAt.split('T')[0] : '', + downloadUrl: n.downloadUrl || '#' + })); + setNotes(mappedData); + return; + } } - } catch (err) { - console.error('Error fetching notes:', err); - setNotes(NOTES_DATA); + setNotes(localFallback); + } catch { + setNotes(localFallback); } }; fetchNotes();