Skip to content

Commit

Permalink
Merge branch 'main' into derek/backupScheduleFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
doprz authored Nov 21, 2024
2 parents 98c0d22 + 8b92208 commit a77f46b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 56 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
![Downloads](https://img.shields.io/chrome-web-store/d/hboadpjkoaieogjimneceaahlppnipaa)
![License](https://img.shields.io/github/license/Longhorn-Developers/UT-Registration-Plus)

**UT Registration Plus (UTRP)** streamlines the process of registering for classes at UT Austin by reducing the chaos of juggling multiple tabs like Rate My Professor, Google Sheets, and the UT Course Schedule. With UTRP, you can simplify class selection and schedule management. We've all been there. 20 tabs of Rate My Professor, Google Spreadsheet, and the UT Course Schedule open and you still don't know what classes to take. UT Registration Plus (UTRP), tries to streamline most of the unnecessary steps and headaches of registering for classes at UT Austin.
**UT Registration Plus (UTRP)** streamlines the process of registering for classes at UT Austin by reducing the chaos of juggling multiple tabs like Rate My Professor, Google Sheets, and the UT Course Schedule. With UTRP, you can simplify class selection and schedule management. We've all been there. 20 tabs of Rate My Professor, Google Spreadsheet, and the UT Course Schedule open and you still don't know what classes to take.

## Demo

Expand Down
75 changes: 28 additions & 47 deletions src/shared/types/Instructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,6 @@ export default class Instructor {
});
}

/**
* Get the URL to the instructor's directory page on the UT Directory website
*
* @returns A URL string to the instructor's directory page
*/
getDirectoryUrl(): string {
const name = this.toString({
format: 'full_name',
case: 'capitalize',
});

const url = new URL('https://directory.utexas.edu/index.php');
url.searchParams.set('q', name);
url.searchParams.set('scope', 'faculty/staff');
url.searchParams.set('submit', 'Search');

return url.toString();
}

/**
* Get a string representation of the instructor
*
Expand All @@ -43,32 +24,36 @@ export default class Instructor {
*/
toString(options: InstructorFormatOptions): string {
const { firstName, lastName, fullName } = this;
const { format, case: caseType } = options;
const { format } = options;

const process = (str: string) => {
if (caseType === 'lowercase') {
return str.toLowerCase();
}
if (caseType === 'uppercase') {
return str.toUpperCase();
}
return capitalize(str);
};
switch (format) {
case 'first_last':
if (firstName && lastName) {
return `${capitalize(firstName)} ${capitalize(lastName)}`;
}

if (format === 'abbr' && firstName && lastName && firstName[0]) {
return `${process(firstName[0])}. ${process(lastName)}`;
}
if (format === 'full_name' && fullName) {
return process(fullName);
}
if (format === 'first_last' && firstName && lastName) {
return `${process(firstName)} ${process(lastName)}`;
}
if (format === 'last' && lastName) {
return process(lastName);
}
if (lastName) {
return capitalize(lastName);
}

if (fullName) {
return fullName;
}

return '';
case 'last':
if (lastName) {
return capitalize(lastName);
}

throw new Error(`Invalid Instructor String format: ${format}`);
if (fullName) {
return fullName;
}

return '';
default:
throw new Error(`Invalid Instructor String format: ${format}`);
}
}
}

Expand All @@ -77,9 +62,5 @@ export default class Instructor {
*/
type InstructorFormatOptions = {
/** How do you want the names of the professors formatted */
format: 'abbr' | 'first_last' | 'last' | 'full_name';
/**
* What the case of the string should be
*/
case: 'capitalize' | 'lowercase' | 'uppercase';
format: 'first_last' | 'last';
};
2 changes: 1 addition & 1 deletion src/views/components/common/PopupCourseBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function PopupCourseBlock({
<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 ? <> &ndash; </> : ''}
{course.instructors.map(v => v.toString({ format: 'last', case: 'capitalize' })).join('; ')}
{course.instructors.map(v => v.toString({ format: 'last' })).join('; ')}
</Text>
{enableCourseStatusChips && course.status !== Status.OPEN && (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default function GradeDistribution({ course }: GradeDistributionProps): J
},
categories: ['A', 'A-', 'B+', 'B', 'B-', 'C+', 'C', 'C-', 'D+', 'D', 'D-', 'F', 'Other'],
tickInterval: 1,
tickWidth: 1.5,
tickWidth: 1,
tickLength: 10,
tickColor: '#9CADB7',
crosshair: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export default function HeadingAndActions({ course, activeSchedule, onClose }: H
const formattedUniqueId = uniqueId.toString().padStart(5, '0');
const isInCalendar = useCalendar();

const getInstructorFullName = (instructor: Instructor) =>
instructor.toString({ format: 'first_last', case: 'capitalize' });
const getInstructorFullName = (instructor: Instructor) => instructor.toString({ format: 'first_last' });

const handleCopy = () => {
navigator.clipboard.writeText(formattedUniqueId);
Expand Down
4 changes: 1 addition & 3 deletions src/views/hooks/useFlattenedCourseSchedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ function extractCourseInfo(course: Course) {

if (course.instructors.length > 0) {
courseDeptAndInstr += ' \u2013 ';
courseDeptAndInstr += course.instructors
.map(instructor => instructor.toString({ format: 'last', case: 'capitalize' }))
.join('; ');
courseDeptAndInstr += course.instructors.map(instructor => instructor.toString({ format: 'last' })).join('; ');
}

return { status, courseDeptAndInstr, meetings, course };
Expand Down
2 changes: 1 addition & 1 deletion unocss.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineConfig({
rules: [
[
'btn-transition',
{ transition: 'color 180ms, border-color 150ms, background-color 150ms, box-shadow 50ms, transform 50ms' },
{ transition: 'color 180ms ease-in, border-color 150ms ease-in, background-color 150ms ease-in, box-shadow 200ms ease-in, transform 50ms ease-in' }
],
[
'ring-offset-0',
Expand Down

0 comments on commit a77f46b

Please sign in to comment.