feat: popout icon for ccip in calendar (#221)

* feat: popout icon for ccip in calendar

* refactor: simplify context

---------

Co-authored-by: Razboy20 <razboy20@gmail.com>
This commit is contained in:
Samuel Gunter
2024-05-21 08:50:31 -07:00
committed by GitHub
parent a2303ee35f
commit 6812d685d0
3 changed files with 57 additions and 32 deletions

View File

@@ -7,6 +7,7 @@ import { Chip, flagMap } from '@views/components/common/Chip';
import Divider from '@views/components/common/Divider';
import Link from '@views/components/common/Link';
import Text from '@views/components/common/Text/Text';
import { useCalendar } from '@views/contexts/CalendarContext';
import React from 'react';
import Add from '~icons/material-symbols/add';
@@ -15,6 +16,7 @@ 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 OpenNewIcon from '~icons/material-symbols/open-in-new';
import Remove from '~icons/material-symbols/remove';
import Reviews from '~icons/material-symbols/reviews';
@@ -50,6 +52,7 @@ export default function HeadingAndActions({ course, activeSchedule, onClose }: H
const { courseName, department, number: courseNumber, uniqueId, instructors, flags, schedule } = course;
const courseAdded = activeSchedule.courses.some(ourCourse => ourCourse.uniqueId === uniqueId);
const formattedUniqueId = uniqueId.toString().padStart(5, '0');
const isInCalendar = useCalendar();
const getInstructorFullName = (instructor: Instructor) => {
const { firstName = '', lastName = '' } = instructor;
@@ -179,8 +182,16 @@ export default function HeadingAndActions({ course, activeSchedule, onClose }: H
<Button
variant='filled'
color='ut-burntorange'
icon={CalendarMonth}
onClick={() => background.switchToCalendarTab({})}
icon={isInCalendar ? OpenNewIcon : CalendarMonth}
onClick={() => {
if (isInCalendar) {
openNewTab({
url: course.url,
});
} else {
background.switchToCalendarTab({});
}
}}
/>
<Divider size='1.75rem' orientation='vertical' />
<Button variant='outline' color='ut-blue' icon={Reviews} onClick={handleOpenRateMyProf}>