diff --git a/langjo-frontend/package.json b/langjo-frontend/package.json index 17f4bd3..b08c5c6 100644 --- a/langjo-frontend/package.json +++ b/langjo-frontend/package.json @@ -1,4 +1,4 @@ -{ +{ "proxy": "http://localhost:5000", "name": "langjo-frontend", "version": "0.1.0", "private": true, diff --git a/langjo-frontend/src/Home.js b/langjo-frontend/src/Home.js index 6c6f5d0..2bdac93 100644 --- a/langjo-frontend/src/Home.js +++ b/langjo-frontend/src/Home.js @@ -4,6 +4,8 @@ import BeginnerLevel from "./components/BeginnerLevel/BeginnerLevel"; import BlocksCards from "./components/BlockCards/BlocksCards"; import Hero from "./components/Hero/Hero"; + + function Home() { return (
@@ -11,6 +13,8 @@ function Home() { + +
); } diff --git a/langjo-frontend/src/Pages.js b/langjo-frontend/src/Pages.js deleted file mode 100644 index 6d6161e..0000000 --- a/langjo-frontend/src/Pages.js +++ /dev/null @@ -1,19 +0,0 @@ -import React from "react"; -import { Routes, Route } from "react-router-dom"; -import EnglishLevel from "./components/EnglishLevel/EnglishLevel"; - -import Home from "./Home.js"; -// import LevelTest from "./components/LevelTest/LevelTest"; - -function Pages() { - return ( -
- - } /> - } /> - -
- ); -} - -export default Pages; diff --git a/langjo-frontend/src/components/BeginnerLevel/BeginnerLevel.js b/langjo-frontend/src/components/BeginnerLevel/BeginnerLevel.js index 7e1b706..6326794 100644 --- a/langjo-frontend/src/components/BeginnerLevel/BeginnerLevel.js +++ b/langjo-frontend/src/components/BeginnerLevel/BeginnerLevel.js @@ -31,14 +31,16 @@ function BeginnerLevel() { engaging video tutorials to help you grasp the fundamental concepts of learning curve...

-
- {getRandomSubset(videos, 3).map((video) => { +
+ {getRandomSubset(videos, 4).map((video) => { const videoId = video.videoUrl.split("/").pop(); // Extract video id from videoUrl return ( -
-
-
- + ); })} diff --git a/langjo-frontend/src/components/NavBar/NavBar.js b/langjo-frontend/src/components/NavBar/NavBar.js index 809d03f..4c06f8f 100644 --- a/langjo-frontend/src/components/NavBar/NavBar.js +++ b/langjo-frontend/src/components/NavBar/NavBar.js @@ -35,7 +35,7 @@ function NavBar() { Beginner - Intermadite + Intermediate Advance Quiz diff --git a/langjo-frontend/src/components/VideoPage/VideoPage.js b/langjo-frontend/src/components/VideoPage/VideoPage.js new file mode 100644 index 0000000..c62fa39 --- /dev/null +++ b/langjo-frontend/src/components/VideoPage/VideoPage.js @@ -0,0 +1,56 @@ +import React, { useEffect, useState } from "react"; +import { useParams } from "react-router-dom"; + + +const VideoPage = () => { + const videoId = useParams(); + const [videoData, setVideoData] = useState(null); + useEffect(() => { + const fetchVideoData = async () => { + try { + const res = await fetch( + `http://localhost:5000/api/videos/beginners-level/${videoId.id}` + ); + if (!res.ok) throw new Error(`HTTP error! Status: ${res.status}`); + const data = await res.json(); + setVideoData(data.data); + } catch (error) { + console.error("Failed to fetch video data:", error); + } + }; + fetchVideoData(); + }, [videoId]); + if (!videoData) { + return ( +
+
+ Loading... +
+
+ ); + } + const videoGet = + (videoData.videoUrl && videoData.videoUrl.split("/").pop()) || ""; + return ( +
+
+
+

{videoData.title}

+

{videoData.desc}

+
+