Dashboard Test 1
Lecturer Dashboard
This commit is contained in:
@@ -22,8 +22,13 @@ export default function Login() {
|
|||||||
|
|
||||||
url = "http://localhost:8080/users/check?sessionid=" + value;
|
url = "http://localhost:8080/users/check?sessionid=" + value;
|
||||||
fetch(url).then(r => r.json()).then(u => localStorage.setItem("userid", u.id))
|
fetch(url).then(r => r.json()).then(u => localStorage.setItem("userid", u.id))
|
||||||
|
let admin = 0
|
||||||
await router.push("/semesteroverview")
|
await fetch(url).then(o => o.json()).then(user => {
|
||||||
|
admin = user.permissions})
|
||||||
|
localStorage.setItem("admin", admin)
|
||||||
|
if(admin === 1) {
|
||||||
|
await router.push("/semesteroverview")
|
||||||
|
}else await router.push("/semesteroverviewLecturer")
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setInputPassword("");
|
setInputPassword("");
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import Button from "@/components/Button";
|
||||||
|
import React, {useEffect, useState} from "react";
|
||||||
|
import SemesterTile from "@/components/SemesterTile";
|
||||||
|
import InputForm from "@/components/InputForm";
|
||||||
|
import {useRouter} from "next/router";
|
||||||
|
import PopUp from "@/components/PopUp";
|
||||||
|
import Background from "@/components/Background";
|
||||||
|
import Logout from "@/components/Logout";
|
||||||
|
|
||||||
|
export default function SemesteroverviewLecturer(p)
|
||||||
|
{
|
||||||
|
async function getSemesters()
|
||||||
|
{
|
||||||
|
let urlTest = "http://localhost:8080/module/id?sessionid=" + localStorage.getItem("sessionid");
|
||||||
|
|
||||||
|
await fetch(urlTest).then(response => response.json()).then(s => {
|
||||||
|
setEntries(s)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function onClickSemester(e, m)
|
||||||
|
{
|
||||||
|
if(m.target === m.currentTarget)
|
||||||
|
{
|
||||||
|
localStorage.setItem("currentsid", e.id)
|
||||||
|
router.push("/planning")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getSemesternameById(id){
|
||||||
|
let urlname = "http://localhost:8080/semester/id?id=" + id + "&sessionid=" + localStorage.getItem("sessionid")
|
||||||
|
let name= "";
|
||||||
|
const response = await fetch(urlname);
|
||||||
|
const data = await response.json();
|
||||||
|
return data.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getSemesters();
|
||||||
|
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
async function fetchSemesterNames() {
|
||||||
|
let names = await Promise.all(
|
||||||
|
entries.map((e) => getSemesternameById(e.semesterid))
|
||||||
|
)
|
||||||
|
|
||||||
|
setSemesterNames(names);
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchSemesterNames();
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const [entries, setEntries] = useState([]);
|
||||||
|
const [semesterNames, setSemesterNames] = useState([]);
|
||||||
|
const [modalDisplay, setModalDisplay] = useState("none");
|
||||||
|
const [modalHint, setModalHint] = useState("");
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={"semester-overview"}>
|
||||||
|
<Logout />
|
||||||
|
<Background />
|
||||||
|
{entries.map((e, index) => (
|
||||||
|
<SemesterTile
|
||||||
|
text={semesterNames[index] + e.name} onClick={(f) => onClickSemester(e, f)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user