Squashed commit of the following:
commitc46e4a51c9Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Mon Feb 19 21:37:46 2024 -0600 change from reducer pattern to state variables, remove chartData from state commit36bcdd2522Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Mon Feb 19 21:15:41 2024 -0600 change grade distribution colors to match updated figma commit11a50df88dMerge:c16b301b4c96a9Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Mon Feb 19 17:57:13 2024 -0600 Merge branch 'hackathon' into abhinavchadaga/course-catalog-popup commitc16b301ff0Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Mon Feb 19 17:47:21 2024 -0600 Kinda complete the handlers commit1ac1d9095aAuthor: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sun Feb 18 17:36:59 2024 -0600 Bunch of renaming commit925829ad41Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sun Feb 18 17:24:53 2024 -0600 Fix syllabi url Remove unused variable and unnecessary args to url commitf2e5d51eb3Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sun Feb 18 17:24:22 2024 -0600 Add TODO replace current grade colors with a tailwind palette commit747ee44440Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sun Feb 18 01:26:51 2024 -0600 Minor tweaks change style in header commitddfe952a32Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sun Feb 18 01:26:38 2024 -0600 Add Grade Distribution Stuff commitc27bf3c390Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sun Feb 18 01:26:13 2024 -0600 Modify story to use proper course info commit7afdbac1b8Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sat Feb 17 16:37:01 2024 -0600 description stuff done commit1a89432276Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sat Feb 17 15:26:32 2024 -0600 Rename CoursePopup Old one to "Old", remove "2" from new one commit4c2b31e61aAuthor: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sat Feb 17 15:23:01 2024 -0600 add todo for calendar button commit11b7a51dedAuthor: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sat Feb 17 15:22:18 2024 -0600 add course button onclick handlers commitf2dfcec838Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sat Feb 17 14:52:38 2024 -0600 some unocss updates commitf9f375514bAuthor: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sat Feb 17 13:00:46 2024 -0600 Add rmp callback commit122fc6dbddAuthor: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sat Feb 17 13:00:16 2024 -0600 Change test course to 314 commit19b124b3bdAuthor: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sat Feb 17 12:19:21 2024 -0600 complete CourseHeaderAndActions Component added course buttons, using proper subcomponents now. commit2eea01fc74Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sat Feb 17 11:22:12 2024 -0600 use chip component in header commit9cb13c8fd1Merge:a62b7189392085Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sat Feb 17 11:21:12 2024 -0600 Merge branch 'hackathon' into abhinavchadaga/course-catalog-popup commita62b718c43Merge:43d26757b7b858Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sat Feb 17 10:57:24 2024 -0600 Merge branch 'hackathon' into abhinavchadaga/course-catalog-popup commit43d2675be5Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Sat Feb 17 10:54:49 2024 -0600 some work on course popup update the stories and create the header component commit31bcef3099Merge:874f8d5fa1d737Author: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Wed Feb 14 14:33:16 2024 -0600 Merge branch 'main' into abhinavchadaga/course-catalog-popup pulling from main commit874f8d56cbAuthor: Abhinav Chadaga <abhinav.chadaga@utexas.edu> Date: Wed Feb 14 14:30:24 2024 -0600 some work
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
import { Button } from '@views/components/common/Button/Button';
|
||||
import { Chip, flagMap } from '@views/components/common/Chip/Chip';
|
||||
import Divider from '@views/components/common/Divider/Divider';
|
||||
import Text from '@views/components/common/Text/Text';
|
||||
import React from 'react';
|
||||
import addCourse from 'src/pages/background/lib/addCourse';
|
||||
import openNewTab from 'src/pages/background/util/openNewTab';
|
||||
import { Course } from 'src/shared/types/Course';
|
||||
import { UserSchedule } from 'src/shared/types/UserSchedule';
|
||||
import Add from '~icons/material-symbols/add';
|
||||
import CalendarMonth from '~icons/material-symbols/calendar-month';
|
||||
import CloseIcon from '~icons/material-symbols/close';
|
||||
import Copy from '~icons/material-symbols/content-copy';
|
||||
import Description from '~icons/material-symbols/description';
|
||||
import Mood from '~icons/material-symbols/mood';
|
||||
import Reviews from '~icons/material-symbols/reviews';
|
||||
|
||||
interface HeadingAndActionProps {
|
||||
/* The course to display */
|
||||
course: Course;
|
||||
/* The active schedule */
|
||||
activeSchedule: UserSchedule;
|
||||
/* The function to call when the popup should be closed */
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the heading component for the CoursePopup component.
|
||||
*
|
||||
* @param {HeadingAndActionProps} props - The component props.
|
||||
* @returns {JSX.Element} The rendered component.
|
||||
*/
|
||||
const HeadingAndActions: React.FC<HeadingAndActionProps> = ({ course, onClose, activeSchedule }) => {
|
||||
const { courseName, department, number: courseNumber, uniqueId, instructors, flags, schedule } = course;
|
||||
const instructorString = instructors
|
||||
.map(instructor => {
|
||||
const { firstName, lastName } = instructor;
|
||||
if (firstName === '') return lastName;
|
||||
return `${firstName} ${lastName}`;
|
||||
})
|
||||
.join(', ');
|
||||
const handleCopy = () => {
|
||||
navigator.clipboard.writeText(uniqueId.toString());
|
||||
};
|
||||
const handleOpenCalendar = async () => {
|
||||
const url = chrome.runtime.getURL('calendar.html');
|
||||
await openNewTab(url);
|
||||
};
|
||||
const handleOpenRateMyProf = async () => {
|
||||
const openTabs = instructors.map(instructor => {
|
||||
const { fullName } = instructor;
|
||||
const url = `https://www.ratemyprofessors.com/search/professors/1255?q=${fullName}`;
|
||||
return openNewTab(url);
|
||||
});
|
||||
await Promise.all(openTabs);
|
||||
};
|
||||
const handleOpenCES = async () => {
|
||||
// TODO: does not look up the professor just takes you to the page
|
||||
const cisUrl = 'https://utexas.bluera.com/utexas/rpvl.aspx?rid=d3db767b-049f-46c5-9a67-29c21c29c580®l=en-US';
|
||||
await openNewTab(cisUrl);
|
||||
};
|
||||
const handleOpenPastSyllabi = async () => {
|
||||
// not specific to professor
|
||||
const url = `https://utdirect.utexas.edu/apps/student/coursedocs/nlogon/?year=&semester=&department=${department}&course_number=${courseNumber}&course_title=${courseName}&unique=&instructor_first=&instructor_last=&course_type=In+Residence&search=Search`;
|
||||
await openNewTab(url);
|
||||
};
|
||||
const handleAddCourse = async () => {
|
||||
await addCourse(activeSchedule.name, course);
|
||||
};
|
||||
return (
|
||||
<div className='w-full pb-3 pt-6'>
|
||||
<div className='flex flex-col gap-1'>
|
||||
<div className='flex items-center gap-1'>
|
||||
<Text variant='h1' className='truncate'>
|
||||
{courseName}
|
||||
</Text>
|
||||
<Text variant='h1' className='flex-1 whitespace-nowrap'>
|
||||
{' '}
|
||||
({department} {courseNumber})
|
||||
</Text>
|
||||
<Button color='ut-burntorange' variant='single' icon={Copy} onClick={handleCopy}>
|
||||
{uniqueId}
|
||||
</Button>
|
||||
<button className='btn bg-transparent p-0' onClick={onClose}>
|
||||
<CloseIcon className='h-7 w-7' />
|
||||
</button>
|
||||
</div>
|
||||
<div className='flex gap-2.5 flex-content-center'>
|
||||
<Text variant='h4' className='inline-flex items-center justify-center'>
|
||||
with {instructorString}
|
||||
</Text>
|
||||
<div className='flex-content-centr flex gap-1'>
|
||||
{flags.map(flag => (
|
||||
<Chip label={flagMap[flag]} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex flex-col'>
|
||||
{schedule.meetings.map(meeting => (
|
||||
<Text variant='h4'>
|
||||
{meeting.getDaysString({ format: 'long', separator: 'long' })}{' '}
|
||||
{meeting.getTimeString({ separator: ' to ', capitalize: false })}
|
||||
{meeting.location && (
|
||||
<>
|
||||
{` in `}
|
||||
<Text variant='h4' className='text-ut-burntorange underline'>
|
||||
{meeting.location.building}
|
||||
</Text>
|
||||
</>
|
||||
)}
|
||||
</Text>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className='my-3 flex flex-wrap items-center gap-[15px]'>
|
||||
<Button variant='filled' color='ut-burntorange' icon={CalendarMonth} onClick={handleOpenCalendar} />
|
||||
<Divider type='solid' color='ut-offwhite' className='h-7' />
|
||||
<Button variant='outline' color='ut-blue' icon={Reviews} onClick={handleOpenRateMyProf}>
|
||||
RateMyProf
|
||||
</Button>
|
||||
<Button variant='outline' color='ut-teal' icon={Mood} onClick={handleOpenCES}>
|
||||
CES
|
||||
</Button>
|
||||
<Button variant='outline' color='ut-orange' icon={Description} onClick={handleOpenPastSyllabi}>
|
||||
Past Syllabi
|
||||
</Button>
|
||||
<Button variant='filled' color='ut-green' icon={Add} onClick={handleAddCourse}>
|
||||
Add Course
|
||||
</Button>
|
||||
</div>
|
||||
<Divider />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default HeadingAndActions;
|
||||
Reference in New Issue
Block a user