Skip to content

Commit

Permalink
fix(exams): fix exam booked count and available count
Browse files Browse the repository at this point in the history
  • Loading branch information
FabrizioCostaMedich committed Jul 11, 2024
1 parent 7c84dd0 commit 4070c70
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@
"noLocation": "Room to be defined",
"notAvailable": "Booking not available",
"notes": "Notes",
"title": "Exam call"
"title": "Exam call",
"noBookedCount": "Data not available"
},
"examsScreen": {
"emptyState": "There are no open exam calls",
Expand Down
3 changes: 2 additions & 1 deletion assets/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@
"noLocation": "Aula da definire",
"notAvailable": "Prenotazione non disponibile",
"notes": "Note",
"title": "Appello"
"title": "Appello",
"noBookedCount": "Dato non disponibile"
},
"examsScreen": {
"emptyState": "Non ci sono appelli disponibili",
Expand Down
4 changes: 1 addition & 3 deletions src/features/teaching/screens/ExamScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,13 @@ export const ExamScreen = ({ route, navigation }: Props) => {
inverted
/* check using undefined since the fields can be 0 */
title={
exam?.availableCount !== undefined &&
exam?.bookedCount !== undefined
? getExam(exam.bookedCount, exam.availableCount)
: ''
: t('examScreen.noBookedCount')
}
subtitle={t('examScreen.bookedCount')}
trailingItem={
exam?.status === ExamStatusEnum.Unavailable &&
exam?.availableCount &&
exam.availableCount === 0 ? (
<Icon
icon={faTriangleExclamation}
Expand Down
2 changes: 1 addition & 1 deletion src/features/teaching/utils/exam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const isExamPassed = (bookingEndsAt: Date) => {
};

export const getExam = (bookedCount: number, availableCount: number) => {
if (availableCount === 999) {
if (availableCount === undefined || availableCount === 999) {
return `${bookedCount}`;
}
return `${bookedCount}/${availableCount + bookedCount}`;
Expand Down

0 comments on commit 4070c70

Please sign in to comment.