From e20a17bc25fe6a1fd327787ca0a264ae71a9d341 Mon Sep 17 00:00:00 2001 From: usserwoutV2 Date: Mon, 13 May 2024 20:14:31 +0200 Subject: [PATCH] Small bug fixes --- .../src/components/common/saveDockerForm.tsx | 2 +- frontend/src/i18n/en/translation.json | 1 - .../pages/index/components/ProjectCard.tsx | 2 +- .../project/components/SubmissionTab.tsx | 2 +- .../project/components/SubmissionsTab.tsx | 2 +- .../submission/components/SubmissionCard.tsx | 80 +++++++------------ frontend/src/pages/submit/Submit.tsx | 7 +- 7 files changed, 37 insertions(+), 59 deletions(-) diff --git a/frontend/src/components/common/saveDockerForm.tsx b/frontend/src/components/common/saveDockerForm.tsx index 2a616ea4..b52c81e9 100644 --- a/frontend/src/components/common/saveDockerForm.tsx +++ b/frontend/src/components/common/saveDockerForm.tsx @@ -18,7 +18,7 @@ const saveDockerForm = async (form:FormInstance, initialDockerValues: DockerForm return API.POST(ApiRoutes.PROJECT_TESTS, { body: data, pathValues: {id: projectId}}) } - if(data.dockerImage === null || data.dockerImage.length === 0 ) { + if(data.dockerImage == null || data.dockerImage.length === 0 ) { // We do a delete console.log("DELETE", data); return API.DELETE(ApiRoutes.PROJECT_TESTS, { pathValues: {id: projectId} }) diff --git a/frontend/src/i18n/en/translation.json b/frontend/src/i18n/en/translation.json index 377a23db..bcd6c716 100644 --- a/frontend/src/i18n/en/translation.json +++ b/frontend/src/i18n/en/translation.json @@ -99,7 +99,6 @@ "structureFailed": "Structure tests failed", "passed": "Passed", "uploadDirectory": "Upload directory", - "submission": "Submission", "notSubmitted": "Not submitted", "submitSuccess": "Submission successful", "submissionTime": "Submission time", diff --git a/frontend/src/pages/index/components/ProjectCard.tsx b/frontend/src/pages/index/components/ProjectCard.tsx index 70752eec..7419cae7 100644 --- a/frontend/src/pages/index/components/ProjectCard.tsx +++ b/frontend/src/pages/index/components/ProjectCard.tsx @@ -49,7 +49,7 @@ const ProjectCard: FC<{ courseId?: number }> = ({ courseId }) => { }} > diff --git a/frontend/src/pages/project/components/SubmissionTab.tsx b/frontend/src/pages/project/components/SubmissionTab.tsx index 6d8c50be..03959cf7 100644 --- a/frontend/src/pages/project/components/SubmissionTab.tsx +++ b/frontend/src/pages/project/components/SubmissionTab.tsx @@ -25,7 +25,7 @@ const SubmissionTab: FC<{ projectId: number; courseId: number }> = ({ projectId, return () => { ignore = true } - }, [projectId,courseId,API]) + }, [projectId,courseId]) diff --git a/frontend/src/pages/project/components/SubmissionsTab.tsx b/frontend/src/pages/project/components/SubmissionsTab.tsx index c63ac650..c2e34f32 100644 --- a/frontend/src/pages/project/components/SubmissionsTab.tsx +++ b/frontend/src/pages/project/components/SubmissionsTab.tsx @@ -24,7 +24,7 @@ const SubmissionsTab = () => { return () => { ignore = true } - }, [API,projectId]) + }, [projectId]) const handleDownloadSubmissions = () => { // TODO: implement this! diff --git a/frontend/src/pages/submission/components/SubmissionCard.tsx b/frontend/src/pages/submission/components/SubmissionCard.tsx index f218535a..b544a312 100644 --- a/frontend/src/pages/submission/components/SubmissionCard.tsx +++ b/frontend/src/pages/submission/components/SubmissionCard.tsx @@ -5,7 +5,6 @@ import {ApiRoutes} from "../../../@types/requests" import {ArrowLeftOutlined} from "@ant-design/icons" import {useNavigate} from "react-router-dom" import "@fontsource/jetbrains-mono" -import {useEffect, useState} from "react" import apiCall from "../../../util/apiFetch" export type SubmissionType = GET_Responses[ApiRoutes.SUBMISSION] @@ -13,13 +12,7 @@ export type SubmissionType = GET_Responses[ApiRoutes.SUBMISSION] const SubmissionCard: React.FC<{ submission: SubmissionType }> = ({submission}) => { const {token} = theme.useToken() const {t} = useTranslation() - const [structureFeedback, setStructureFeedback] = useState(null) - const [dockerFeedback, setDockerFeedback] = useState(null) const navigate = useNavigate() - useEffect(() => { - if (!submission.dockerAccepted) apiCall.get(submission.dockerFeedbackUrl).then((res) => setDockerFeedback(res.data ? res.data : "")) - if (!submission.structureAccepted) apiCall.get(submission.structureFeedbackUrl).then((res) => setStructureFeedback(res.data ? res.data : "")) - }, [submission.dockerFeedbackUrl, submission.structureFeedbackUrl]) const downloadSubmission = async () => { try { @@ -49,6 +42,7 @@ const SubmissionCard: React.FC<{ submission: SubmissionType }> = ({submission}) } } + const feedback = "TODO: feedback" return ( = ({submission}) {submission.structureAccepted ? t("submission.status.accepted") : t("submission.status.failed")} {submission.structureAccepted ? null : ( -
- {structureFeedback === null ? ( - - ) : ( - - )} -
- )} +
+ {submission.structureFeedback === null ? ( + + ) : ( + + )} +
+ )} @@ -124,28 +111,21 @@ const SubmissionCard: React.FC<{ submission: SubmissionType }> = ({submission})
  • {submission.dockerAccepted ? t("submission.status.accepted") : t("submission.status.failed")} - {submission.dockerAccepted ? null : ( -
    - {dockerFeedback === null ? ( - - ) : ( - - )} -
    - )} + {submission.dockerAccepted ? null : ( +
    + {submission.dockerFeedback === null ? ( + + ) : ( + + )} +
    + )}
  • diff --git a/frontend/src/pages/submit/Submit.tsx b/frontend/src/pages/submit/Submit.tsx index b5bab401..caf93d60 100644 --- a/frontend/src/pages/submit/Submit.tsx +++ b/frontend/src/pages/submit/Submit.tsx @@ -1,15 +1,14 @@ -import {Affix, Button, Card, Col, Form, Row, Typography} from "antd" +import {Button, Card, Col, Form, Row} from "antd" import {useTranslation} from "react-i18next" import SubmitForm from "./components/SubmitForm" import SubmitStructure from "./components/SubmitStructure" import {useNavigate, useParams} from "react-router-dom" -import React, {useState, useRef} from 'react'; +import {useState} from 'react'; import apiCall from "../../util/apiFetch"; import {ApiRoutes} from "../../@types/requests.d"; import JSZip from 'jszip'; -import { Popconfirm, message } from 'antd'; +import { message } from 'antd'; import {AppRoutes} from "../../@types/routes"; -import submission from "../submission/Submission"; const Submit = () => { const {t} = useTranslation()