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.
* start homepage * added calender functions and titlecard * homepage changes * homepage changes * Added: Homepage and Student Homepage * homepage changes * project projects parser * test passed * linter * pr review * Project card refactor * homepage change fix * Revert "Merge remote-tracking branch 'origin/backend/projectendpoint-fix' into frontend/feature/homepage" This reverts commit 645443a, reversing changes made to e5451b6. * homepage changes * rm comment * pr changes * project overview * project overview * project overview done * pr changes * project page changes * added support for no deadline projects * link changed * link changed * pr changes * merged with HomeStudent.tsx * projects overview page * wording change * homepage change * homepage change * API URL to API_HOST * end point with /me * project pages * home * create button * create button * opt * deadline fix * deadline fix * deadline fix * deadline fix * creds --------- Co-authored-by: gerwoud <gerwoud@hotmail.be>
- Loading branch information
1 parent
c5e9fbc
commit 9b61937
Showing
7 changed files
with
151 additions
and
33 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
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
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,97 @@ | ||
import {ProjectDeadline} from "./projectDeadline/ProjectDeadline.tsx"; | ||
import {Button, Card, CardContent, Container, Grid, Typography, Link} from "@mui/material"; | ||
import {ProjectDeadlineCard} from "./projectDeadline/ProjectDeadlineCard.tsx"; | ||
import { useTranslation } from "react-i18next"; | ||
import {Title} from "../../components/Header/Title.tsx"; | ||
import {useLoaderData, Link as RouterLink} from "react-router-dom"; | ||
import dayjs from "dayjs"; | ||
|
||
/** | ||
* Displays all the projects | ||
* @returns the project page | ||
*/ | ||
export default function ProjectOverView() { | ||
const {i18n} = useTranslation() | ||
const { t } = useTranslation('translation', { keyPrefix: 'projectsOverview' }); | ||
const loader = useLoaderData() as { | ||
projects: ProjectDeadline[], | ||
me: string | ||
} | ||
const projects = loader.projects | ||
const me = loader.me | ||
|
||
const projectReducer = (acc: {[key: string]: ProjectDeadline[]}, project: ProjectDeadline) => { | ||
(acc[project.course.course_id] = acc[project.course.course_id] || []).push(project); | ||
return acc; | ||
} | ||
const futureProjectsByCourse = projects | ||
.filter((p) => (p.deadline && dayjs(dayjs()).isBefore(p.deadline))) | ||
.sort((a, b) => dayjs(a.deadline).diff(dayjs(b.deadline))) | ||
.reduce(projectReducer, {}); | ||
const pastProjectsByCourse = projects | ||
.filter((p) => p.deadline && (dayjs()).isAfter(p.deadline)) | ||
.sort((a, b) => dayjs(b.deadline).diff(dayjs(a.deadline))) | ||
.reduce(projectReducer, {}); | ||
const noDeadlineProject = projects.filter((p) => p.deadline === undefined) | ||
.reduce(projectReducer,{}); | ||
|
||
const projectItem = ([index, courseProjects] : [string, ProjectDeadline[]]) =>{ | ||
return ( | ||
<Grid container spacing={2} key={index}> | ||
<Grid item xs={12}> | ||
<Link href={`/${i18n.language}/course/${courseProjects[0].course.course_id}`} style={{color: 'inherit'}} | ||
underline={'none'}> | ||
<Typography variant="h6">{courseProjects[0].course.name} {courseProjects[0].course.ufora_id}</Typography> | ||
</Link> | ||
</Grid> | ||
<Grid item xs={8}> | ||
<ProjectDeadlineCard deadlines={courseProjects} showCourse={false} /> | ||
</Grid> | ||
</Grid> | ||
) | ||
} | ||
return ( | ||
<Container style={{ paddingTop: '50px' }}> | ||
<Title title={"Projects Overview"}/> | ||
<Grid container spacing={2}> | ||
<Grid item xs={2}> | ||
{me === 'TEACHER' && ( | ||
<Button component={RouterLink} to={`/${i18n.language}/projects/create`}>{t('new_project')}</Button> | ||
)} | ||
</Grid> | ||
<Grid item xs={5}> | ||
<Card> | ||
<CardContent> | ||
<Typography variant="h5" style={{ color: '#3f51b5' }}>{t("future_deadline")}:</Typography> | ||
{Object.keys(futureProjectsByCourse).length + Object.keys(noDeadlineProject).length === 0 ? ( | ||
<Typography variant="body1"> | ||
{t('no_projects')} | ||
</Typography> | ||
) :( | ||
[...Object.entries(futureProjectsByCourse), | ||
...Object.entries(noDeadlineProject)].map(projectItem) | ||
)} | ||
</CardContent> | ||
</Card> | ||
|
||
</Grid> | ||
<Grid item xs={5}> | ||
<Card> | ||
<CardContent> | ||
<Typography variant="h5" style={{ color: '#3f51b5' }}>{t("past_deadline")}:</Typography> | ||
{ | ||
Object.keys(pastProjectsByCourse).length === 0 ? ( | ||
<Typography variant="body1"> | ||
{t('no_projects')} | ||
</Typography> | ||
):( | ||
Object.entries(pastProjectsByCourse).map(projectItem) | ||
) | ||
} | ||
</CardContent> | ||
</Card> | ||
</Grid> | ||
</Grid> | ||
</Container> | ||
) | ||
} |