diff --git a/eduaid_web/src/pages/Home.jsx b/eduaid_web/src/pages/Home.jsx index e00a0d23..f581f7f4 100644 --- a/eduaid_web/src/pages/Home.jsx +++ b/eduaid_web/src/pages/Home.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from "react"; import "../index.css"; -import logo_trans from "../assets/aossie_logo_transparent.png" +import logo_trans from "../assets/aossie_logo_transparent.png"; import starsImg from "../assets/stars.png"; import arrow from "../assets/arrow.png"; import gitStar from "../assets/gitStar.png"; @@ -12,9 +12,21 @@ const Home = () => { const [error, setError] = useState(""); async function fetchGitHubStars() { - const response = await fetch("https://api.github.com/repos/AOSSIE-Org/EduAid"); - if (!response.ok) throw new Error("Failed to fetch stars"); + const response = await fetch( + "https://api.github.com/repos/AOSSIE-Org/EduAid" + ); + const data = await response.json(); + + if ( + !response.ok || + !data || + typeof data.stargazers_count !== "number" + ) { + console.error("Invalid GitHub API response:", data); + throw new Error("Invalid GitHub response"); + } + return data.stargazers_count; } @@ -27,24 +39,36 @@ const Home = () => { const storedStars = localStorage.getItem("stars"); const storedTime = localStorage.getItem("fetchTime"); - if (storedStars && storedTime && !isMoreThanOneDayOld(parseInt(storedTime))) { - setStars(parseInt(storedStars)); - } else { - fetchGitHubStars() - .then((starCount) => { - setStars(starCount); - localStorage.setItem("stars", starCount); - localStorage.setItem("fetchTime", Date.now().toString()); - }) - .catch(() => setError("Failed to fetch stars")); + if (storedStars !== null && storedTime !== null) { + const cachedStars = Number(storedStars); + const cachedTime = Number(storedTime); + + if ( + Number.isFinite(cachedStars) && + Number.isFinite(cachedTime) && + !isMoreThanOneDayOld(cachedTime) + ) { + setStars(cachedStars); + return; + } } + + fetchGitHubStars() + .then((starCount) => { + setStars(starCount); + localStorage.setItem("stars", String(starCount)); + localStorage.setItem("fetchTime", Date.now().toString()); + }) + .catch(() => setError("Failed to fetch stars")); }, []); return ( -
+
-
- logo +
+ + {/* Logo */} + EduAid Logo {/* Heading */}

@@ -57,44 +81,108 @@ const Home = () => {

{/* Subtitle */} -
-

A tool that can auto-generate short quizzes

-
-

based on user input

- stars -
+
+

Turn your notes into interactive quizzes in seconds.

+

+ Upload your PDF or DOC file and start practicing instantly. +

- {/* Features */} -
+ {/* Feature Highlights */} +
{[ - "Doc/Audio Input", - "In-depth questions gen", - "Dynamic Google Form Integration", + "PDF / DOC Upload", + "AI-powered Quiz Generation", + "Instant Practice Mode", ].map((feature, i) => (
-
{feature}
+
+ {feature} +
))}
- {/* Buttons */} -
- - + {/* Primary Buttons */} +
+ + + Upload & Generate Quiz + - - + + + View Previous Work + + + +
+ + {/* How It Works */} +
+

+ How It Works +

+ +
+ {[ + "Upload your PDF or DOC file", + "AI generates quiz questions instantly", + "Start practicing and test your knowledge", + ].map((step, i) => ( +
+

+ Step {i + 1} +

+

{step}

+
+ ))} +
+
+ + {/* Why EduAid */} +
+

+ Why EduAid? +

+ +
+ {[ + "Saves hours of manual question creation", + "Encourages active recall learning", + "Instant feedback improves retention", + "Perfect for exams and revision", + ].map((point, i) => ( +
+

{point}

+
+ ))} +
+
+ + {/* Final CTA */} +
+ + Turn Your Notes Into a Quiz Now
@@ -103,7 +191,7 @@ const Home = () => { href="https://github.com/AOSSIE-Org/EduAid" target="_blank" rel="noopener noreferrer" - className="group block mt-10" + className="group block mt-16" >
GitHub Star @@ -119,10 +207,11 @@ const Home = () => {
+
); }; -export default Home; +export default Home; \ No newline at end of file