diff --git a/frontend/src/App.js b/frontend/src/App.js index 3ef2438..ef4209a 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -6,6 +6,7 @@ import LogoutPage from "./pages/LogoutPage"; import RegisterPage from "./pages/RegisterPage"; import CoursePage from "./pages/CoursePage"; import AssignmentPage from "./pages/AssignmentPage"; +import ContentPage from "./pages/ContentPage"; import ManagePage from "./pages/ManagePage"; import ManageStudentsPage from "./pages/ManageStudentsPage"; import AuthenticatedRoute from "./components/AuthenticatedRoute"; @@ -50,6 +51,16 @@ function App() { }} + + {(params) => { + return ( + + + + ); + }} + + {(params) => { return ( diff --git a/frontend/src/components/ContentWidget.jsx b/frontend/src/components/ContentWidget.jsx new file mode 100644 index 0000000..d6e428d --- /dev/null +++ b/frontend/src/components/ContentWidget.jsx @@ -0,0 +1,42 @@ +import { useContext, useEffect, useState } from "react"; +import { Card, Container } from "react-bootstrap"; +import { Link } from "wouter"; +import UserContext from "../contexts/UserContext"; +import { makeRequest } from "../utils.ts"; + +const ContentWidget = ({ className = "", cid }) => { + const [contentData, setContentData] = useState([]); + + useEffect(() => { + makeRequest({ endpoint: `course/${cid}/content` }) + .then((resp) => resp.json()) + .then((data) => { + setContentData(data.content); + }); + }, [setContentData]); + + return ( + +
+ {contentData.map((content, i) => { + return ( + + + + {content.name} + + + + ); + })} +
+
+ ); +}; + +export default ContentWidget; diff --git a/frontend/src/pages/ContentPage.jsx b/frontend/src/pages/ContentPage.jsx new file mode 100644 index 0000000..608389e --- /dev/null +++ b/frontend/src/pages/ContentPage.jsx @@ -0,0 +1,65 @@ +import { useEffect, useState } from "react"; +import { Container } from "react-bootstrap"; +import MyNavbar from "../components/MyNavbar"; +import { makeRequest } from "../utils.ts"; + +const ContentPage = ({ id }) => { + const [contentData, setContentData] = useState({}); + const [courseData, setCourseData] = useState({}); + + useEffect(() => { + const wrap = async () => { + let resp = await makeRequest({ endpoint: `content/${id}` }); + let data = await resp.json(); + setContentData(data); + + resp = await makeRequest({ endpoint: `course/${data.course_id}` }); + data = await resp.json(); + setCourseData(data); + }; + wrap(); + }, []); + + const Title = ({ children, className, ...rest }) => { + return ( +

+ {children} +

+ ); + }; + + const Value = ({ children, className, ...rest }) => { + return ( +
+ {children} +
+ ); + }; + + return ( +
+ + +

{courseData.name}

+
+ + + Name + {contentData.name} +
+ Created + {contentData.created_at} +
+ Body + + {contentData.body?.split("\n").map((line, k) => { + return
{line}
; + })} +
+
+
+
+ ); +}; + +export default ContentPage; diff --git a/frontend/src/pages/CoursePage.jsx b/frontend/src/pages/CoursePage.jsx index 092154f..87a898c 100644 --- a/frontend/src/pages/CoursePage.jsx +++ b/frontend/src/pages/CoursePage.jsx @@ -1,6 +1,7 @@ import { useEffect, useState } from "react"; import { Container } from "react-bootstrap"; import AssignmentsWidget from "../components/AssignmentsWidget"; +import ContentWidget from "../components/ContentWidget"; import MyNavbar from "../components/MyNavbar"; import { makeRequest } from "../utils.ts"; @@ -23,6 +24,9 @@ const CoursePage = ({ id }) => {

{courseData.instructor}


+

Course Content

+ +

Assignments