-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15f0c70
commit b786c58
Showing
5 changed files
with
128 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
frontend/src/components/Courses/CourseDetailStudent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { | ||
Grid, | ||
Paper, | ||
Typography, | ||
} from "@mui/material"; | ||
import { useTranslation } from "react-i18next"; | ||
import { | ||
Course, ProjectDetail, | ||
} from "./CourseUtils"; | ||
import { | ||
useLoaderData, | ||
} from "react-router-dom"; | ||
import { Title } from "../Header/Title"; | ||
import { Me } from "../../types/me"; | ||
import {EmptyOrNotProjects} from "./CourseDetailTeacher" | ||
|
||
|
||
|
||
/** | ||
* | ||
* @returns A jsx component representing the course detail page for a teacher | ||
*/ | ||
export default function CourseDetailStudent() { | ||
|
||
|
||
|
||
const courseDetail = useLoaderData() as { | ||
course: Course; | ||
projects: ProjectDetail[]; | ||
adminMes: Me[]; | ||
studentMes: Me[]; | ||
me:Me; | ||
}; | ||
const { course, projects, adminMes } = courseDetail; | ||
const { t } = useTranslation("translation", { | ||
keyPrefix: "courseDetailTeacher", | ||
}); | ||
|
||
return ( | ||
<> | ||
<Title title={course.name}></Title> | ||
<Grid | ||
container | ||
direction={"row"} | ||
spacing={2} | ||
margin="1rem" | ||
style={{ height: "80vh" }} | ||
> | ||
<Grid item xs={5} height="100%"> | ||
<Paper | ||
style={{ height: "100%", maxHeight: "100%", overflow: "auto" }} | ||
> | ||
<div style={{ padding: "1rem" }}> | ||
<Typography variant="h5">{t("projects")}:</Typography> | ||
<EmptyOrNotProjects projects={projects} /> | ||
</div> | ||
</Paper> | ||
</Grid> | ||
<Grid item xs={5} height="100%"> | ||
<Grid container direction={"column"} spacing={2} height={"100%"}> | ||
<Grid | ||
item | ||
style={{ | ||
height: "50%", | ||
}} | ||
> | ||
<Paper | ||
style={{ | ||
overflow: "auto", | ||
height: "100%", | ||
}} | ||
> | ||
<Typography variant="h5">{t("admins")}:</Typography> | ||
<Grid container direction={"column"}> | ||
{adminMes.map((admin: Me) => ( | ||
<Grid | ||
container | ||
alignItems="center" | ||
spacing={1} | ||
key={admin.uid} | ||
> | ||
<Grid item> | ||
<Typography variant="body1"> | ||
{admin.display_name} | ||
</Typography> | ||
</Grid> | ||
|
||
</Grid> | ||
))} | ||
</Grid> | ||
</Paper> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</> | ||
); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {useLoaderData} from "react-router-dom"; | ||
import {Me} from "../../types/me.ts"; | ||
import {Course, ProjectDetail} from "./CourseUtils.tsx"; | ||
import CourseDetailTeacher from "./CourseDetailTeacher.tsx"; | ||
import CourseDetailStudent from "./CourseDetailStudent.tsx"; | ||
|
||
export default function CoursesDetail() :JSX.Element { | ||
const loader = useLoaderData() as { | ||
course: Course; | ||
projects: ProjectDetail[]; | ||
adminMes: Me[]; | ||
studentMes: Me[]; | ||
me:Me; | ||
}; | ||
if (loader.me.role == "TEACHER") { | ||
return <CourseDetailTeacher/>; | ||
} else { | ||
return <CourseDetailStudent/>; | ||
} | ||
} |