Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #351 from SELab-2/one-time-submit
Browse files Browse the repository at this point in the history
Herselecteren file na submit
  • Loading branch information
matt01y authored May 22, 2024
2 parents 4fcd04c + 0d57c11 commit 2e0a73b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions frontend/src/components/ProjectStudentComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChangeEvent, JSX, useEffect, useState} from "react";
import {ChangeEvent, JSX, useEffect, useRef, useState} from "react";
import FieldWithLabel from "./FieldWithLabel.tsx";
import {FaCheck, FaUpload} from "react-icons/fa";
import {FaDownload} from "react-icons/fa6";
Expand Down Expand Up @@ -75,6 +75,8 @@ export default function ProjectStudentComponent(props: { project: ProjectStudent
const [submission, setSubmission] = useState(props.project.submission)
const [groupInfo, setGroupInfo] = useState(props.project.groups_info)

const fileInputRef = useRef<HTMLInputElement | null>(null);

function TableJoinedGroup(props: {
groupMembers: {
name: string,
Expand Down Expand Up @@ -220,12 +222,17 @@ export default function ProjectStudentComponent(props: { project: ProjectStudent
setSuccess("The submission has been successful") // TODO translation
setError('')
}
setFile(undefined);
setNewSelectedFile(false);
if (fileInputRef.current) {
fileInputRef.current.value = '';
}
}
}

function selectFile(event: ChangeEvent<HTMLInputElement>) {
if (event.target?.files) {
setFile(event?.target?.files[0])
setFile(event?.target?.files[0]);
setNewSelectedFile(true);
}
}
Expand Down Expand Up @@ -304,6 +311,7 @@ export default function ProjectStudentComponent(props: { project: ProjectStudent
<div id="file-js" className="field is-horizontal">
<label className="file-label">
<input className="file-input" type="file" name="resume"
ref={fileInputRef}
onChange={selectFile}/>
<span className="file-cta">
<span className="file-icon"><FaUpload/></span>
Expand Down

0 comments on commit 2e0a73b

Please sign in to comment.