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(ui): multiple instructors are formatted properly, displays last name only, and are capitalized in all course blocks (#342) #403

Merged
5 changes: 3 additions & 2 deletions src/views/components/common/PopupCourseBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ export default function PopupCourseBlock({
<DragIndicatorIcon className='h-6 w-6 text-white' />
</div>
<Text className={clsx('flex-1 py-3.5 truncate', fontColor)} variant='h1-course'>
<span className='px-0.5 font-450'>{formattedUniqueId}</span> {course.department} {course.number} &ndash;{' '}
{course.instructors.length === 0 ? 'Unknown' : course.instructors.map(v => v.lastName)}
<span className='px-0.5 font-450'>{formattedUniqueId}</span> {course.department} {course.number}
{course.instructors.length > 0 ? <> &ndash; </> : ''}
{course.instructors.map(v => v.toString({ format: 'last', case: 'capitalize' })).join('; ')}
</Text>
{enableCourseStatusChips && course.status !== Status.OPEN && (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ export default function HeadingAndActions({ course, activeSchedule, onClose }: H
const formattedUniqueId = uniqueId.toString().padStart(5, '0');
const isInCalendar = useCalendar();

const getInstructorFullName = (instructor: Instructor) => {
const { firstName = '', lastName = '' } = instructor;
if (firstName === '') return capitalizeString(lastName);
return `${capitalizeString(firstName)} ${capitalizeString(lastName)}`;
};
const getInstructorFullName = (instructor: Instructor) =>
instructor.toString({ format: 'first_last', case: 'capitalize' });
adityamkk marked this conversation as resolved.
Show resolved Hide resolved

const getBuildingUrl = (building: string) =>
`https://utdirect.utexas.edu/apps/campus/buildings/nlogon/maps/UTM/${building}`;
Expand Down
8 changes: 5 additions & 3 deletions src/views/hooks/useFlattenedCourseSchedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ function extractCourseInfo(course: Course) {

let courseDeptAndInstr = `${course.department} ${course.number}`;

const mainInstructor = course.instructors[0];
if (mainInstructor) {
courseDeptAndInstr += ` – ${mainInstructor.toString({ format: 'first_last', case: 'capitalize' })}`;
if (course.instructors.length > 0) {
courseDeptAndInstr += ' \u2013 ';
courseDeptAndInstr += course.instructors
.map(instructor => instructor.toString({ format: 'last', case: 'capitalize' }))
.join('; ');
}

return { status, courseDeptAndInstr, meetings, course };
Expand Down
Loading