diff --git a/eduaid_web/package-lock.json b/eduaid_web/package-lock.json index 265257c..4da2e59 100644 --- a/eduaid_web/package-lock.json +++ b/eduaid_web/package-lock.json @@ -11,6 +11,7 @@ "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", + "dotenv": "^16.4.7", "pdf-lib": "^1.17.1", "react": "^18.3.1", "react-dom": "^18.3.1", @@ -7136,11 +7137,15 @@ } }, "node_modules/dotenv": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", + "license": "BSD-2-Clause", "engines": { - "node": ">=10" + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" } }, "node_modules/dotenv-expand": { @@ -15121,6 +15126,15 @@ } } }, + "node_modules/react-scripts/node_modules/dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=10" + } + }, "node_modules/react-switch": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/react-switch/-/react-switch-7.0.0.tgz", diff --git a/eduaid_web/package.json b/eduaid_web/package.json index 6cc891b..08e9780 100644 --- a/eduaid_web/package.json +++ b/eduaid_web/package.json @@ -43,4 +43,4 @@ "devDependencies": { "tailwindcss": "^3.4.9" } -} +} \ No newline at end of file diff --git a/eduaid_web/src/index.css b/eduaid_web/src/index.css index 31dc491..ffa3c78 100644 --- a/eduaid_web/src/index.css +++ b/eduaid_web/src/index.css @@ -22,4 +22,5 @@ code { border-image: linear-gradient(to right, #ff005c, #7600f2, #00cbe7); border-image-slice: 1; border-radius: 2rem; -} \ No newline at end of file +} + diff --git a/eduaid_web/src/pages/Home.css b/eduaid_web/src/pages/Home.css new file mode 100644 index 0000000..a7bc26b --- /dev/null +++ b/eduaid_web/src/pages/Home.css @@ -0,0 +1,30 @@ +/* Side Panel Styles */ +.side-panel { + background-color: #1e1e2f; + color: white; + padding: 20px; + width: 250px; /* Narrow side panel */ + position: fixed; + top: 0; + left: 0; + height: 100%; + transition: transform 0.3s ease-in-out; + transform: translateX(-100%); /* Hidden by default */ + box-shadow: 4px 0px 6px rgba(0, 0, 0, 0.3); /* Subtle shadow */ + border-radius: 0 20px 20px 0; + } + + .side-panel.open { + transform: translateX(0); /* Slide in */ + } + + .side-panel ul { + padding: 0; + list-style: none; + } + + .side-panel ul li { + margin-bottom: 10px; + font-size: 14px; + } + \ No newline at end of file diff --git a/eduaid_web/src/pages/Home.jsx b/eduaid_web/src/pages/Home.jsx index ec3a412..be643b3 100644 --- a/eduaid_web/src/pages/Home.jsx +++ b/eduaid_web/src/pages/Home.jsx @@ -9,7 +9,10 @@ import { FaGithub } from "react-icons/fa"; const Home = () => { const [stars, setStars] = useState(null); const [error, setError] = useState(""); + const [isSidePanelOpen, setIsSidePanelOpen] = useState(false); // State to toggle side panel + const [pastQuizzes, setPastQuizzes] = useState([]); // State to hold past quizzes + // Function to fetch GitHub stars async function fetchGitHubStars() { const response = await fetch( "https://api.github.com/repos/AOSSIE-Org/EduAid" @@ -21,6 +24,7 @@ const Home = () => { return data.stargazers_count; } + // Function to check if data is older than a day function isMoreThanOneDayOld(timestamp) { const oneDay = 24 * 60 * 60 * 1000; // One day in milliseconds return Date.now() - timestamp > oneDay; @@ -29,6 +33,7 @@ const Home = () => { useEffect(() => { const storedStars = localStorage.getItem("stars"); const storedTime = localStorage.getItem("fetchTime"); + if ( storedStars && storedTime && @@ -42,15 +47,76 @@ const Home = () => { localStorage.setItem("stars", starCount); localStorage.setItem("fetchTime", Date.now().toString()); }) - .catch((err) => { + .catch(() => { setError("Failed to fetch stars"); }); } + + // Fetch and display past quizzes from localStorage + const storedQuizzes = JSON.parse(localStorage.getItem("pastQuizzes")) || []; + setPastQuizzes(storedQuizzes); }, []); + // Toggle the side panel open/close + const toggleSidePanel = () => { + setIsSidePanelOpen(!isSidePanelOpen); + }; + + // Reset stored quizzes + const resetQuizHistory = () => { + localStorage.removeItem("pastQuizzes"); + setPastQuizzes([]); + }; + return (
-
+
+ {/* Hamburger Menu for Toggling the Side Panel */} +
+ ☰ {/* Hamburger Icon */} +
+ + {/* Side Panel */} + {isSidePanelOpen && ( +
+
+ Aossie Logo +
+ × {/* Close Icon */} +
+
+ +

Past Quizzes

+
    + {pastQuizzes.length === 0 ? ( +
  • No past quizzes found.
  • + ) : ( + pastQuizzes.slice(0, 5).map((quiz, index) => ( +
  • +
    + {quiz.topic} - {quiz.numQuestions} questions +
    + Difficulty: {quiz.difficulty} | Created on: {quiz.createdAt} +
    +
  • + )) + )} +
+ +
+ )} +
logo
@@ -69,26 +135,25 @@ const Home = () => {
-
-
- -
Doc/Audio Input
-
-
-
-
- -
In-depth questions gen
-
-
-
-
- -
- Dynamic Google Form Integration + {[{ text: "Doc/Audio Input", id: 1 }, { text: "In-depth questions gen", id: 2 }, { text: "Dynamic Google Form Integration", id: 3 }].map((feature) => ( +
+
+ +
+ {feature.text} +
-
+ ))}
@@ -114,7 +179,7 @@ const Home = () => { rel="noopener noreferrer" className="group" > -
+
{stars !== null ? ( diff --git a/eduaid_web/src/pages/Text_Input.jsx b/eduaid_web/src/pages/Text_Input.jsx index 4a60753..fbf5a04 100644 --- a/eduaid_web/src/pages/Text_Input.jsx +++ b/eduaid_web/src/pages/Text_Input.jsx @@ -161,6 +161,17 @@ const Text_Input = () => { } }; + const quizzes = JSON.parse(localStorage.getItem('quizzes')) || []; +const newQuiz = { + quizTitle: "Sample Quiz", + numberOfQuestions: 10, + difficulty: "Medium", + creationDate: new Date().toISOString(), + context: "This quiz covers advanced Python concepts." +}; +quizzes.push(newQuiz); +localStorage.setItem('quizzes', JSON.stringify(quizzes)); + return (
{loading && (