Skip to content

Commit

Permalink
Merge pull request #276 from SELab-2/no_project_file
Browse files Browse the repository at this point in the history
project pagina werkt terug als er geen opdrachtsbestand is
  • Loading branch information
gusvanpoucke authored May 19, 2024
2 parents 2fc687a + 5d0c222 commit 7fd0dc0
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,30 @@ export function AssignmentPage() {
`/projecten/${assignmentId}/`
)
const newAssignment: Project = assignmentResponse.data
newAssignment.filename =
assignmentResponse.data.opgave_bestand.replace(
/^.*[\\/]/,
''
)
newAssignment.opgave_bestand = await instance
.get(`/projecten/${assignmentId}/opgave_bestand/`, {
responseType: 'blob',
})
.then((res) => {
let filename = 'indiening.zip'
if (newAssignment.filename) {
filename = newAssignment.filename
}
const blob = new Blob([res.data], {
type: res.headers['content-type'],
if (assignmentResponse.data.opgave_bestand) {
newAssignment.filename =
assignmentResponse.data.opgave_bestand.replace(
/^.*[\\/]/,
''
)
newAssignment.opgave_bestand = await instance
.get(`/projecten/${assignmentId}/opgave_bestand/`, {
responseType: 'blob',
})
const file: File = new File([blob], filename, {
type: res.headers['content-type'],
.then((res) => {
let filename = 'indiening.zip'
if (newAssignment.filename) {
filename = newAssignment.filename
}
const blob = new Blob([res.data], {
type: res.headers['content-type'],
})
const file: File = new File([blob], filename, {
type: res.headers['content-type'],
})
return file
})
return file
})
}
setAssignment(newAssignment)
if (user) {
if (user.is_lesgever) {
Expand Down Expand Up @@ -854,7 +856,7 @@ export function AssignmentPage() {
<Button
startIcon={<DownloadIcon />}
onClick={downloadAssignment}
disabled={assignment === undefined}
disabled={assignment === undefined || assignment.filename === undefined}
>
{loading ? (
<Skeleton
Expand All @@ -869,6 +871,8 @@ export function AssignmentPage() {
<>
{assignment
? assignment.filename
? assignment.filename
: t('no_assignmentfile')
: t('no_assignmentfile')}
</>
)}
Expand Down

0 comments on commit 7fd0dc0

Please sign in to comment.