Skip to content

Commit

Permalink
Merge pull request #314 from SELab-2/last_bugs
Browse files Browse the repository at this point in the history
frontend kapot 😢
  • Loading branch information
Bendemeurichy authored May 23, 2024
2 parents 144ae22 + d960444 commit 2b285c9
Show file tree
Hide file tree
Showing 5 changed files with 520 additions and 513 deletions.
13 changes: 9 additions & 4 deletions frontend/frontend/src/components/CourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,14 @@ export function CourseCard({
setGroups(groups)

const submissionPromises = groups.map(async (group) => {
const response = await instance.get<Submission>(
const response = await instance.get<Submission[]>(
`/indieningen/?project=${group.project}&groep=${group.groep_id}`
)
return response.data
return response.data.sort(
(a: Submission, b: Submission) => {
return dayjs(b.tijdstip).diff(dayjs(a.tijdstip))
}
)[0]
})
const submissions = await axios.all(submissionPromises)

Expand Down Expand Up @@ -155,13 +159,14 @@ export function CourseCard({
}

const mySubmission = submissions.find(
(submission) => submission.groep === myGroup.groep_id
(submission) =>
(submission ? submission.groep : 0) === myGroup.groep_id
)

if (!mySubmission) {
return SubmissionStatus.FAIL
}

console.log('myStatus', mySubmission.status)
return mySubmission.status
}

Expand Down
25 changes: 15 additions & 10 deletions frontend/frontend/src/components/SubmissionListItemTeacherPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ export function SubmissionListItemTeacherPage({
const submissionsResponse = await instance.get(
`/indieningen/?groep=${group_id}`
)
const lastSubmission =
submissionsResponse.data[
submissionsResponse.data.length - 1
]
const lastSubmission = submissionsResponse.data.sort(
(a: Submission, b: Submission) => {
return dayjs(a.tijdstip).isBefore(dayjs(b.tijdstip))
? -1
: 1
}
)[submissionsResponse.data.length - 1]
if (lastSubmission) {
const lastSubmissionResponse = await instance.get(
`indieningen/${lastSubmission.indiening_id}/`
Expand All @@ -77,7 +80,7 @@ export function SubmissionListItemTeacherPage({
)
newSubmission.bestand = await instance
.get(
`/indieningen/${lastSubmission.indiening_id}/indiening_bestand`,
`/indieningen/${lastSubmission.indiening_id}/indiening_bestand/`,
{
responseType: 'blob',
}
Expand Down Expand Up @@ -175,12 +178,14 @@ export function SubmissionListItemTeacherPage({
<HighlightOffIcon
sx={{ color: 'error.main' }}
/>
) : submitted.status > 0 ? (
<CheckCircleOutlineIcon
sx={{ color: 'success.main' }}
/>
) : (
submitted !== undefined && (
<CheckCircleOutlineIcon
sx={{ color: 'success.main' }}
/>
)
<HighlightOffIcon
sx={{ color: 'error.main' }}
/>
)}
</ListItemIcon>
</Box>,
Expand Down
Loading

0 comments on commit 2b285c9

Please sign in to comment.