Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
axellorreyne committed May 22, 2024
2 parents 3816a50 + c6dc17d commit b6cadea
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 22 deletions.
53 changes: 36 additions & 17 deletions frontend/app/[locale]/components/ProjectDetailsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'
import React, { useEffect, useState } from "react";
import {checkGroup, getGroup, getProject, fetchUserData, Project, UserData} from "@lib/api";
import {checkGroup, getGroup, getProject, getUserData, Project, UserData} from "@lib/api";
import { useTranslation } from "react-i18next";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
Expand Down Expand Up @@ -154,22 +154,37 @@ const ProjectDetailsPage: React.FC<ProjectDetailsPageProps> = ({
/>
))) : (
<>
{user?.role !== 3 && (
<Button
variant="contained"
color="secondary"
startIcon={<EditIcon />}
href={`/${locale}/project/${project_id}/edit`}
sx={{
fontSize: "0.75rem",
py: 1,
marginRight: 1,
marginY: 1,
}}
>
{t("edit_project")}
</Button>
)}
{user?.role !== 3 && (
<>
<Button
variant="contained"
color="secondary"
href={`/${locale}/project/${project_id}/submissions`}
sx={{
fontSize: "0.75rem",
py: 1,
marginRight: 1,
marginY: 1,
}}
>
{t("submissions")}
</Button>
<Button
variant="contained"
color="secondary"
startIcon={<EditIcon />}
href={`/${locale}/project/${project_id}/edit`}
sx={{
fontSize: "0.75rem",
py: 1,
marginRight: 1,
marginY: 1,
}}
>
{t("edit_project")}
</Button>
</>
)}
<Button
variant="contained"
color="secondary"
Expand Down Expand Up @@ -287,6 +302,10 @@ const ProjectDetailsPage: React.FC<ProjectDetailsPageProps> = ({

function buildTree(paths) {
const tree = {};
if (!paths) {
return tree;
}

const paths_list = paths.split(',');
paths_list.forEach(path => {
const parts = path.split('/');
Expand Down
10 changes: 5 additions & 5 deletions frontend/app/[locale]/components/SubmissionDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import DownloadIcon from "@mui/icons-material/CloudDownload";

const backend_url = process.env['NEXT_PUBLIC_BACKEND_URL'];

interface ProjectDetailsPageProps {
interface SubmissionDetailsPageProps {
locale: any,
submission_id: number;
}

const ProjectDetailsPage: React.FC<ProjectDetailsPageProps> = ({ locale, submission_id }) => {
const SubmissionDetailsPage: React.FC<SubmissionDetailsPageProps> = ({ locale, submission_id }) => {
const { t } = useTranslation();

const [submission, setSubmission] = useState<Submission>();
Expand Down Expand Up @@ -67,7 +67,7 @@ const ProjectDetailsPage: React.FC<ProjectDetailsPageProps> = ({ locale, submiss
<ThemeProvider theme={baseTheme}>
<Grid container justifyContent="center" alignItems="flex-start" style={{ width: '100%', padding: '20px' }}>
<Grid item xs={12} style={{paddingBottom: '20px'}}>
<ProjectReturnButton locale={locale} project_id={project?.project_id} />
<ProjectReturnButton locale={locale} project_id={projectId} />
</Grid>
<Grid item xs={12}>
<Card raised style={{ width: '100%' }}>
Expand Down Expand Up @@ -107,7 +107,7 @@ const ProjectDetailsPage: React.FC<ProjectDetailsPageProps> = ({ locale, submiss
startIcon={<DownloadIcon />}
href={`${backend_url}/submissions/${submission_id}/download`}
download
size="small" // Adjust button size
size="small"
>
{t("download_file")}
</Button>
Expand All @@ -121,4 +121,4 @@ const ProjectDetailsPage: React.FC<ProjectDetailsPageProps> = ({ locale, submiss
);
};

export default ProjectDetailsPage;
export default SubmissionDetailsPage;
50 changes: 50 additions & 0 deletions frontend/app/[locale]/project/[project_id]/submissions/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import initTranslations from "@app/i18n";
import TranslationsProvider from "@app/[locale]/components/TranslationsProvider";
import NavBar from "@app/[locale]/components/NavBar";
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
import {Box, Button} from "@mui/material";
import React from "react";
import ProjectSubmissionsList from "@app/[locale]/components/ProjectSubmissionsList";
import Typography from "@mui/material/Typography";

const i18nNamespaces = ['common']

export default async function SubmissionsPage({params}: { params: { locale: any, project_id: number } }) {
const {locale, project_id: projectId} = params;
const {t, resources} = await initTranslations(locale, i18nNamespaces);

return (
<TranslationsProvider
resources={resources}
locale={locale}
namespaces={i18nNamespaces}
>
<NavBar/>
<Box width={'100%'} style={{padding: 20}}>
<Button
variant="outlined"
color="primary"
startIcon={<ArrowBackIcon/>}
href={`/${locale}/project/${projectId}`}
>
{t("return_project")}
</Button>
<Typography
variant="h3"
sx={{
fontWeight: 'medium',
marginTop: 2,
marginBottom: 2
}}
>
{t('all_submissions')}
</Typography>
<ProjectSubmissionsList
project_id={projectId}
page_size={10}
search={t("submission_search")}
/>
</Box>
</TranslationsProvider>
);
}
1 change: 1 addition & 0 deletions frontend/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"edit_user_details": "Edit user details",
"status_button_tooltip": "Required, optional or forbidden file",
"no_deadline": "No deadline",
"all_submissions": "All submissions",
"students": "Students",
"teachers": "Teachers",
"courses_archive": "Courses archive",
Expand Down
1 change: 1 addition & 0 deletions frontend/locales/nl/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
"edit_user_details": "Gebruiker bewerken",
"status_button_tooltip": "Verplicht, optioneel of verboden bestand",
"no_deadline": "Geen deadline",
"all_submissions": "Alle indieningen",
"students": "Studenten",
"teachers": "Docenten",
"courses_archive": "Gearchiveerde cursussen",
Expand Down

0 comments on commit b6cadea

Please sign in to comment.