Skip to content

Commit

Permalink
fix(courses): customize course list item subtitle
Browse files Browse the repository at this point in the history
  • Loading branch information
lpezzolla committed Sep 18, 2023
1 parent 3d2d7b9 commit 99bdb35
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@
"virtualClassroomsSectionTitle": "Virtual classrooms"
},
"courseListItem": {
"courseWithoutDetailsAlertTitle": "This course doesn't have any details"
"courseWithoutDetailsAlertTitle": "This course doesn't have any details",
"extra": "Extra APSP",
"overbooking": "Overbooking"
},
"courseNoticesTab": {
"emptyState": "There are no notices here",
Expand Down
4 changes: 3 additions & 1 deletion assets/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@
"virtualClassroomsSectionTitle": "Virtual classrooms"
},
"courseListItem": {
"courseWithoutDetailsAlertTitle": "Questo corso non ha dettagli"
"courseWithoutDetailsAlertTitle": "Questo corso non ha dettagli",
"extra": "Extra carico",
"overbooking": "Overbooking"
},
"courseNoticesTab": {
"emptyState": "Non ci sono avvisi",
Expand Down
1 change: 1 addition & 0 deletions src/core/queries/courseHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const useGetCourses = () => {
coursesClient
.getCourses()
.then(pluckData)
.then(c => c.sort((a, b) => (a.name > b.name ? 1 : -1)))
.then(p => {
let hasNewPreferences = false;
// Associate each course with a set of preferences, if missing
Expand Down
13 changes: 11 additions & 2 deletions src/features/teaching/components/CourseListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropsWithChildren } from 'react';
import { PropsWithChildren, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { Alert, Platform, View } from 'react-native';

Expand Down Expand Up @@ -71,9 +71,18 @@ export const CourseListItem = ({

const hasDetails = course.id != null;

const subtitle = useMemo(() => {
return (
`${course.cfu} ${t('common.credits').toLowerCase()}` +
(!course.isInPersonalStudyPlan ? ` • ${t('courseListItem.extra')}` : '') +
(course.isOverBooking ? ` • ${t('courseListItem.overbooking')}` : '')
);
}, [course.cfu, course.isInPersonalStudyPlan, course.isOverBooking, t]);

const listItem = (
<ListItem
accessible={accessible}
disabled={course.isOverBooking}
linkTo={
hasDetails
? {
Expand All @@ -91,7 +100,7 @@ export const CourseListItem = ({
course.cfu
} ${t('common.credits')}`}
title={course.name}
subtitle={`${course.cfu} ${t('common.credits').toLowerCase()}`}
subtitle={subtitle}
leadingItem={
<CourseIcon
icon={course.id ? preferences.courses[course.id]?.icon : undefined}
Expand Down

0 comments on commit 99bdb35

Please sign in to comment.