From 5653bf8485d9f0b5b4a17e25651ebab928c83cef Mon Sep 17 00:00:00 2001 From: Kevin Wu Date: Sun, 22 Dec 2024 02:17:38 -0800 Subject: [PATCH] refactor: move code around --- .../{ => CourseInfo}/CourseInfoBar.tsx | 11 +++----- .../{ => CourseInfo}/CourseInfoButton.tsx | 25 ++++++------------- .../RightPane/SectionTable/SectionTable.tsx | 9 +++---- 3 files changed, 16 insertions(+), 29 deletions(-) rename apps/antalmanac/src/components/RightPane/SectionTable/{ => CourseInfo}/CourseInfoBar.tsx (97%) rename apps/antalmanac/src/components/RightPane/SectionTable/{ => CourseInfo}/CourseInfoButton.tsx (90%) diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfoBar.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfo/CourseInfoBar.tsx similarity index 97% rename from apps/antalmanac/src/components/RightPane/SectionTable/CourseInfoBar.tsx rename to apps/antalmanac/src/components/RightPane/SectionTable/CourseInfo/CourseInfoBar.tsx index e42625fd1..28adcb083 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfoBar.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfo/CourseInfoBar.tsx @@ -6,12 +6,11 @@ import { Skeleton } from '@material-ui/lab'; import type { PrerequisiteTree } from '@packages/antalmanac-types'; import { useState } from 'react'; -import { MOBILE_BREAKPOINT } from '../../../globals'; - -import PrereqTree from './PrereqTree'; +import { MOBILE_BREAKPOINT } from '../../../../globals'; import analyticsEnum, { logAnalytics } from '$lib/analytics'; import trpc from '$lib/api/trpc'; +import PrereqTree from '$components/RightPane/SectionTable/PrereqTree'; const styles = () => ({ rightSpace: { @@ -67,7 +66,7 @@ export interface CourseInfo { ge_list: string; } -const CourseInfoBar = (props: CourseInfoBarProps) => { +export const CourseInfoBar = withStyles(styles)((props: CourseInfoBarProps) => { const { courseTitle, courseNumber, deptCode, prerequisiteLink, classes, analyticsCategory } = props; const [anchorEl, setAnchorEl] = useState(null); @@ -208,6 +207,4 @@ const CourseInfoBar = (props: CourseInfoBarProps) => { ); -}; - -export default withStyles(styles)(CourseInfoBar); +}); diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfoButton.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfo/CourseInfoButton.tsx similarity index 90% rename from apps/antalmanac/src/components/RightPane/SectionTable/CourseInfoButton.tsx rename to apps/antalmanac/src/components/RightPane/SectionTable/CourseInfo/CourseInfoButton.tsx index 0a9e2d9a2..580e857e4 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfoButton.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/CourseInfo/CourseInfoButton.tsx @@ -1,21 +1,11 @@ import { Button, Paper, Popper } from '@material-ui/core'; -import { withStyles } from '@material-ui/core/styles'; -import { ClassNameMap } from '@material-ui/core/styles/withStyles'; import { useMediaQuery, useTheme } from '@mui/material'; import { useEffect, useState } from 'react'; import { logAnalytics } from '$lib/analytics'; import { useScheduleManagementStore } from '$stores/ScheduleManagementStore'; -const styles = { - button: { - backgroundColor: '#385EB1', - color: '#fff', - }, -}; - interface CourseInfoButtonProps { - classes: ClassNameMap; text: string; icon: React.ReactElement; redirectLink?: string; @@ -24,15 +14,14 @@ interface CourseInfoButtonProps { analyticsCategory: string; } -function CourseInfoButton({ - classes, +export const CourseInfoButton = ({ text, icon, redirectLink, popupContent, analyticsAction, analyticsCategory, -}: CourseInfoButtonProps) { +}: CourseInfoButtonProps) => { const theme = useTheme(); const isMobileScreen = useMediaQuery(theme.breakpoints.down('sm')); @@ -74,9 +63,9 @@ function CourseInfoButton({ return (
); -} - -export default withStyles(styles)(CourseInfoButton); +}; diff --git a/apps/antalmanac/src/components/RightPane/SectionTable/SectionTable.tsx b/apps/antalmanac/src/components/RightPane/SectionTable/SectionTable.tsx index 026440098..d2b7459e2 100644 --- a/apps/antalmanac/src/components/RightPane/SectionTable/SectionTable.tsx +++ b/apps/antalmanac/src/components/RightPane/SectionTable/SectionTable.tsx @@ -10,13 +10,11 @@ import { Typography, useMediaQuery, } from '@material-ui/core'; -import { Assessment, Help, RateReview, ShowChart as ShowChartIcon } from '@material-ui/icons'; +import { Assessment, Help, RateReview, Search, ShowChart as ShowChartIcon } from '@material-ui/icons'; import { useMemo } from 'react'; import { MOBILE_BREAKPOINT } from '../../../globals'; -import CourseInfoBar from './CourseInfoBar'; -import CourseInfoButton from './CourseInfoButton'; import { EnrollmentHistoryPopup } from './EnrollmentHistoryPopup'; import GradesPopup from './GradesPopup'; import { SectionTableProps } from './SectionTable.types'; @@ -24,6 +22,8 @@ import { SectionTableProps } from './SectionTable.types'; import { SectionTableBody } from '$components/RightPane/SectionTable/SectionTableBody/SectionTableBody'; import analyticsEnum from '$lib/analytics'; import { useColumnStore, SECTION_TABLE_COLUMNS, type SectionTableColumn } from '$stores/ColumnStore'; +import { CourseInfoButton } from '$components/RightPane/SectionTable/CourseInfo/CourseInfoButton'; +import { CourseInfoBar } from '$components/RightPane/SectionTable/CourseInfo/CourseInfoBar'; const TOTAL_NUM_COLUMNS = SECTION_TABLE_COLUMNS.length; @@ -135,8 +135,7 @@ function SectionTable(props: SectionTableProps) { analyticsCategory={analyticsCategory} /> - {/* Temporarily remove "Past Enrollment" until data on Anteater API */} - {/* */} + } />