From 01acc80939d4737b1831030fe934a663ea369e6a Mon Sep 17 00:00:00 2001 From: NishilJ <78994772+NishilJ@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:44:52 -0500 Subject: [PATCH 01/37] Auto focus search bar on homepage --- src/components/common/SearchBar/searchBar.tsx | 3 +++ src/pages/index.tsx | 1 + 2 files changed, 4 insertions(+) diff --git a/src/components/common/SearchBar/searchBar.tsx b/src/components/common/SearchBar/searchBar.tsx index 5499fe80..39b1614e 100644 --- a/src/components/common/SearchBar/searchBar.tsx +++ b/src/components/common/SearchBar/searchBar.tsx @@ -18,6 +18,7 @@ interface SearchProps { onSelect?: (value: SearchQuery[]) => void; className?: string; input_className?: string; + autoFocus?: boolean; } /** @@ -32,6 +33,7 @@ const SearchBar = ({ onSelect, className, input_className, + autoFocus }: SearchProps) => { //what you can choose from const [options, setOptions] = useState([]); @@ -262,6 +264,7 @@ const SearchBar = ({ variant="outlined" className={input_className} placeholder="ex. GOVT 2306" + autoFocus={autoFocus} /> ); }} diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 750416d1..92b7364e 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -68,6 +68,7 @@ const Home: NextPage = () => { find the perfect class.

Date: Mon, 14 Oct 2024 20:51:28 -0500 Subject: [PATCH 02/37] Update README.md --- README.md | 49 +++++++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 4fcb2262..c9759816 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# UTD-Trends +# UTD Trends -_UTD-Trends a data visualization tool built to help students view historical course and section data using the Nebula API_ +_Easy access to all the information you need to plan your schedule_ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) @@ -8,31 +8,19 @@ _UTD-Trends a data visualization tool built to help students view historical cou ### Overview -UTD-Trends offers students and faculty an accessible and easily digestible means -of viewing the data stored in the Nebula API. This front-end for the API offers -data visualization tools so that students can view agregated data and make more informed -decisions on their coursework. - -### Inspiration - -For years the students of UTD have made use of the UTD Grades tool to access -information about their coursework in conjunction with other web applications like -Rate My Professor. - -Now Project Nebula hopes to offer students a comprehensive view of course information -all in a single application through Project UTD-Trends. The hope is to offer students an all -in one experience and streamline the data gathering experience of students while providing -better data gathered through UTD specific sources rather than the crowd sourcing of other sites. - -UTD-Trends hopes to offer more tooling to students than previously available and build upon the -successes of UTD Grades to enhance the student experience. +UTD Trends offers students and faculty an accessible and easily digestible means +of viewing the data stored in the Nebula API and on Rate My Professors. Providing +data visualization tools so that students can view agregated data and make more +informed decisions on their coursework. ### Features -- Data Visualizations for the Nebula API -- Easy searchability and result filtering -- Section comparison -- Multi-metric evaluations on course performance +- Multiple Sources + - Find grade distributions and Rate My Professors scores for any given class. +- Aggregate + - Powerful query abilities that aggregate grade and Rate My Professors data across several years to give you a more wholistic view. +- Compare + - See data for multiple courses, professors, and categories on a single graph without switching tabs. ## Contributing @@ -45,14 +33,11 @@ This project uses the MIT License. To get started, see the [contribution guide](./CONTRIBUTING.md). It'll tell you everything you need to know. -Additionally, see the Project Nebula-wide contributors [guide](https://about.utdnebula.com/) -for more info. - Once you're ready to make some changes, see the -[issues](https://github.com/UTDNebula/UTD-Trends/issues) for the repository. +[issues](https://github.com/UTDNebula/utd-trends/issues) for the repository. If you want to brainstorm, share ideas or ask questions, start a discussion in -the [Discussions](https://github.com/UTDNebula/UTD-Trends/discussions) section. +our [Discord](https://discord.utdnebula.com/) section. ### Set-up @@ -61,8 +46,8 @@ installation. To start, clone the repository, and then run `npm run dev` to laun a local development server at [`localhost:3000`](https://localhost:3000) by default. ```bash -git clone https://github.com/UTDNebula/UTD-Trends.git -cd UTD-Trends +git clone https://github.com/UTDNebula/utd-trends.git +cd utd-Trends npm install npm run dev ``` @@ -70,4 +55,4 @@ npm run dev ### Contact This project is maintained by Nebula Labs. If you have -any questions about this project or Nebula Labs, see the [discord server](https://discord.gg/3p4H44zjTt) +any questions about this project or Nebula Labs, see the [discord server](https://discord.utdnebula.com/) From 425711f3fe0f95e5024e7872bd36549158f90c86 Mon Sep 17 00:00:00 2001 From: RithwikChittineni Date: Sun, 20 Oct 2024 12:28:54 -0500 Subject: [PATCH 03/37] added tooltips --- .../common/CompareTable/compareTable.tsx | 85 ++++++++++--------- 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/src/components/common/CompareTable/compareTable.tsx b/src/components/common/CompareTable/compareTable.tsx index 587c70d1..3bd6f696 100644 --- a/src/components/common/CompareTable/compareTable.tsx +++ b/src/components/common/CompareTable/compareTable.tsx @@ -8,6 +8,7 @@ import { TableContainer, TableHead, TableRow, + Tooltip, Typography, } from '@mui/material'; import React, { useState } from 'react'; @@ -85,20 +86,24 @@ function GradeOrRmpRow({ return ( - { - handleClick(name); - }} - sx={{ - '& .MuiTableSortLabel-icon': { - rotate: '-90deg', - }, - }} - > - {name} - + + { + handleClick(name); + }} + sx={{ + '& .MuiTableSortLabel-icon': { + rotate: '-90deg', + }, + }} + > + {name} + + {values.map((value, index) => ( ({ )) || (value.state === 'done' && getValue(value.data) !== -1 && ( - - {/*value.data is all the data past the state of loading, done, or error. + + + {/*value.data is all the data past the state of loading, done, or error. getValue returns the specific value from the data structure, like gpa. formatValue makes it look pretty like 3.7216373 displaying as 3.72.*/} - {formatValue(getValue(value.data))} - + {formatValue(getValue(value.data))} + + )) || null} @@ -266,17 +273,19 @@ function CheckboxRow({ backgroundColor: colors[index] + '10', // add transparency }} > - { - removeFromCompare(course); - }} - sx={{ - '&.Mui-checked': { - color: colors[index], - }, - }} //Colored Checkbox based on graph - /> + + { + removeFromCompare(course); + }} + sx={{ + '&.Mui-checked': { + color: colors[index], + }, + }} //Colored Checkbox based on graph + /> + ))} From 6d998e07f239e5e9e7e928870229f02eee020d65 Mon Sep 17 00:00:00 2001 From: RithwikChittineni Date: Sun, 20 Oct 2024 12:31:03 -0500 Subject: [PATCH 04/37] added tooltips --- .../common/CompareTable/compareTable.tsx | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/components/common/CompareTable/compareTable.tsx b/src/components/common/CompareTable/compareTable.tsx index 3bd6f696..ab387a1c 100644 --- a/src/components/common/CompareTable/compareTable.tsx +++ b/src/components/common/CompareTable/compareTable.tsx @@ -86,24 +86,20 @@ function GradeOrRmpRow({ return ( - - { - handleClick(name); - }} - sx={{ - '& .MuiTableSortLabel-icon': { - rotate: '-90deg', - }, - }} - > - {name} - - + { + handleClick(name); + }} + sx={{ + '& .MuiTableSortLabel-icon': { + rotate: '-90deg', + }, + }} + > + {name} + {values.map((value, index) => ( ({ )) || (value.state === 'done' && getValue(value.data) !== -1 && ( - - - {/*value.data is all the data past the state of loading, done, or error. + + + + {/*value.data is all the data past the state of loading, done, or error. getValue returns the specific value from the data structure, like gpa. formatValue makes it look pretty like 3.7216373 displaying as 3.72.*/} - {formatValue(getValue(value.data))} - - + {formatValue(getValue(value.data))} + + + )) || null} @@ -277,14 +277,14 @@ function CheckboxRow({ { - removeFromCompare(course); - }} - sx={{ - '&.Mui-checked': { - color: colors[index], - }, - }} //Colored Checkbox based on graph - /> + removeFromCompare(course); + }} + sx={{ + '&.Mui-checked': { + color: colors[index], + }, + }} //Colored Checkbox based on graph + /> ))} From 655e8b2f5f1dc64e245321d206363f6ccd8b4b54 Mon Sep 17 00:00:00 2001 From: RithwikChittineni Date: Sun, 20 Oct 2024 12:32:50 -0500 Subject: [PATCH 05/37] ran format --- .../common/CompareTable/compareTable.tsx | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/src/components/common/CompareTable/compareTable.tsx b/src/components/common/CompareTable/compareTable.tsx index ab387a1c..c95877e2 100644 --- a/src/components/common/CompareTable/compareTable.tsx +++ b/src/components/common/CompareTable/compareTable.tsx @@ -120,27 +120,23 @@ function GradeOrRmpRow({ )) || (value.state === 'done' && getValue(value.data) !== -1 && ( - - - - {/*value.data is all the data past the state of loading, done, or error. + + + {/*value.data is all the data past the state of loading, done, or error. getValue returns the specific value from the data structure, like gpa. formatValue makes it look pretty like 3.7216373 displaying as 3.72.*/} - {formatValue(getValue(value.data))} - - - + {formatValue(getValue(value.data))} + + )) || null} @@ -277,14 +273,14 @@ function CheckboxRow({ { - removeFromCompare(course); - }} - sx={{ - '&.Mui-checked': { - color: colors[index], - }, - }} //Colored Checkbox based on graph - /> + removeFromCompare(course); + }} + sx={{ + '&.Mui-checked': { + color: colors[index], + }, + }} //Colored Checkbox based on graph + /> ))} From d9b841aeb695b6d38602f3b1d76462c10c73ed8d Mon Sep 17 00:00:00 2001 From: Shivhare-Ayush Date: Mon, 21 Oct 2024 20:52:27 -0500 Subject: [PATCH 06/37] Notification --- src/components/common/Carousel/carousel.tsx | 48 ++++++------------- .../navigation/tabNavMenu/tabNavMenu.tsx | 17 ++++++- src/pages/dashboard/index.tsx | 2 +- 3 files changed, 31 insertions(+), 36 deletions(-) diff --git a/src/components/common/Carousel/carousel.tsx b/src/components/common/Carousel/carousel.tsx index 8c2c9c70..bb5dee90 100644 --- a/src/components/common/Carousel/carousel.tsx +++ b/src/components/common/Carousel/carousel.tsx @@ -1,12 +1,12 @@ import { ReactJSXElement } from '@emotion/react/types/jsx-namespace'; import { AnimatePresence, motion } from 'framer-motion'; import React, { useState } from 'react'; - import { TabNavMenu } from '../../navigation/tabNavMenu/tabNavMenu'; interface CarouselProps { names: string[] | string; children: ReactJSXElement[] | ReactJSXElement; + compareLength: number; } /** @@ -16,8 +16,8 @@ interface CarouselProps { const variants = { enter: (dir: number) => { return { - x: dir > 0 ? 500 : -500, // velocity in x direction - opacity: 0, // child opacity + x: dir > 0 ? 500 : -500, //velocity in x direction + opacity: 0, //child opacity }; }, center: { @@ -38,19 +38,11 @@ const variants = { * @param props the props passed from the parent component * @returns */ -const Carousel = ({ names, children }: CarouselProps) => { - // The card currently being displayed - const [currentCard, setCurrentCard] = useState(0); - // The Direction that the card is moving in - const [direction, setDirection] = useState(0); - - /** - * On each re-render, ensure currentCard is within valid bounds - */ - if (Array.isArray(children) && currentCard >= children.length) { - // If currentCard is out of bounds, reset it to 0 - setCurrentCard(0); - } +export const Carousel = ({ names, children, compareLength }: CarouselProps) => { + //The card currently being displayed + const [currentCard, setCard] = useState(0); + //The Direction that the card is moving in + const [direction, setDir] = useState(0); /** * Turn @@ -58,14 +50,10 @@ const Carousel = ({ names, children }: CarouselProps) => { * @param displacement a positive value will cause the card to move right, negative value cause card to move left */ const turn = (displacement: number) => { - setDirection(displacement); - setCurrentCard((prevCard) => { - const newCard = prevCard + displacement; - if (Array.isArray(children)) { - return Math.max(0, Math.min(newCard, children.length - 1)); - } - return newCard; - }); + //set direction + // console.log("displacement=",displacement); + setDir(displacement); + setCard(currentCard + displacement); }; return ( @@ -74,6 +62,7 @@ const Carousel = ({ names, children }: CarouselProps) => { value={currentCard} options={Array.isArray(names) ? names : [names]} turner={turn} + compareLength={compareLength} />
@@ -89,16 +78,7 @@ const Carousel = ({ names, children }: CarouselProps) => { opacity: { duration: 0.2 }, }} > - {Array.isArray(children) - ? children.map((child, index) => ( -
- {child} -
- )) - : children} + {Array.isArray(children) ? children[currentCard] : children}
diff --git a/src/components/navigation/tabNavMenu/tabNavMenu.tsx b/src/components/navigation/tabNavMenu/tabNavMenu.tsx index f8e13b98..fcc926a2 100644 --- a/src/components/navigation/tabNavMenu/tabNavMenu.tsx +++ b/src/components/navigation/tabNavMenu/tabNavMenu.tsx @@ -1,5 +1,6 @@ import { Tab, Tabs } from '@mui/material'; import React from 'react'; +import { Badge } from '@mui/material'; /** * Props type used by the TabNavMenu component @@ -10,6 +11,7 @@ type TabNavMenuProps = { // responsible for playing the animation and setting the value to the correct new value turner: (displacement: number) => void; options: string[]; + compareLength: number; }; /** @@ -27,10 +29,23 @@ export const TabNavMenu = (props: TabNavMenuProps) => { > {props.options.map((option, index) => ( + {option} + + + ) : ( + option + ) + } /> ))} diff --git a/src/pages/dashboard/index.tsx b/src/pages/dashboard/index.tsx index 34095cde..1de6424f 100644 --- a/src/pages/dashboard/index.tsx +++ b/src/pages/dashboard/index.tsx @@ -749,7 +749,7 @@ export const Dashboard: NextPage = () => {
- {tabs} + {tabs}
From 8d69f2815fbf03148c0d51edbf7f7250786bb4f7 Mon Sep 17 00:00:00 2001 From: Shivhare-Ayush Date: Mon, 21 Oct 2024 20:57:53 -0500 Subject: [PATCH 07/37] lint --- src/pages/dashboard/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/dashboard/index.tsx b/src/pages/dashboard/index.tsx index 1de6424f..52311731 100644 --- a/src/pages/dashboard/index.tsx +++ b/src/pages/dashboard/index.tsx @@ -749,7 +749,9 @@ export const Dashboard: NextPage = () => {
- {tabs} + + {tabs} +
From 5ef57a7ca94aef8c5a78efd6542741af97bb9c72 Mon Sep 17 00:00:00 2001 From: Shivhare-Ayush Date: Mon, 21 Oct 2024 21:04:02 -0500 Subject: [PATCH 08/37] ESlint --- src/components/common/Carousel/carousel.tsx | 1 + src/components/navigation/tabNavMenu/tabNavMenu.tsx | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/common/Carousel/carousel.tsx b/src/components/common/Carousel/carousel.tsx index bb5dee90..587a4845 100644 --- a/src/components/common/Carousel/carousel.tsx +++ b/src/components/common/Carousel/carousel.tsx @@ -1,6 +1,7 @@ import { ReactJSXElement } from '@emotion/react/types/jsx-namespace'; import { AnimatePresence, motion } from 'framer-motion'; import React, { useState } from 'react'; + import { TabNavMenu } from '../../navigation/tabNavMenu/tabNavMenu'; interface CarouselProps { diff --git a/src/components/navigation/tabNavMenu/tabNavMenu.tsx b/src/components/navigation/tabNavMenu/tabNavMenu.tsx index fcc926a2..bb3249f7 100644 --- a/src/components/navigation/tabNavMenu/tabNavMenu.tsx +++ b/src/components/navigation/tabNavMenu/tabNavMenu.tsx @@ -1,6 +1,5 @@ -import { Tab, Tabs } from '@mui/material'; +import { Badge,Tab, Tabs } from '@mui/material'; import React from 'react'; -import { Badge } from '@mui/material'; /** * Props type used by the TabNavMenu component From 24db09ea2793122e07bcd7e72c20b407ba90bef6 Mon Sep 17 00:00:00 2001 From: Shivhare-Ayush Date: Mon, 21 Oct 2024 21:14:51 -0500 Subject: [PATCH 09/37] attempt3 --- src/components/navigation/tabNavMenu/tabNavMenu.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/navigation/tabNavMenu/tabNavMenu.tsx b/src/components/navigation/tabNavMenu/tabNavMenu.tsx index bb3249f7..cdb19e64 100644 --- a/src/components/navigation/tabNavMenu/tabNavMenu.tsx +++ b/src/components/navigation/tabNavMenu/tabNavMenu.tsx @@ -1,4 +1,4 @@ -import { Badge,Tab, Tabs } from '@mui/material'; +import { Badge, Tab, Tabs } from '@mui/material'; import React from 'react'; /** From 62eb8814eeae5e20e2ff829ce2c1df8e6a1fd3c1 Mon Sep 17 00:00:00 2001 From: NishilJ <78994772+NishilJ@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:19:59 -0500 Subject: [PATCH 10/37] linting fix --- src/components/common/SearchBar/searchBar.tsx | 1 + src/pages/index.tsx | 1 + 2 files changed, 2 insertions(+) diff --git a/src/components/common/SearchBar/searchBar.tsx b/src/components/common/SearchBar/searchBar.tsx index 39b1614e..59d6cf5d 100644 --- a/src/components/common/SearchBar/searchBar.tsx +++ b/src/components/common/SearchBar/searchBar.tsx @@ -264,6 +264,7 @@ const SearchBar = ({ variant="outlined" className={input_className} placeholder="ex. GOVT 2306" + //eslint-disable-next-line jsx-a11y/no-autofocus autoFocus={autoFocus} /> ); diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 92b7364e..a68c7957 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -68,6 +68,7 @@ const Home: NextPage = () => { find the perfect class.

Date: Sun, 27 Oct 2024 22:05:20 -0500 Subject: [PATCH 11/37] Add all course or professor sessions from RHS to academic sessions --- src/pages/dashboard/index.tsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/pages/dashboard/index.tsx b/src/pages/dashboard/index.tsx index 46da9a4b..166e8091 100644 --- a/src/pages/dashboard/index.tsx +++ b/src/pages/dashboard/index.tsx @@ -275,6 +275,26 @@ export const Dashboard: NextPage = () => { ); } }); + if ( + professorSearchTerms.length === 1 && + grades[searchQueryLabel(professorSearchTerms[0])] && + grades[searchQueryLabel(professorSearchTerms[0])].state === 'done' + ) { + const entry = grades[searchQueryLabel(professorSearchTerms[0])]; + if (entry && entry.state === 'done') { + addAcademicSessions(entry.data.grades.map((session) => session._id)); + } + } + if ( + courseSearchTerms.length === 1 && + grades[searchQueryLabel(courseSearchTerms[0])] && + grades[searchQueryLabel(courseSearchTerms[0])].state === 'done' + ) { + const entry = grades[searchQueryLabel(courseSearchTerms[0])]; + if (entry && entry.state === 'done') { + addAcademicSessions(entry.data.grades.map((session) => session._id)); + } + } //To cancel on rerender const controller = new AbortController(); From e4352840d37277da2dcd4cd7119944b189752aa6 Mon Sep 17 00:00:00 2001 From: NishilJ <78994772+NishilJ@users.noreply.github.com> Date: Mon, 28 Oct 2024 17:13:44 -0500 Subject: [PATCH 12/37] linting fix 2 --- src/components/common/SearchBar/searchBar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/common/SearchBar/searchBar.tsx b/src/components/common/SearchBar/searchBar.tsx index 59d6cf5d..5f6dc9ba 100644 --- a/src/components/common/SearchBar/searchBar.tsx +++ b/src/components/common/SearchBar/searchBar.tsx @@ -33,7 +33,7 @@ const SearchBar = ({ onSelect, className, input_className, - autoFocus + autoFocus, }: SearchProps) => { //what you can choose from const [options, setOptions] = useState([]); From 2031fde5a6be8a9022cdfaa6bc40be3746450a5a Mon Sep 17 00:00:00 2001 From: Tyler Hill Date: Tue, 29 Oct 2024 19:43:48 -0500 Subject: [PATCH 13/37] Set cursor pointer --- .../common/SearchResultsTable/searchResultsTable.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/common/SearchResultsTable/searchResultsTable.tsx b/src/components/common/SearchResultsTable/searchResultsTable.tsx index 87408690..c9041f67 100644 --- a/src/components/common/SearchResultsTable/searchResultsTable.tsx +++ b/src/components/common/SearchResultsTable/searchResultsTable.tsx @@ -117,6 +117,7 @@ function Row({ setOpen(!open)} // opens/closes the card by clicking anywhere on the row sx={{ '& > *': { borderBottom: 'unset' } }} + className="cursor-pointer" > - + {searchQueryLabel(course) + ((typeof course.profFirst === 'undefined' && typeof course.profLast === 'undefined') || From 3a763e9a2a63c825954971bef66b77d9e8516fc4 Mon Sep 17 00:00:00 2001 From: RithwikChittineni Date: Wed, 30 Oct 2024 11:41:30 -0500 Subject: [PATCH 14/37] added tooltips to sort buttons --- .../common/CompareTable/compareTable.tsx | 139 ++++++++++++------ 1 file changed, 92 insertions(+), 47 deletions(-) diff --git a/src/components/common/CompareTable/compareTable.tsx b/src/components/common/CompareTable/compareTable.tsx index c95877e2..32aff4d8 100644 --- a/src/components/common/CompareTable/compareTable.tsx +++ b/src/components/common/CompareTable/compareTable.tsx @@ -83,6 +83,12 @@ function GradeOrRmpRow({ handleClick, defaultAscSort, }: GradeOrRmpRowProps) { + const tooltipTitles: { [key: string]: string } = { + GPA: 'Sort by GPA', + Rating: 'Sort by Rating', + 'Would Take Again': 'Sort by Would Take Again %', + Difficulty: 'Sort by Difficulty', + }; return ( @@ -98,7 +104,13 @@ function GradeOrRmpRow({ }, }} > - {name} + {tooltipTitles[name] ? ( + + {name} + + ) : ( + name + )} {values.map((value, index) => ( @@ -120,7 +132,10 @@ function GradeOrRmpRow({ )) || (value.state === 'done' && getValue(value.data) !== -1 && ( - + - {name} + + {name} + {gradeValues - // combine values + // Combine values by mapping gradeValues and rmpValues together .map((x, i) => [x, rmpValues[i]]) - // so ts can remember the type of rmp (which it can't do for rmpValues[index]) and know's that when its state is done, you can access its data value - .map(([grade, rmp], index) => ( - - {((typeof grade === 'undefined' || grade.state === 'error') && ( - - )) || - (grade.state === 'loading' && ( - - {loadingFiller} - - )) || - (grade.state === 'done' && ( - - {getGradeValue(grade.data as GradesType)} - - )) || - null} - {' / '} - {((typeof rmp === 'undefined' || rmp.state === 'error') && ( - - )) || - (rmp.state === 'loading' && ( - - {loadingFiller} - - )) || - (rmp.state === 'done' && ( - - {getRmpValue(rmp.data as RMPInterface)} - - )) || - null} - - ))} + .map(([grade, rmp], index) => { + // Extract values if state is 'done' + const gradeValue = + grade.state === 'done' + ? getGradeValue(grade.data as GradesType) + : null; + const rmpValue = + rmp.state === 'done' ? getRmpValue(rmp.data as RMPInterface) : null; + + return ( + + + + {/* Displaying grade value */} + {((typeof grade === 'undefined' || + grade.state === 'error') && ) || + (grade.state === 'loading' && ( + + + {loadingFiller} + + + )) || + (grade.state === 'done' && ( + + {gradeValue} + + )) || + null} + {' / '} + {/* Displaying rmp value */} + {((typeof rmp === 'undefined' || rmp.state === 'error') && ( + + )) || + (rmp.state === 'loading' && ( + + + {loadingFiller} + + + )) || + (rmp.state === 'done' && ( + + {rmpValue} + + )) || + null} + + + + ); + })} ); } - type CheckboxRowProps = { name: string; courses: SearchQuery[]; @@ -448,6 +492,7 @@ const CompareTable = ({ order={order} handleClick={handleClick} /> + name="Rating" values={sortedResults.map( From a8ef494039d2a348a3306051c84ea8bb97e3ce2b Mon Sep 17 00:00:00 2001 From: RithwikChittineni Date: Wed, 30 Oct 2024 11:54:53 -0500 Subject: [PATCH 15/37] added back comments --- src/components/common/CompareTable/compareTable.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/common/CompareTable/compareTable.tsx b/src/components/common/CompareTable/compareTable.tsx index 32aff4d8..7e11262c 100644 --- a/src/components/common/CompareTable/compareTable.tsx +++ b/src/components/common/CompareTable/compareTable.tsx @@ -189,10 +189,10 @@ function GradeAndRmpRow({ {gradeValues - // Combine values by mapping gradeValues and rmpValues together + // Combine values .map((x, i) => [x, rmpValues[i]]) + // so ts can remember the type of rmp (which it can't do for rmpValues[index]) and know's that when its state is done, you can access its data value .map(([grade, rmp], index) => { - // Extract values if state is 'done' const gradeValue = grade.state === 'done' ? getGradeValue(grade.data as GradesType) @@ -211,12 +211,10 @@ function GradeAndRmpRow({ }} > - {/* Displaying grade value */} {((typeof grade === 'undefined' || grade.state === 'error') && ) || (grade.state === 'loading' && ( @@ -236,7 +234,6 @@ function GradeAndRmpRow({ )) || null} {' / '} - {/* Displaying rmp value */} {((typeof rmp === 'undefined' || rmp.state === 'error') && ( )) || From 0f566c610560dd5d4a25ea3fa35a99ff8040256d Mon Sep 17 00:00:00 2001 From: AbhiramTadepalli Date: Wed, 30 Oct 2024 16:39:57 -0500 Subject: [PATCH 16/37] align Letter Grades in LHS result table --- src/components/common/SearchResultsTable/searchResultsTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/common/SearchResultsTable/searchResultsTable.tsx b/src/components/common/SearchResultsTable/searchResultsTable.tsx index 87408690..d99e171c 100644 --- a/src/components/common/SearchResultsTable/searchResultsTable.tsx +++ b/src/components/common/SearchResultsTable/searchResultsTable.tsx @@ -187,7 +187,7 @@ function Row({ placement="top" > {gpaToLetterGrade(grades.data.gpa)} From bdd2e83b1bd0df738ef32818427fcb0096c54f7d Mon Sep 17 00:00:00 2001 From: AbhiramTadepalli Date: Wed, 30 Oct 2024 19:56:26 -0500 Subject: [PATCH 17/37] Center-align ratings and Grade column headers --- .../common/SearchResultsTable/searchResultsTable.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/common/SearchResultsTable/searchResultsTable.tsx b/src/components/common/SearchResultsTable/searchResultsTable.tsx index d99e171c..27a01a61 100644 --- a/src/components/common/SearchResultsTable/searchResultsTable.tsx +++ b/src/components/common/SearchResultsTable/searchResultsTable.tsx @@ -438,7 +438,7 @@ const SearchResultsTable = ({ Name - + - + Date: Wed, 30 Oct 2024 23:28:01 -0500 Subject: [PATCH 18/37] changed tooltip titles and positoning for sort by rows --- .../common/CompareTable/compareTable.tsx | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/components/common/CompareTable/compareTable.tsx b/src/components/common/CompareTable/compareTable.tsx index 7e11262c..45633bcb 100644 --- a/src/components/common/CompareTable/compareTable.tsx +++ b/src/components/common/CompareTable/compareTable.tsx @@ -105,7 +105,20 @@ function GradeOrRmpRow({ }} > {tooltipTitles[name] ? ( - + {name} ) : ( @@ -184,7 +197,20 @@ function GradeAndRmpRow({ return ( - + {name} From dbaa975a4172aa6bec56c3b8b7c207a66e8f5bc3 Mon Sep 17 00:00:00 2001 From: Tyler Hill Date: Thu, 31 Oct 2024 12:13:28 -0500 Subject: [PATCH 19/37] Stop propagation on text --- .../SearchResultsTable/searchResultsTable.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/common/SearchResultsTable/searchResultsTable.tsx b/src/components/common/SearchResultsTable/searchResultsTable.tsx index c9041f67..6cc86f5c 100644 --- a/src/components/common/SearchResultsTable/searchResultsTable.tsx +++ b/src/components/common/SearchResultsTable/searchResultsTable.tsx @@ -134,18 +134,15 @@ function Row({ - e.stopPropagation() // prevents opening/closing the card when clicking on the compare checkbox - } - > + { + onClick={(e) => { + e.stopPropagation(); // prevents opening/closing the card when clicking on the compare checkbox if (inCompare) { removeFromCompare(course); } else { @@ -160,7 +157,12 @@ function Row({ - + e.stopPropagation() // prevents opening/closing the card when clicking on the text + } + className="leading-tight text-lg text-gray-600 dark:text-gray-200 cursor-text" + > {searchQueryLabel(course) + ((typeof course.profFirst === 'undefined' && typeof course.profLast === 'undefined') || From e700815d0b862a1d31c9a2e83a42bc48cf12adeb Mon Sep 17 00:00:00 2001 From: AbhiramTadepalli Date: Fri, 1 Nov 2024 07:28:02 -0500 Subject: [PATCH 20/37] Add a undefined check when adding result to compare that doesn't have either a grade distribution or rmp data --- src/components/common/CompareTable/compareTable.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/common/CompareTable/compareTable.tsx b/src/components/common/CompareTable/compareTable.tsx index 45633bcb..f05707bf 100644 --- a/src/components/common/CompareTable/compareTable.tsx +++ b/src/components/common/CompareTable/compareTable.tsx @@ -220,11 +220,13 @@ function GradeAndRmpRow({ // so ts can remember the type of rmp (which it can't do for rmpValues[index]) and know's that when its state is done, you can access its data value .map(([grade, rmp], index) => { const gradeValue = - grade.state === 'done' + typeof grade !== 'undefined' && grade.state === 'done' ? getGradeValue(grade.data as GradesType) : null; const rmpValue = - rmp.state === 'done' ? getRmpValue(rmp.data as RMPInterface) : null; + typeof rmp !== 'undefined' && rmp.state === 'done' + ? getRmpValue(rmp.data as RMPInterface) + : null; return ( Date: Fri, 1 Nov 2024 20:45:13 -0500 Subject: [PATCH 21/37] Merge in changes kinda --- src/components/common/Carousel/carousel.tsx | 43 +++++++++++++++------ 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/src/components/common/Carousel/carousel.tsx b/src/components/common/Carousel/carousel.tsx index 587a4845..1a9cbb45 100644 --- a/src/components/common/Carousel/carousel.tsx +++ b/src/components/common/Carousel/carousel.tsx @@ -17,8 +17,8 @@ interface CarouselProps { const variants = { enter: (dir: number) => { return { - x: dir > 0 ? 500 : -500, //velocity in x direction - opacity: 0, //child opacity + x: dir > 0 ? 500 : -500, // velocity in x direction + opacity: 0, // child opacity }; }, center: { @@ -40,10 +40,18 @@ const variants = { * @returns */ export const Carousel = ({ names, children, compareLength }: CarouselProps) => { - //The card currently being displayed - const [currentCard, setCard] = useState(0); - //The Direction that the card is moving in - const [direction, setDir] = useState(0); + // The card currently being displayed + const [currentCard, setCurrentCard] = useState(0); + // The Direction that the card is moving in + const [direction, setDirection] = useState(0); + + /** + * On each re-render, ensure currentCard is within valid bounds + */ + if (Array.isArray(children) && currentCard >= children.length) { + // If currentCard is out of bounds, reset it to 0 + setCurrentCard(0); + } /** * Turn @@ -51,10 +59,14 @@ export const Carousel = ({ names, children, compareLength }: CarouselProps) => { * @param displacement a positive value will cause the card to move right, negative value cause card to move left */ const turn = (displacement: number) => { - //set direction - // console.log("displacement=",displacement); - setDir(displacement); - setCard(currentCard + displacement); + setDirection(displacement); + setCurrentCard((prevCard) => { + const newCard = prevCard + displacement; + if (Array.isArray(children)) { + return Math.max(0, Math.min(newCard, children.length - 1)); + } + return newCard; + }); }; return ( @@ -79,7 +91,16 @@ export const Carousel = ({ names, children, compareLength }: CarouselProps) => { opacity: { duration: 0.2 }, }} > - {Array.isArray(children) ? children[currentCard] : children} + {Array.isArray(children) + ? children.map((child, index) => ( +
+ {child} +
+ )) + : children} From e134888e5e40ad00f83d240a53cddb95fecb0cab Mon Sep 17 00:00:00 2001 From: Tyler Hill Date: Fri, 1 Nov 2024 20:56:12 -0500 Subject: [PATCH 22/37] one more change --- src/components/common/Carousel/carousel.tsx | 2 +- src/components/navigation/tabNavMenu/tabNavMenu.tsx | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/components/common/Carousel/carousel.tsx b/src/components/common/Carousel/carousel.tsx index 1a9cbb45..0b1401d6 100644 --- a/src/components/common/Carousel/carousel.tsx +++ b/src/components/common/Carousel/carousel.tsx @@ -39,7 +39,7 @@ const variants = { * @param props the props passed from the parent component * @returns */ -export const Carousel = ({ names, children, compareLength }: CarouselProps) => { +const Carousel = ({ names, children, compareLength }: CarouselProps) => { // The card currently being displayed const [currentCard, setCurrentCard] = useState(0); // The Direction that the card is moving in diff --git a/src/components/navigation/tabNavMenu/tabNavMenu.tsx b/src/components/navigation/tabNavMenu/tabNavMenu.tsx index cdb19e64..f75a10a0 100644 --- a/src/components/navigation/tabNavMenu/tabNavMenu.tsx +++ b/src/components/navigation/tabNavMenu/tabNavMenu.tsx @@ -32,14 +32,10 @@ export const TabNavMenu = (props: TabNavMenuProps) => { className="text-lg text-gray-600 dark:text-gray-200 normal-case" value={index} label={ - index === props.options.length - 1 ? ( -
+ index === props.options.length - 1 && props.compareLength ? ( +
{option} - +
) : ( option From bdc6fbbb42b576f063ee5836f33d2b7501c38b77 Mon Sep 17 00:00:00 2001 From: ajlikesoj Date: Sat, 2 Nov 2024 15:59:19 -0500 Subject: [PATCH 23/37] Mapped colors based on compare table Added similar mappedColor logic from compareTable component. Added colorIndex and isInCompare variables to verify if the result object is in the compare table as well as using an individual index variable to make sure the colors stay on track based on what is added to the compare table. Added, an index to sortedResults to apply checkboxColor to all checkboxes. Allso added checkboxColor to RowProps and Row. --- .../SearchResultsTable/searchResultsTable.tsx | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/components/common/SearchResultsTable/searchResultsTable.tsx b/src/components/common/SearchResultsTable/searchResultsTable.tsx index 87408690..c0a2bd96 100644 --- a/src/components/common/SearchResultsTable/searchResultsTable.tsx +++ b/src/components/common/SearchResultsTable/searchResultsTable.tsx @@ -19,7 +19,9 @@ import React, { useState } from 'react'; import SearchQuery, { convertToProfOnly, } from '../../../modules/SearchQuery/SearchQuery'; -import { useRainbowColors } from '../../../modules/searchQueryColors/searchQueryColors'; +import searchQueryColors, { + useRainbowColors, +} from '../../../modules/searchQueryColors/searchQueryColors'; import searchQueryEqual from '../../../modules/searchQueryEqual/searchQueryEqual'; import searchQueryLabel from '../../../modules/searchQueryLabel/searchQueryLabel'; import type { RMPInterface } from '../../../pages/api/ratemyprofessorScraper'; @@ -84,6 +86,7 @@ type RowProps = { inCompare: boolean; addToCompare: (arg0: SearchQuery) => void; removeFromCompare: (arg0: SearchQuery) => void; + checkboxColor: string; }; function Row({ @@ -93,6 +96,7 @@ function Row({ inCompare, addToCompare, removeFromCompare, + checkboxColor, }: RowProps) { const [open, setOpen] = useState(false); @@ -151,6 +155,11 @@ function Row({ addToCompare(course); } }} + sx={{ + '&.Mui-checked': { + color: checkboxColor, + }, + }} disabled={ (typeof grades !== 'undefined' && grades.state === 'loading') || (typeof rmp !== 'undefined' && rmp.state === 'loading') @@ -415,6 +424,26 @@ const SearchResultsTable = ({ return 0; }); + const isInCompare = (item: SearchQuery) => + compare.some((compItem) => searchQueryEqual(compItem, item)); + + let colorIndex = 0; + const colorMap: { [key: string]: string } = {}; + + includedResults.forEach((result) => { + const inCompare = isInCompare(result); + + if (inCompare) { + colorMap[searchQueryLabel(result)] = + searchQueryColors[colorIndex % searchQueryColors.length]; + colorIndex++; + } + }); + + const mappedColors = sortedResults.map( + (result) => colorMap[searchQueryLabel(result)], + ); + return ( //TODO: sticky header <> @@ -478,7 +507,7 @@ const SearchResultsTable = ({ {resultsLoading === 'done' - ? sortedResults.map((result) => ( + ? sortedResults.map((result, index) => ( )) : Array(10) From 20a42e40813c9a8734b6a54059fc33e23fbb338c Mon Sep 17 00:00:00 2001 From: TatvikReddy Date: Sat, 2 Nov 2024 16:29:00 -0500 Subject: [PATCH 24/37] Display compare colors on search results checkboxes Updated the SearchResultsTable component to pass the corresponding color from colorMap to each Row. Modified the Row component to apply the passed color to the compare checkbox on the left-hand side. Ensured that the compare checkboxes in the search results display the same colors as those in the compare tab. This change makes it easier to correlate items between the search results and the compare view. --- .../SearchResultsTable/searchResultsTable.tsx | 49 ++++++++----------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/src/components/common/SearchResultsTable/searchResultsTable.tsx b/src/components/common/SearchResultsTable/searchResultsTable.tsx index c0a2bd96..f9835c8a 100644 --- a/src/components/common/SearchResultsTable/searchResultsTable.tsx +++ b/src/components/common/SearchResultsTable/searchResultsTable.tsx @@ -86,7 +86,7 @@ type RowProps = { inCompare: boolean; addToCompare: (arg0: SearchQuery) => void; removeFromCompare: (arg0: SearchQuery) => void; - checkboxColor: string; + color?: string; }; function Row({ @@ -96,7 +96,7 @@ function Row({ inCompare, addToCompare, removeFromCompare, - checkboxColor, + color, }: RowProps) { const [open, setOpen] = useState(false); @@ -155,15 +155,19 @@ function Row({ addToCompare(course); } }} - sx={{ - '&.Mui-checked': { - color: checkboxColor, - }, - }} disabled={ (typeof grades !== 'undefined' && grades.state === 'loading') || (typeof rmp !== 'undefined' && rmp.state === 'loading') } + sx={ + color + ? { + '&.Mui-checked': { + color: color, + }, + } + : undefined + } // Apply color if defined /> @@ -300,6 +304,13 @@ const SearchResultsTable = ({ ); } + // Build colorMap based on the 'compare' array + const colorMap: { [key: string]: string } = {}; + compare.forEach((course, index) => { + colorMap[searchQueryLabel(course)] = + searchQueryColors[index % searchQueryColors.length]; + }); + //Sort const sortedResults = includedResults.sort((a, b) => { if (orderBy === 'name') { @@ -424,26 +435,6 @@ const SearchResultsTable = ({ return 0; }); - const isInCompare = (item: SearchQuery) => - compare.some((compItem) => searchQueryEqual(compItem, item)); - - let colorIndex = 0; - const colorMap: { [key: string]: string } = {}; - - includedResults.forEach((result) => { - const inCompare = isInCompare(result); - - if (inCompare) { - colorMap[searchQueryLabel(result)] = - searchQueryColors[colorIndex % searchQueryColors.length]; - colorIndex++; - } - }); - - const mappedColors = sortedResults.map( - (result) => colorMap[searchQueryLabel(result)], - ); - return ( //TODO: sticky header <> @@ -507,7 +498,7 @@ const SearchResultsTable = ({ {resultsLoading === 'done' - ? sortedResults.map((result, index) => ( + ? sortedResults.map((result) => ( )) : Array(10) From 59daaf7320b50f303992aa32d56b7c273c4a3819 Mon Sep 17 00:00:00 2001 From: egsch Date: Sun, 3 Nov 2024 11:24:42 -0600 Subject: [PATCH 25/37] Revert "Add all course or professor sessions from RHS to academic sessions" This reverts commit 8429df8506a0ee2536e9b93d824581a24d4846c7. --- src/pages/dashboard/index.tsx | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/pages/dashboard/index.tsx b/src/pages/dashboard/index.tsx index 166e8091..46da9a4b 100644 --- a/src/pages/dashboard/index.tsx +++ b/src/pages/dashboard/index.tsx @@ -275,26 +275,6 @@ export const Dashboard: NextPage = () => { ); } }); - if ( - professorSearchTerms.length === 1 && - grades[searchQueryLabel(professorSearchTerms[0])] && - grades[searchQueryLabel(professorSearchTerms[0])].state === 'done' - ) { - const entry = grades[searchQueryLabel(professorSearchTerms[0])]; - if (entry && entry.state === 'done') { - addAcademicSessions(entry.data.grades.map((session) => session._id)); - } - } - if ( - courseSearchTerms.length === 1 && - grades[searchQueryLabel(courseSearchTerms[0])] && - grades[searchQueryLabel(courseSearchTerms[0])].state === 'done' - ) { - const entry = grades[searchQueryLabel(courseSearchTerms[0])]; - if (entry && entry.state === 'done') { - addAcademicSessions(entry.data.grades.map((session) => session._id)); - } - } //To cancel on rerender const controller = new AbortController(); From 07186923ad0cfbb0fd220ca0551865eee8a70e2f Mon Sep 17 00:00:00 2001 From: TatvikReddy Date: Mon, 4 Nov 2024 10:51:34 -0600 Subject: [PATCH 26/37] Add colorMap prop to Compare, CompareTable, and SearchResultsTable components --- src/components/common/Compare/compare.tsx | 4 +++- .../common/CompareTable/compareTable.tsx | 10 +++------- .../SearchResultsTable/searchResultsTable.tsx | 11 +++-------- src/pages/dashboard/index.tsx | 15 +++++++++++++++ 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/components/common/Compare/compare.tsx b/src/components/common/Compare/compare.tsx index e2701eb1..0ebc5ead 100644 --- a/src/components/common/Compare/compare.tsx +++ b/src/components/common/Compare/compare.tsx @@ -15,6 +15,7 @@ type CompareProps = { grades: { [key: string]: GenericFetchedData }; rmp: { [key: string]: GenericFetchedData }; removeFromCompare: { (arg0: SearchQuery): void }; + colorMap: { [key: string]: string }; }; function convertNumbersToPercents(distribution: GradesType): number[] { @@ -24,7 +25,7 @@ function convertNumbersToPercents(distribution: GradesType): number[] { ); } -const Compare = ({ courses, grades, rmp, removeFromCompare }: CompareProps) => { +const Compare = ({ courses, grades, rmp, removeFromCompare, colorMap }: CompareProps) => { if (courses.length === 0) { return

Click a checkbox to add something to compare.

; } @@ -90,6 +91,7 @@ const Compare = ({ courses, grades, rmp, removeFromCompare }: CompareProps) => { grades={grades} rmp={rmp} removeFromCompare={removeFromCompare} + colorMap={colorMap} />
); diff --git a/src/components/common/CompareTable/compareTable.tsx b/src/components/common/CompareTable/compareTable.tsx index 587c70d1..b5cfb000 100644 --- a/src/components/common/CompareTable/compareTable.tsx +++ b/src/components/common/CompareTable/compareTable.tsx @@ -15,7 +15,6 @@ import React, { useState } from 'react'; import SearchQuery, { convertToProfOnly, } from '../../../modules/SearchQuery/SearchQuery'; -import searchQueryColors from '../../../modules/searchQueryColors/searchQueryColors'; import searchQueryLabel from '../../../modules/searchQueryLabel/searchQueryLabel'; import type { RMPInterface } from '../../../pages/api/ratemyprofessorScraper'; import type { @@ -288,6 +287,7 @@ type CompareTableProps = { grades: { [key: string]: GenericFetchedData }; rmp: { [key: string]: GenericFetchedData }; removeFromCompare: (arg0: SearchQuery) => void; + colorMap: { [key: string]: string }; }; const CompareTable = ({ @@ -295,6 +295,7 @@ const CompareTable = ({ grades, rmp, removeFromCompare, + colorMap, }: CompareTableProps) => { //Table sorting category const [orderBy, setOrderBy] = useState('Color'); @@ -388,12 +389,7 @@ const CompareTable = ({ return 0; }); - // Color map for each course in the compare table based on searchQueryColors - const colorMap: { [key: string]: string } = {}; - includedResults.forEach((result, index) => { - colorMap[searchQueryLabel(result)] = - searchQueryColors[index % searchQueryColors.length]; - }); + // Update mappedColors to use the passed colorMap const mappedColors = sortedResults.map( (result) => colorMap[searchQueryLabel(result)], ); diff --git a/src/components/common/SearchResultsTable/searchResultsTable.tsx b/src/components/common/SearchResultsTable/searchResultsTable.tsx index f9835c8a..2871d382 100644 --- a/src/components/common/SearchResultsTable/searchResultsTable.tsx +++ b/src/components/common/SearchResultsTable/searchResultsTable.tsx @@ -19,7 +19,7 @@ import React, { useState } from 'react'; import SearchQuery, { convertToProfOnly, } from '../../../modules/SearchQuery/SearchQuery'; -import searchQueryColors, { +import { useRainbowColors, } from '../../../modules/searchQueryColors/searchQueryColors'; import searchQueryEqual from '../../../modules/searchQueryEqual/searchQueryEqual'; @@ -256,6 +256,7 @@ type SearchResultsTableProps = { compare: SearchQuery[]; addToCompare: (arg0: SearchQuery) => void; removeFromCompare: (arg0: SearchQuery) => void; + colorMap: { [key: string]: string }; }; const SearchResultsTable = ({ @@ -266,6 +267,7 @@ const SearchResultsTable = ({ compare, addToCompare, removeFromCompare, + colorMap, }: SearchResultsTableProps) => { //Table sorting category const [orderBy, setOrderBy] = useState<'name' | 'gpa' | 'rating'>('name'); @@ -304,13 +306,6 @@ const SearchResultsTable = ({ ); } - // Build colorMap based on the 'compare' array - const colorMap: { [key: string]: string } = {}; - compare.forEach((course, index) => { - colorMap[searchQueryLabel(course)] = - searchQueryColors[index % searchQueryColors.length]; - }); - //Sort const sortedResults = includedResults.sort((a, b) => { if (orderBy === 'name') { diff --git a/src/pages/dashboard/index.tsx b/src/pages/dashboard/index.tsx index 34095cde..af4652d8 100644 --- a/src/pages/dashboard/index.tsx +++ b/src/pages/dashboard/index.tsx @@ -21,6 +21,7 @@ import fetchWithCache, { } from '../../modules/fetchWithCache'; import type SearchQuery from '../../modules/SearchQuery/SearchQuery'; import { convertToProfOnly } from '../../modules/SearchQuery/SearchQuery'; +import searchQueryColors from '../../modules/searchQueryColors/searchQueryColors'; import searchQueryEqual from '../../modules/searchQueryEqual/searchQueryEqual'; import searchQueryLabel from '../../modules/searchQueryLabel/searchQueryLabel'; import type { GradesData } from '../../pages/api/grades'; @@ -228,6 +229,15 @@ function fetchRmpData( }); } +// Add this utility function after the existing type definitions +function createColorMap(courses: SearchQuery[]): { [key: string]: string } { + const colorMap: { [key: string]: string } = {}; + courses.forEach((course, index) => { + colorMap[searchQueryLabel(course)] = searchQueryColors[index % searchQueryColors.length]; + }); + return colorMap; +} + export const Dashboard: NextPage = () => { const router = useRouter(); @@ -679,6 +689,9 @@ export const Dashboard: NextPage = () => { } } + // Add this after the compare state declaration + const colorMap = createColorMap(compare); + //Main content: loading, error, or normal let contentComponent; @@ -719,6 +732,7 @@ export const Dashboard: NextPage = () => { grades={compareGrades} rmp={compareRmp} removeFromCompare={removeFromCompare} + colorMap={colorMap} // Add this prop />, ); contentComponent = ( @@ -744,6 +758,7 @@ export const Dashboard: NextPage = () => { compare={compare} addToCompare={addToCompare} removeFromCompare={removeFromCompare} + colorMap={colorMap} // Add this prop /> From fb71a2d3fdd7b566be2b64445457aaa4dff58dab Mon Sep 17 00:00:00 2001 From: TatvikReddy Date: Mon, 4 Nov 2024 11:07:08 -0600 Subject: [PATCH 27/37] ran prettier to format on Compare and SearchResultsTable and index components --- src/components/common/Compare/compare.tsx | 8 +++++++- .../common/SearchResultsTable/searchResultsTable.tsx | 6 ++---- src/pages/dashboard/index.tsx | 7 ++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/components/common/Compare/compare.tsx b/src/components/common/Compare/compare.tsx index 0ebc5ead..f8b86647 100644 --- a/src/components/common/Compare/compare.tsx +++ b/src/components/common/Compare/compare.tsx @@ -25,7 +25,13 @@ function convertNumbersToPercents(distribution: GradesType): number[] { ); } -const Compare = ({ courses, grades, rmp, removeFromCompare, colorMap }: CompareProps) => { +const Compare = ({ + courses, + grades, + rmp, + removeFromCompare, + colorMap, +}: CompareProps) => { if (courses.length === 0) { return

Click a checkbox to add something to compare.

; } diff --git a/src/components/common/SearchResultsTable/searchResultsTable.tsx b/src/components/common/SearchResultsTable/searchResultsTable.tsx index 2871d382..53de7de8 100644 --- a/src/components/common/SearchResultsTable/searchResultsTable.tsx +++ b/src/components/common/SearchResultsTable/searchResultsTable.tsx @@ -19,9 +19,7 @@ import React, { useState } from 'react'; import SearchQuery, { convertToProfOnly, } from '../../../modules/SearchQuery/SearchQuery'; -import { - useRainbowColors, -} from '../../../modules/searchQueryColors/searchQueryColors'; +import { useRainbowColors } from '../../../modules/searchQueryColors/searchQueryColors'; import searchQueryEqual from '../../../modules/searchQueryEqual/searchQueryEqual'; import searchQueryLabel from '../../../modules/searchQueryLabel/searchQueryLabel'; import type { RMPInterface } from '../../../pages/api/ratemyprofessorScraper'; @@ -506,7 +504,7 @@ const SearchResultsTable = ({ } addToCompare={addToCompare} removeFromCompare={removeFromCompare} - color={colorMap[searchQueryLabel(result)]} // Use color from colorMap + color={colorMap[searchQueryLabel(result)]} /> )) : Array(10) diff --git a/src/pages/dashboard/index.tsx b/src/pages/dashboard/index.tsx index af4652d8..8c8d71b9 100644 --- a/src/pages/dashboard/index.tsx +++ b/src/pages/dashboard/index.tsx @@ -233,7 +233,8 @@ function fetchRmpData( function createColorMap(courses: SearchQuery[]): { [key: string]: string } { const colorMap: { [key: string]: string } = {}; courses.forEach((course, index) => { - colorMap[searchQueryLabel(course)] = searchQueryColors[index % searchQueryColors.length]; + colorMap[searchQueryLabel(course)] = + searchQueryColors[index % searchQueryColors.length]; }); return colorMap; } @@ -732,7 +733,7 @@ export const Dashboard: NextPage = () => { grades={compareGrades} rmp={compareRmp} removeFromCompare={removeFromCompare} - colorMap={colorMap} // Add this prop + colorMap={colorMap} />, ); contentComponent = ( @@ -758,7 +759,7 @@ export const Dashboard: NextPage = () => { compare={compare} addToCompare={addToCompare} removeFromCompare={removeFromCompare} - colorMap={colorMap} // Add this prop + colorMap={colorMap} />
From ef2bb1f374fed11c94cd848bda64d29d4bc9ca4c Mon Sep 17 00:00:00 2001 From: egsch Date: Mon, 4 Nov 2024 16:16:36 -0600 Subject: [PATCH 28/37] Store RHS course and professor data separately --- src/pages/dashboard/index.tsx | 77 +++++++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 17 deletions(-) diff --git a/src/pages/dashboard/index.tsx b/src/pages/dashboard/index.tsx index 46da9a4b..2517db63 100644 --- a/src/pages/dashboard/index.tsx +++ b/src/pages/dashboard/index.tsx @@ -281,23 +281,51 @@ export const Dashboard: NextPage = () => { //Get course/prof info if (courseSearchTerms.length === 1) { - if ( - typeof grades[searchQueryLabel(courseSearchTerms[0])] === 'undefined' - ) { - fetchAndStoreGradesData(courseSearchTerms[0], controller); + if (!(searchQueryLabel(courseSearchTerms[0]) in rhsGrades.course)) { + addRHSGrades( + searchQueryLabel(courseSearchTerms[0]), + { + state: 'loading', + }, + true, + ); + fetchGradesData(courseSearchTerms[0], controller) + .then((rhsGrade) => { + addRHSGrades( + searchQueryLabel(courseSearchTerms[0]), + { + state: rhsGrade.gpa !== -1 ? 'done' : 'error', + data: rhsGrade, + }, + true, + ); + }) + .catch((err) => console.error('Grades data for ' + searchQueryLabel(courseSearchTerms[0]), err)); } } if (professorSearchTerms.length === 1) { if ( - typeof grades[searchQueryLabel(professorSearchTerms[0])] === - 'undefined' - ) { - fetchAndStoreGradesData(professorSearchTerms[0], controller); - } - if ( - typeof rmp[searchQueryLabel(professorSearchTerms[0])] === 'undefined' + !(searchQueryLabel(professorSearchTerms[0]) in rhsGrades.professor) ) { - fetchAndStoreRmpData(professorSearchTerms[0], controller); + addRHSGrades( + searchQueryLabel(professorSearchTerms[0]), + { + state: 'loading', + }, + false, + ); + fetchGradesData(professorSearchTerms[0], controller) + .then((rhsGrade) => { + addRHSGrades( + searchQueryLabel(professorSearchTerms[0]), + { + state: rhsGrade.gpa !== -1 ? 'done' : 'error', + data: rhsGrade, + }, + false, + ); + }) + .catch((err) => console.error('Grades data for ' + searchQueryLabel(courseSearchTerms[0]), err)); } } @@ -350,9 +378,7 @@ export const Dashboard: NextPage = () => { //Relavent keys for (const result of [ ...(results.state === 'done' ? results.data : []), - ] - .concat(courses.length === 1 ? courses[0] : []) - .concat(professors.length === 1 ? professors[0] : [])) { + ]) { const entry = grades[searchQueryLabel(result)]; if (entry && entry.state === 'done') { entry.data = { @@ -442,6 +468,23 @@ export const Dashboard: NextPage = () => { return newVal; }); } + + type rhsGradesType = { [key: string]: GenericFetchedData }; + const [rhsGrades, setRHSGrades] = useState<{ + course: rhsGradesType; + professor: rhsGradesType; + }>({ course: {}, professor: {} }); + function addRHSGrades( + rhsKey: string, + rhsGrade: GenericFetchedData, + course: boolean, + ) { + setRHSGrades((old) => ({ + course: course ? { [rhsKey]: rhsGrade } : old.course, + professor: course ? old.professor : { [rhsKey]: rhsGrade }, + })); + } + //Store rmp scores by profs const [rmp, setRmp] = useState<{ [key: string]: GenericFetchedData; @@ -696,7 +739,7 @@ export const Dashboard: NextPage = () => { , ); @@ -707,7 +750,7 @@ export const Dashboard: NextPage = () => { , ); } From b41baeec10178f2fa7455dae6f38af23fa50c724 Mon Sep 17 00:00:00 2001 From: egsch Date: Mon, 4 Nov 2024 17:00:01 -0600 Subject: [PATCH 29/37] clean up and formatting --- src/pages/dashboard/index.tsx | 67 ++++++++++++----------------------- 1 file changed, 23 insertions(+), 44 deletions(-) diff --git a/src/pages/dashboard/index.tsx b/src/pages/dashboard/index.tsx index 2517db63..eed8d649 100644 --- a/src/pages/dashboard/index.tsx +++ b/src/pages/dashboard/index.tsx @@ -282,50 +282,14 @@ export const Dashboard: NextPage = () => { //Get course/prof info if (courseSearchTerms.length === 1) { if (!(searchQueryLabel(courseSearchTerms[0]) in rhsGrades.course)) { - addRHSGrades( - searchQueryLabel(courseSearchTerms[0]), - { - state: 'loading', - }, - true, - ); - fetchGradesData(courseSearchTerms[0], controller) - .then((rhsGrade) => { - addRHSGrades( - searchQueryLabel(courseSearchTerms[0]), - { - state: rhsGrade.gpa !== -1 ? 'done' : 'error', - data: rhsGrade, - }, - true, - ); - }) - .catch((err) => console.error('Grades data for ' + searchQueryLabel(courseSearchTerms[0]), err)); + fetchAndAddRHSGrades(courseSearchTerms[0], controller); } } if (professorSearchTerms.length === 1) { if ( !(searchQueryLabel(professorSearchTerms[0]) in rhsGrades.professor) ) { - addRHSGrades( - searchQueryLabel(professorSearchTerms[0]), - { - state: 'loading', - }, - false, - ); - fetchGradesData(professorSearchTerms[0], controller) - .then((rhsGrade) => { - addRHSGrades( - searchQueryLabel(professorSearchTerms[0]), - { - state: rhsGrade.gpa !== -1 ? 'done' : 'error', - data: rhsGrade, - }, - false, - ); - }) - .catch((err) => console.error('Grades data for ' + searchQueryLabel(courseSearchTerms[0]), err)); + fetchAndAddRHSGrades(professorSearchTerms[0], controller); } } @@ -469,20 +433,35 @@ export const Dashboard: NextPage = () => { }); } + // holds data for course and professor overviews type rhsGradesType = { [key: string]: GenericFetchedData }; const [rhsGrades, setRHSGrades] = useState<{ course: rhsGradesType; professor: rhsGradesType; }>({ course: {}, professor: {} }); - function addRHSGrades( - rhsKey: string, - rhsGrade: GenericFetchedData, - course: boolean, + function fetchAndAddRHSGrades( + query: SearchQuery, + controller: AbortController, ) { + const rhsKey = searchQueryLabel(query); + // only update course on course query or vice versa + const isCourse = typeof query.prefix !== 'undefined'; setRHSGrades((old) => ({ - course: course ? { [rhsKey]: rhsGrade } : old.course, - professor: course ? old.professor : { [rhsKey]: rhsGrade }, + course: isCourse ? { [rhsKey]: { state: 'loading' } } : old.course, + professor: isCourse ? old.professor : { [rhsKey]: { state: 'loading' } }, })); + fetchGradesData(query, controller) + .then((rhsGrade) => { + const rhsGradeFetched: GenericFetchedData = { + state: rhsGrade.gpa !== -1 ? 'done' : 'error', + data: rhsGrade, + }; + setRHSGrades((old) => ({ + course: isCourse ? { [rhsKey]: rhsGradeFetched } : old.course, + professor: isCourse ? old.professor : { [rhsKey]: rhsGradeFetched }, + })); + }) + .catch((err) => console.error('Grades data for ' + rhsKey, err)); } //Store rmp scores by profs From b010980230c771915e3d264502a4d6d7d6deb7aa Mon Sep 17 00:00:00 2001 From: Tyler Hill Date: Wed, 6 Nov 2024 23:37:22 -0600 Subject: [PATCH 30/37] Add link --- src/pages/index.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index a68c7957..958117f5 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -75,6 +75,9 @@ const Home: NextPage = () => { input_className="[&>.MuiInputBase-root]:bg-white [&>.MuiInputBase-root]:dark:bg-haiti" /> + + Also check out UTD Grades + ); From 4911cc0486d3fd7964e43425b8df0129858ac0b3 Mon Sep 17 00:00:00 2001 From: Tyler Hill Date: Thu, 7 Nov 2024 00:43:43 -0600 Subject: [PATCH 31/37] Add the href oops --- src/pages/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 958117f5..80627dcf 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -75,7 +75,11 @@ const Home: NextPage = () => { input_className="[&>.MuiInputBase-root]:bg-white [&>.MuiInputBase-root]:dark:bg-haiti" /> - + Also check out UTD Grades From b7bb759979e6ce836d65e2d69ef38aa4f8011539 Mon Sep 17 00:00:00 2001 From: Tyler Hill Date: Thu, 7 Nov 2024 01:00:50 -0600 Subject: [PATCH 32/37] Change rounded --- src/pages/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 80627dcf..2dff5e97 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -78,7 +78,7 @@ const Home: NextPage = () => { Also check out UTD Grades From a6ff26c03551a08e02bd99cd93a057a70120293c Mon Sep 17 00:00:00 2001 From: Tyler Hill Date: Thu, 7 Nov 2024 01:17:14 -0600 Subject: [PATCH 33/37] noopener eslint --- src/pages/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 2dff5e97..bf2b7a68 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -50,12 +50,12 @@ const Home: NextPage = () => { />

- POWERED BY{' '} + POWERED BY {/*eslint-disable-next-line react/jsx-no-target-blank*/} NEBULA LABS @@ -75,9 +75,11 @@ const Home: NextPage = () => { input_className="[&>.MuiInputBase-root]:bg-white [&>.MuiInputBase-root]:dark:bg-haiti" />

+ {/*eslint-disable-next-line react/jsx-no-target-blank*/} Also check out UTD Grades From 6196c2b6b39d842b78403ccee0a7292fd5a63fb6 Mon Sep 17 00:00:00 2001 From: Tyler Hill Date: Thu, 7 Nov 2024 11:44:59 -0600 Subject: [PATCH 34/37] Remove duplicate button --- src/pages/_app.tsx | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index d0ddd218..d141e6ba 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,7 +1,6 @@ import '../styles/globals.css'; -import GitHub from '@mui/icons-material/GitHub'; -import { Card, IconButton, Tooltip, useMediaQuery } from '@mui/material'; +import { useMediaQuery } from '@mui/material'; import { createTheme, ThemeProvider } from '@mui/material/styles'; import { GoogleAnalytics } from '@next/third-parties/google'; import { Analytics } from '@vercel/analytics/react'; @@ -99,12 +98,6 @@ function MyApp({ Component, pageProps }: AppProps) { }, }); - const showGitInfo = - typeof process.env.NEXT_PUBLIC_VERCEL_ENV !== 'undefined' && - process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview' && - typeof process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA !== 'undefined' && - process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA !== ''; - const router = useRouter(); return ( @@ -148,26 +141,6 @@ function MyApp({ Component, pageProps }: AppProps) { - {showGitInfo && ( - <> - - - - - - - -
- - - )} ); } From 7e316046920fbc018eb5815d0e8b946ca738d127 Mon Sep 17 00:00:00 2001 From: Tyler Hill Date: Thu, 7 Nov 2024 11:45:10 -0600 Subject: [PATCH 35/37] Update button --- .../common/GitHubButton/gitHubButton.tsx | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/src/components/common/GitHubButton/gitHubButton.tsx b/src/components/common/GitHubButton/gitHubButton.tsx index 6c915071..4ccc1519 100644 --- a/src/components/common/GitHubButton/gitHubButton.tsx +++ b/src/components/common/GitHubButton/gitHubButton.tsx @@ -1,11 +1,8 @@ import GitHub from '@mui/icons-material/GitHub'; -import { Card, IconButton, Tooltip, useMediaQuery } from '@mui/material'; +import { IconButton, Tooltip } from '@mui/material'; import React from 'react'; export default function GitHubButton() { - const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)'); - const cardElevation = prefersDarkMode ? 3 : 1; - const showGitInfo = typeof process.env.NEXT_PUBLIC_VERCEL_ENV !== 'undefined' && process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview' && @@ -17,24 +14,20 @@ export default function GitHubButton() { } return ( - - - - - - - - - + + + + + + + ); } From 1c371ee2cbf46f7aa2e1b42a970af4ef794a0933 Mon Sep 17 00:00:00 2001 From: Tyler Hill Date: Thu, 7 Nov 2024 15:19:28 -0600 Subject: [PATCH 36/37] Remove shadow --- src/pages/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index bf2b7a68..a4fa94fd 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -80,7 +80,7 @@ const Home: NextPage = () => { href="https://utdgrades.com/" target="_blank" rel="noopener" - className="absolute bottom-4 bg-white text-black py-3 px-5 rounded [box-shadow:_0_2px_6px_rgb(0_0_0_/_0.2)] transition hover:[box-shadow:_0_2px_8px_rgb(0_0_0_/_0.2)] hover:scale-[1.01]" + className="absolute bottom-4 bg-white text-black py-3 px-5 rounded transition hover:scale-[1.01]" > Also check out UTD Grades From 8bc57669bd2fb3a6c4a9b08c024b78cda0cda34e Mon Sep 17 00:00:00 2001 From: Tyler Hill Date: Thu, 7 Nov 2024 15:21:00 -0600 Subject: [PATCH 37/37] Dark mode support --- src/pages/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index a4fa94fd..8b9e3105 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -80,7 +80,7 @@ const Home: NextPage = () => { href="https://utdgrades.com/" target="_blank" rel="noopener" - className="absolute bottom-4 bg-white text-black py-3 px-5 rounded transition hover:scale-[1.01]" + className="absolute bottom-4 bg-white dark:bg-black text-black dark:text-white py-3 px-5 rounded transition hover:scale-[1.01]" > Also check out UTD Grades