This repository has been archived by the owner on Jan 22, 2025. It is now read-only.
-
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.
Merge branch 'development' into frontend/fix/authorization-project-view
- Loading branch information
Showing
5 changed files
with
125 additions
and
5 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
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,94 @@ | ||
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,24 @@ | ||
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"; | ||
|
||
/** | ||
* gives the right detail page | ||
* @returns - detail page | ||
*/ | ||
export default function CoursesDetail() :JSX.Element { | ||
const loader = useLoaderData() as { | ||
course: Course; | ||
projects: ProjectDetail[]; | ||
adminMes: Me[]; | ||
studentMes: Me[]; | ||
me:Me; | ||
}; | ||
if (loader.course.teacher === loader.me.uid) { | ||
return <CourseDetailTeacher/>; | ||
} else { | ||
return <CourseDetailStudent/>; | ||
} | ||
} |