Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the Pyq Pages to All the years -- Issue No #12 #112

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/pyqs/1stYear/1sem.pdf
Binary file not shown.
Binary file added public/pyqs/1stYear/Nodejs Notes.pdf
Binary file not shown.
Binary file added public/pyqs/2ndYear/3rdsem.pdf
Binary file not shown.
Binary file added public/pyqs/3rdYear/5thsem.pdf
Binary file not shown.
Binary file added public/pyqs/4thYear/7thsem.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion src/components/page3/1Year.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function fstYear() {
</div>
</Link>

<Link class="link" to=''>
<Link class="link" to='/pyq/1st'>
<div class="card green">
<img src={pyq} alt=''/>
<p class="second-text">PYQ</p>
Expand Down
4 changes: 2 additions & 2 deletions src/components/page3/2Year.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ function sndYear() {
</div>
</Link>

<Link class="link" to="/pyq">
<Link class="link" to="/">
<div class="card syan">
<img src={timetable} alt="" />
<p class="second-text">Timetable</p>
</div>
</Link>

<Link class="link" to='/notes'>
<Link class="link" to='/pyq/2nd'>
<div class="card green">
<img src={pyq} alt=''/>
<p class="second-text">PYQ</p>
Expand Down
2 changes: 1 addition & 1 deletion src/components/page3/3Year.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function TrdYear() {
</div>
</Link>

<Link class="link" to='/pyq'>
<Link class="link" to='/pyq/3rd'>
<div class="card green">
<img src={pyq} alt=''/>
<p class="second-text">PYQ</p>
Expand Down
151 changes: 151 additions & 0 deletions src/components/page4/Pyq.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
html, body {
height: 100%;
margin: 0;
display: flex;
flex-direction: column;
}

.page-container {
display: flex;
flex-direction: column;
min-height: 100vh;
}

.container-pyq {
text-align: center;
margin: 20px;
flex: 1;
}

.year-heading {
font-size: 20px;
margin-bottom: 20px;
}

.semester-selection {
display: flex;
justify-content: center;
gap: 20px;
margin-bottom: 20px;
}

.semester-btn {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
transition: background-color 0.3s ease;
}

.semester-btn:hover {
background-color: #45a049;
}

.file-item {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}

.download-btn {
padding: 5px 10px;
font-size: 14px;
cursor: pointer;
background-color: #008CBA;
color: white;
border: none;
border-radius: 3px;
transition: background-color 0.3s ease;
}

.download-btn:hover {
background-color: #007bb5;
}

.back-btn {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
background-color: #f44336;
color: white;
border: none;
border-radius: 5px;
transition: background-color 0.3s ease;
margin-top: 20px;
}

.back-btn:hover {
background-color: #e53935;
}

.pyq-box {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: 20px;
}

.subjects-container {
display: flex;
gap: 20px;
flex-wrap: wrap;
}

.subject-box {
border: 1px solid #ccc;
padding: 10px;
border-radius: 5px;
flex: 1;
min-width: 45%;
}

.subject-title {
margin-bottom: 10px;
}

@media (max-width: 1200px) {
.subject-box {
min-width: 100%;
}
}

@media (max-width: 768px) {
.semester-selection {
flex-direction: column;
align-items: center;
}

.semester-btn {
width: 100%;
margin-bottom: 10px;
}

.subjects-container {
flex-direction: column;
gap: 15px;
}

.subject-box {
min-width: 100%;
}
}

@media (max-width: 600px) {
.subjects-container {
flex-direction: column;
gap: 10px;
}

.subject-box {
min-width: 100%;
}
}

.footer {
margin-top: auto;
}
146 changes: 138 additions & 8 deletions src/components/page4/pyq.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,143 @@
import React from 'react'
import ComingSoon from '../../pages/cs.js';
import React, { useState } from 'react';
import { useParams } from 'react-router-dom';
import Header from "../../pages/header";
import Footer from "../../pages/footer";
import './Pyq.css';

function Pyq() {
const yearFiles = [
{
year: '1st',
oddSemesters: {
subjects: [
{ name: 'Mathematics', files: ['1sem_mathematics.pdf', 'Nodejs Notes.pdf'] },
{ name: 'Physics', files: ['1sem_physics.pdf'] }
]
},
evenSemesters: {
subjects: [
{ name: 'Chemistry', files: ['2sem_chemistry.pdf'] },
{ name: 'Biology', files: ['2sem_biology.pdf'] }
]
}
},
{
year: '2nd',
oddSemesters: {
subjects: [
{ name: 'Computer Science', files: ['3rdsem.pdf'] }
]
},
evenSemesters: {
subjects: [
{ name: 'Electronics', files: ['4thsem_electronics.pdf'] }
]
}
},
{
year: '3rd',
oddSemesters: {
subjects: [
{ name: 'Data Structures', files: ['5thsem.pdf'] }
]
},
evenSemesters: {
subjects: [
{ name: 'Operating Systems', files: ['6thsem_operating_systems.pdf', 'os 23-24.pdf'] },
{ name: 'Networks', files: ['6thsem_networks.pdf'] }
]
}
},
{
year: '4th',
oddSemesters: {
subjects: [
{ name: 'Software Engineering', files: ['7thsem_software_engineering.pdf'] }
]
},
evenSemesters: {
subjects: [
{ name: 'Machine Learning', files: ['8thsem_machine_learning.pdf'] }
]
}
}
];

// Function to handle file download
const downloadFile = (filePath) => {
const link = document.createElement('a');
link.href = `${process.env.PUBLIC_URL}/${filePath}`;
const file = filePath.split('/').pop();
link.setAttribute('download', file);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};

const handleDownload = (filePath) => {
downloadFile(filePath);
};

const { id } = useParams();
const yearItem = yearFiles.find((item) => item.year === id);
const [selectedSemester, setSelectedSemester] = useState(null);

function pyq() {
return (
<div>

<ComingSoon/>
<div className="page-container">
<Header />
<div className="container-pyq">
<h2 className='head'>Download Previous Year Questions</h2>
{yearItem && <h3 className='year-heading'>{yearItem.year} Year</h3>}
<div className="content-container">
<div className="pyq-box">
{!selectedSemester ? (
<div className="semester-selection">
<button className="semester-button" onClick={() => setSelectedSemester('odd')}>Odd Semester</button>
<button className="semester-button" onClick={() => setSelectedSemester('even')}>Even Semester</button>
</div>
) : (
yearItem ? (
<div className="semester-container">
<div className="subjects-container">
{selectedSemester === 'odd' ? yearItem.oddSemesters.subjects.map((subject, subjIndex) => (
<div key={subjIndex} className="subject-box">
<h4 className="subject-title">{subject.name}</h4>
<ul>
{subject.files.map((file, fileIndex) => (
<li key={fileIndex} className="file-item">
<span>{file}</span>
<button className="download-button" onClick={() => handleDownload(`pyqs/${yearItem.year}Year/${file}`)}>Download</button>
</li>
))}
</ul>
</div>
)) : yearItem.evenSemesters.subjects.map((subject, subjIndex) => (
<div key={subjIndex} className="subject-box">
<h4 className="subject-title">{subject.name}</h4>
<ul>
{subject.files.map((file, fileIndex) => (
<li key={fileIndex} className="file-item">
<span>{file}</span>
<button className="download-button" onClick={() => handleDownload(`pyqs/${yearItem.year}Year/${file}`)}>Download</button>
</li>
))}
</ul>
</div>
))}
</div>

<button className="back-button" onClick={() => setSelectedSemester(null)}>Back to Semester Selection</button>
</div>
) : (
<p>Year data not found.</p>
)
)}
</div>
</div>
</div>
<Footer />
</div>
)
);
}

export default pyq
export default Pyq;
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const router = createBrowserRouter([
element: <Notes/>
},
{
path: "pyq",
path: "pyq/:id",
element: <Pyq />
},
{
Expand Down
Loading