fix(ui): multiple instructors are formatted properly, displays last name only, and are capitalized in all course blocks (#342) (#403)
* fix(ui): updated multiple instructor name formatting in course blocks * fix(ui): display instructor last names only in all course blocks * refactor: use instructor toString when getting instructor full name * refactor: toString in useFlattenedCourseSchedule without template literal Co-authored-by: Samuel Gunter <29130894+Samathingamajig@users.noreply.github.com> * refactor: delete type hint and unnecessary comments * fix(ui): instructor names semicolon delimiter in calendar course block * fix(ui): removed 'unknown' when there are no instructors * fix(ui): change - to &ndash * fix(ui): changed - to ndash in hook --------- Co-authored-by: Samuel Gunter <29130894+Samathingamajig@users.noreply.github.com>
This commit is contained in:
@@ -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} –{' '}
|
||||
{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 ? <> – </> : ''}
|
||||
{course.instructors.map(v => v.toString({ format: 'last', case: 'capitalize' })).join('; ')}
|
||||
</Text>
|
||||
{enableCourseStatusChips && course.status !== Status.OPEN && (
|
||||
<div
|
||||
|
||||
@@ -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' });
|
||||
|
||||
const getBuildingUrl = (building: string) =>
|
||||
`https://utdirect.utexas.edu/apps/campus/buildings/nlogon/maps/UTM/${building}`;
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user