From cf9067b4fe4d46c04e10b4b52106a4318c564165 Mon Sep 17 00:00:00 2001 From: Shashank Gangade Date: Mon, 13 Jul 2026 16:49:10 +0530 Subject: [PATCH 1/2] feat: implement syllabus preview and download functionality --- client/src/pages/Syllabus.js | 118 +++++++++++++++++++++++------------ 1 file changed, 77 insertions(+), 41 deletions(-) diff --git a/client/src/pages/Syllabus.js b/client/src/pages/Syllabus.js index 9c3ee4e..533192e 100644 --- a/client/src/pages/Syllabus.js +++ b/client/src/pages/Syllabus.js @@ -19,7 +19,9 @@ const Syllabus = () => { uploadDate: "2024-01-15", fileSize: "2.4 MB", difficulty: "Beginner", - tags: ["CSE", "First Year", "Basic Programming"] + tags: ["CSE", "First Year", "Basic Programming"], + + pdf: "/pdf/DBMS.pdf" }, { id: 2, @@ -32,7 +34,9 @@ const Syllabus = () => { uploadDate: "2024-01-18", fileSize: "2.8 MB", difficulty: "Intermediate", - tags: ["Mechanical", "Thermodynamics", "Manufacturing"] + tags: ["Mechanical", "Thermodynamics", "Manufacturing"], + + pdf: "/pdf/DSA.pdf" }, { id: 3, @@ -45,7 +49,9 @@ const Syllabus = () => { uploadDate: "2024-01-20", fileSize: "3.1 MB", difficulty: "Intermediate", - tags: ["CSE", "Data Structures", "Database"] + tags: ["CSE", "Data Structures", "Database"], + + pdf: "/pdf/Java.pdf" }, { id: 4, @@ -58,7 +64,9 @@ const Syllabus = () => { uploadDate: "2024-01-22", fileSize: "3.5 MB", difficulty: "Advanced", - tags: ["Electronics", "Microprocessors", "Communication"] + tags: ["Electronics", "Microprocessors", "Communication"], + + pdf: "/pdf/OS.pdf" }, { id: 5, @@ -71,7 +79,9 @@ const Syllabus = () => { uploadDate: "2024-01-25", fileSize: "2.2 MB", difficulty: "Beginner", - tags: ["IT", "Web Development", "Networks"] + tags: ["IT", "Web Development", "Networks"], + + pdf: "/pdf/python.pdf" }, { id: 6, @@ -84,7 +94,9 @@ const Syllabus = () => { uploadDate: "2024-01-12", fileSize: "2.9 MB", difficulty: "Intermediate", - tags: ["Civil", "Structural", "Environmental"] + tags: ["Civil", "Structural", "Environmental"], + + pdf: "/pdf/WebDevelopment.pdf" }, { id: 7, @@ -97,7 +109,9 @@ const Syllabus = () => { uploadDate: "2024-01-28", fileSize: "4.2 MB", difficulty: "Advanced", - tags: ["CSE", "Machine Learning", "Security"] + tags: ["CSE", "Machine Learning", "Security"], + + pdf: "/pdf/DBMS.pdf" }, { id: 8, @@ -110,7 +124,9 @@ const Syllabus = () => { uploadDate: "2024-01-14", fileSize: "3.3 MB", difficulty: "Intermediate", - tags: ["Electrical", "Power Systems", "Circuits"] + tags: ["Electrical", "Power Systems", "Circuits"], + + pdf: "/pdf/DSA.pdf" } ]; @@ -124,13 +140,13 @@ const Syllabus = () => { hidden: { opacity: 0 }, visible: { opacity: 1, transition: { staggerChildren: 0.15, delayChildren: 0.1 } } }; - + const scaleIn = { hidden: { opacity: 0, scale: 0.85 }, visible: { opacity: 1, scale: 1, transition: { duration: 0.5, ease: "easeOut" } } }; -const [showScroll, setShowScroll] = useState(false); + const [showScroll, setShowScroll] = useState(false); useEffect(() => { const checkScrollTop = () => { @@ -170,8 +186,8 @@ const [showScroll, setShowScroll] = useState(false); const filteredAndSortedSyllabi = useMemo(() => { let filtered = syllabusData.filter(item => { const matchesSearch = item.title.toLowerCase().includes(searchTerm.toLowerCase()) || - item.subjects.some(subject => subject.toLowerCase().includes(searchTerm.toLowerCase())) || - item.tags.some(tag => tag.toLowerCase().includes(searchTerm.toLowerCase())); + item.subjects.some(subject => subject.toLowerCase().includes(searchTerm.toLowerCase())) || + item.tags.some(tag => tag.toLowerCase().includes(searchTerm.toLowerCase())); const matchesUniversity = selectedUniversity === 'All' || item.university === selectedUniversity; const matchesDepartment = selectedDepartment === 'All' || item.department === selectedDepartment; const matchesSemester = selectedSemester === 'All' || item.semester.toString() === selectedSemester; @@ -197,8 +213,27 @@ const [showScroll, setShowScroll] = useState(false); }, [searchTerm, selectedUniversity, selectedDepartment, selectedSemester, sortBy, syllabusData]); const handleDownload = (syllabus) => { - // Simulate download - alert(`Downloading: ${syllabus.title}`); + if (!syllabus.pdf) { + alert("Syllabus PDF is not available."); + return; + } + + const link = document.createElement("a"); + link.href = syllabus.pdf; + link.download = syllabus.title + ".pdf"; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + }; + + + const handlePreview = (syllabus) => { + if (!syllabus.pdf) { + alert("Preview is not available."); + return; + } + + window.open(syllabus.pdf, "_blank"); }; const getDifficultyColor = (difficulty) => { @@ -213,7 +248,7 @@ const [showScroll, setShowScroll] = useState(false); return (
{/* Hero Section */} - {/* Search and Filters */} - {/* Results Section */} - Found {filteredAndSortedSyllabi.length} syllabi

Browse through our collection of verified academic syllabi

- + {filteredAndSortedSyllabi.length === 0 ? ( - Try adjusting your search criteria or filters to find what you're looking for.

) : ( - {filteredAndSortedSyllabi.map(syllabus => ( -
- handleDownload(syllabus)} whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }} > 📥 Download Syllabus - handlePreview(syllabus)} whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }} > @@ -423,22 +459,22 @@ const [showScroll, setShowScroll] = useState(false); {/* Scroll to Top Button */} - - {showScroll && ( - - - - )} - + + {showScroll && ( + + + + )} +
); }; From 6aac10189786f8e834902f2eb7261f367b1e75e4 Mon Sep 17 00:00:00 2001 From: Shashank Gangade Date: Mon, 13 Jul 2026 17:02:10 +0530 Subject: [PATCH 2/2] feat: implement syllabus preview and download functionality --- client/src/pages/Syllabus.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/pages/Syllabus.js b/client/src/pages/Syllabus.js index 533192e..9c8d508 100644 --- a/client/src/pages/Syllabus.js +++ b/client/src/pages/Syllabus.js @@ -126,7 +126,7 @@ const Syllabus = () => { difficulty: "Intermediate", tags: ["Electrical", "Power Systems", "Circuits"], - pdf: "/pdf/DSA.pdf" + pdf: null } ]; @@ -214,7 +214,7 @@ const Syllabus = () => { const handleDownload = (syllabus) => { if (!syllabus.pdf) { - alert("Syllabus PDF is not available."); + window.alert("This syllabus PDF is not available yet."); return; } @@ -229,7 +229,7 @@ const Syllabus = () => { const handlePreview = (syllabus) => { if (!syllabus.pdf) { - alert("Preview is not available."); + window.alert("Preview is not available because the syllabus PDF has not been uploaded yet."); return; }