Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(exams): fix exam booked count and available count #511

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading