Skip to content

Commit

Permalink
Merge pull request #132 from UTDNebula/develop
Browse files Browse the repository at this point in the history
Late 2023 Production update
  • Loading branch information
iamwood authored Dec 7, 2023
2 parents d6b4ede + fb7dd32 commit be113cd
Show file tree
Hide file tree
Showing 74 changed files with 801,489 additions and 13,701 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/lint-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint and Formatting Check

on: push

jobs:
main:
name: Run ESLint + Prettier
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install Next for ESLint and Prettier
run: npm install next prettier

- name: Run ESLint
run: npm run lint:check

- name: Run Prettier
run: npm run format:check
13 changes: 0 additions & 13 deletions .github/workflows/main.yml

This file was deleted.

1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
29 changes: 22 additions & 7 deletions components/common/ExpandableSearchGrid/expandableSearchGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export const ExpandableSearchGrid = ({
studentTotals[index],
averageData[index],
)}
includeTooltip={studentTotals[index] !== 0}
key={index}
index={index}
legendColor={searchQueryColors[index]}
Expand All @@ -143,6 +144,9 @@ export const ExpandableSearchGrid = ({
};

function secondaryTextFormatter(total: number, gpa: number) {
if (total == 0) {
return 'No grade data available';
}
return (
total.toLocaleString('en-US') +
' grades | ' +
Expand Down Expand Up @@ -200,8 +204,10 @@ function parseURIEncodedSearchTerm(encodedSearchTerm: string): SearchQuery {
return {
prefix: encodedSearchTermParts[0],
number: encodedSearchTermParts[1],
professorName:
encodedSearchTermParts[2] + ' ' + encodedSearchTermParts[3],
profFirst: encodedSearchTermParts
.slice(2, encodedSearchTermParts.length - 1)
.join(' '),
profLast: encodedSearchTermParts[encodedSearchTermParts.length - 1],
};
}
}
Expand All @@ -220,20 +226,29 @@ function parseURIEncodedSearchTerm(encodedSearchTerm: string): SearchQuery {
prefix: encodedSearchTermParts[0],
number: courseNumberAndSection[0],
sectionNumber: courseNumberAndSection[1],
professorName:
encodedSearchTermParts[2] + ' ' + encodedSearchTermParts[3],
profFirst: encodedSearchTermParts
.slice(2, encodedSearchTermParts.length - 1)
.join(' '),
profLast: encodedSearchTermParts[encodedSearchTermParts.length - 1],
};
}
}
// the second part is the start of the name
else {
return {
prefix: encodedSearchTermParts[0],
professorName:
encodedSearchTermParts[1] + ' ' + encodedSearchTermParts[2],
profFirst: encodedSearchTermParts
.slice(1, encodedSearchTermParts.length - 1)
.join(' '),
profLast: encodedSearchTermParts[encodedSearchTermParts.length - 1],
};
}
} else {
return { professorName: encodedSearchTerm.trim() };
return {
profFirst: encodedSearchTermParts
.slice(0, encodedSearchTermParts.length - 1)
.join(' '),
profLast: encodedSearchTermParts[encodedSearchTermParts.length - 1],
};
}
}
26 changes: 2 additions & 24 deletions components/common/RelatedClasses/relatedClasses.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { Typography } from '@mui/material';
import React from 'react';

import SearchQuery from '../../../modules/SearchQuery/SearchQuery';
import searchQueryLabel from '../../../modules/searchQueryLabel/searchQueryLabel';
import { RelatedTermCard } from '../RelatedTermCard/relatedTermCard';

type SearchQuery = {
prefix?: string;
number?: string;
professorName?: string;
sectionNumber?: string;
};

type RelatedClassesProps = {
displayData: SearchQuery[];
addNew: (query: SearchQuery) => void;
Expand Down Expand Up @@ -49,20 +44,3 @@ export const RelatedClasses = ({
</div>
);
};

function searchQueryLabel(query: SearchQuery): string {
let result = '';
if (query.prefix !== undefined) {
result += query.prefix;
}
if (query.number !== undefined) {
result += ' ' + query.number;
}
if (query.sectionNumber !== undefined) {
result += '.' + query.sectionNumber;
}
if (query.professorName !== undefined) {
result += ' ' + query.professorName;
}
return result.trim();
}
26 changes: 9 additions & 17 deletions components/common/SearchBar/searchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ type SearchProps = {
export const SearchBar = (props: SearchProps) => {
const [open, setOpen] = useState(false);
const [options, setOptions] = useState<readonly SearchQuery[]>([]);
const [loading, setLoading] = useState(false);

const [value, setValue] = useState<SearchQuery | null>(null);
const [inputValue, setInputValue] = useState('');

useEffect(() => {
if (open) {
setLoading(true);
let searchValue = inputValue;
if (searchValue === '') {
if (!props.searchTerms.length) {
setOptions([]);
setLoading(false);
return;
}
searchValue = searchQueryLabel(
Expand All @@ -56,6 +59,7 @@ export const SearchBar = (props: SearchProps) => {
throw new Error(data.message);
}
setOptions(data.data);
setLoading(false);
})
.catch((error) => {
if (error instanceof DOMException) {
Expand All @@ -74,9 +78,11 @@ export const SearchBar = (props: SearchProps) => {
<>
<div className="text-primary w-full max-w-2xl h-fit flex flex-row items-start">
<Autocomplete
loading={loading}
autoHighlight={true}
clearOnBlur={false}
disabled={props.disabled}
className="w-full h-12 bg-primary-light font-sans"
className="w-full h-12 bg-primary-light"
open={open}
onOpen={() => {
setOpen(true);
Expand Down Expand Up @@ -115,7 +121,7 @@ export const SearchBar = (props: SearchProps) => {
ref={params.InputProps.ref}
inputProps={params.inputProps}
fullWidth={true}
className="font-sans w-full h-12 bg-primary-light text-gray-600 dark:text-gray-200 placeholder-dark"
className="w-full h-12 bg-primary-light text-gray-600 dark:text-gray-200 placeholder-dark"
placeholder="Search course, professor, or both...."
startAdornment={
<InputAdornment position="start">
Expand Down Expand Up @@ -158,21 +164,7 @@ export const SearchBar = (props: SearchProps) => {
</li>
);
}}
isOptionEqualToValue={(option, value) => {
if (option.prefix !== value.prefix) {
return false;
}
if (option.professorName !== value.professorName) {
return false;
}
if (option.number !== value.number) {
return false;
}
if (option.sectionNumber !== value.sectionNumber) {
return false;
}
return true;
}}
isOptionEqualToValue={searchQueryEqual}
PopperComponent={(props) => {
return (
<Popper {...props} className="rounded-none" placement="bottom" />
Expand Down
3 changes: 2 additions & 1 deletion components/common/SearchTermCard/searchTermCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React from 'react';
type SearchTermCardProps = {
primaryText: string;
secondaryText: string;
includeTooltip: boolean;
index: number;
onCloseButtonClicked: (index: number) => void;
onToggleButtonClicked: (index: number) => void;
Expand Down Expand Up @@ -64,7 +65,7 @@ export const SearchTermCard = (props: SearchTermCardProps) => {
<span className="block text-sm text-gray-500 dark:text-gray-300 inline">
{props.loading ? 'Loading...' : props.secondaryText}
</span>
{props.loading ? null : (
{!props.loading && props.includeTooltip && (
<Tooltip title="Avergae GPA excludes dropped grades" arrow>
<Help className="inline fill-gray-500 dark:fill-gray-300 text-base ml-0.5 mb-0.5" />
</Tooltip>
Expand Down
6 changes: 6 additions & 0 deletions components/common/SplashPageSearchBar/splashPageSearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ type SearchProps = {
*/
export const SplashPageSearchBar = (props: SearchProps) => {
const [options, setOptions] = useState<readonly SearchQuery[]>([]);
const [loading, setLoading] = useState(false);

const [inputValue, setInputValue] = useState('');

useEffect(() => {
setLoading(true);
if (inputValue === '') {
setOptions([]);
setLoading(false);
return;
}
const controller = new AbortController();
Expand All @@ -43,6 +46,7 @@ export const SplashPageSearchBar = (props: SearchProps) => {
throw new Error(data.message);
}
setOptions(data.data);
setLoading(false);
})
.catch((error) => {
if (error instanceof DOMException) {
Expand All @@ -60,7 +64,9 @@ export const SplashPageSearchBar = (props: SearchProps) => {
<>
<div className="text-primary m-auto w-11/12 -translate-y-1/4">
<Autocomplete
loading={loading}
autoHighlight={true}
clearOnBlur={false}
disabled={props.disabled}
className="w-full h-12"
getOptionLabel={(option) => searchQueryLabel(option)}
Expand Down
20 changes: 2 additions & 18 deletions components/graph/BarGraph/BarGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,7 @@ import { VerticalBarGraph } from '../VerticalBarGraph/VerticalBarGraph';
export function BarGraph(props: GraphProps) {
const smallScreen = useMediaQuery('(min-width:600px)');
if (smallScreen) {
return (
<VerticalBarGraph
xaxisLabels={props.xaxisLabels}
yaxisFormatter={props.yaxisFormatter}
series={props.series}
title={props.title}
includedColors={props.includedColors}
/>
);
return <VerticalBarGraph {...props} />;
}
return (
<HorizontalBarGraph
xaxisLabels={props.xaxisLabels}
yaxisFormatter={props.yaxisFormatter}
series={props.series}
title={props.title}
includedColors={props.includedColors}
/>
);
return <HorizontalBarGraph {...props} />;
}
Loading

1 comment on commit be113cd

@vercel
Copy link

@vercel vercel bot commented on be113cd Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.