Skip to content

Commit

Permalink
Merge branch 'develop' into move-academic-session-select
Browse files Browse the repository at this point in the history
  • Loading branch information
TyHil authored Oct 12, 2023
2 parents 656d45a + fee265d commit 3e39ebe
Show file tree
Hide file tree
Showing 44 changed files with 11,868 additions and 28,881 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.json

This file was deleted.

5 changes: 0 additions & 5 deletions apitesting.http

This file was deleted.

6 changes: 0 additions & 6 deletions commitlint.config.js

This file was deleted.

118 changes: 0 additions & 118 deletions components/autocomplete.ts

This file was deleted.

5 changes: 3 additions & 2 deletions components/common/Carousel/carousel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ReactJSXElement } from '@emotion/react/types/jsx-namespace';
import React, { FC, useState } from 'react';
import { AnimatePresence, motion } from 'framer-motion';
import React, { useState } from 'react';

import { TabNavMenu } from '../../navigation/tabNavMenu/tabNavMenu';

interface CarouselProps {
Expand Down Expand Up @@ -36,7 +37,7 @@ const variants = {
* @param props the props passed from the parent component
* @returns
*/
export const Carousel: FC<CarouselProps> = (props: CarouselProps) => {
export const Carousel = (props: CarouselProps) => {
//The card currently being displayed
const [currentCard, setCard] = useState(0);
//The Direction that the card is moving in
Expand Down
67 changes: 31 additions & 36 deletions components/common/ExpandableSearchGrid/expandableSearchGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import { useEffect, useState } from 'react';
import { SearchTermCard } from '../SearchTermCard/searchTermCard';
import Card from '@mui/material/Card';
import { CardContent } from '@mui/material';
import { SearchBar } from '../SearchBar/searchBar';
import React from 'react';
import Card from '@mui/material/Card';
import { useRouter } from 'next/router';
import React, { useEffect, useState } from 'react';

type SearchQuery = {
prefix?: string;
number?: string;
professorName?: string;
sectionNumber?: string;
};
import SearchQuery from '../../../modules/SearchQuery/SearchQuery';
import searchQueryColors from '../../../modules/searchQueryColors/searchQueryColors';
import searchQueryLabel from '../../../modules/searchQueryLabel/searchQueryLabel';
import { SearchBar } from '../SearchBar/searchBar';
import { SearchTermCard } from '../SearchTermCard/searchTermCard';

type ExpandableSearchGridProps = {
onChange: Function;
onChange: (searchTerms: SearchQuery[]) => void;
studentTotals: number[];
averageData: number[];
};
Expand All @@ -29,15 +25,31 @@ export const ExpandableSearchGrid = ({
studentTotals,
averageData,
}: ExpandableSearchGridProps) => {
const router = useRouter();

const [value, setValue] = useState<SearchQuery[]>([]);
const [searchTerms, setSearchTerms] = useState<SearchQuery[]>([]);
const [searchDisabled, setSearchDisable] = useState<boolean>(false);

useEffect(() => {
onChange(searchTerms);
if (router.isReady) {
if (searchTerms.length > 0) {
router.replace(
{
pathname: '/dashboard',
query: { searchTerms: searchQueriesLabel(searchTerms) },
},
undefined,
{ shallow: true },
);
} else {
router.replace('/dashboard', undefined, { shallow: true });
}
}
}, [onChange, searchTerms]);

function addSearchTerm(newSearchTerm: SearchQuery) {
function addSearchTerm(newSearchTerm: SearchQuery | null) {
if (newSearchTerm != null) {
//console.log('adding ' + newSearchTerm + ' to the search terms.');
setSearchTerms([...searchTerms, newSearchTerm]);
Expand Down Expand Up @@ -66,13 +78,11 @@ export const ExpandableSearchGrid = ({
}
}, [searchTerms]);

const router = useRouter();

useEffect(() => {
if (router.isReady) {
setSearchTerms(parseURIEncodedSearchTerms(router.query.searchTerms));
}
}, [router.isReady]);
}, [router.isReady, router.query.searchTerms]);

return (
<div className="w-full min-h-[72px] grid grid-flow-row auto-cols-fr md:grid-flow-col justify-center">
Expand All @@ -85,7 +95,7 @@ export const ExpandableSearchGrid = ({
)}
key={index}
index={index}
legendColor={colors[index]}
legendColor={searchQueryColors[index]}
onCloseButtonClicked={deleteSearchTerm}
loading={studentTotals[index] === -1 || averageData[index] === -1}
/>
Expand Down Expand Up @@ -113,21 +123,8 @@ function secondaryTextFormatter(total: number, gpa: number) {
);
}

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();
function searchQueriesLabel(queries: SearchQuery[]): string {
return queries.map((query) => searchQueryLabel(query)).join(',');
}

function parseURIEncodedSearchTerms(
Expand All @@ -145,7 +142,7 @@ function parseURIEncodedSearchTerms(
}

function parseURIEncodedSearchTerm(encodedSearchTerm: string): SearchQuery {
let encodedSearchTermParts = encodedSearchTerm.split(' ');
const encodedSearchTermParts = encodedSearchTerm.split(' ');
// Does it start with prefix
if (/^([A-Z]{2,4})$/.test(encodedSearchTermParts[0])) {
// If it is just the prefix, return that
Expand All @@ -170,7 +167,7 @@ function parseURIEncodedSearchTerm(encodedSearchTerm: string): SearchQuery {
}
// Is the second part a course number and section
else if (/^([0-9A-Z]{4}\.[0-9A-Z]{3})$/.test(encodedSearchTermParts[1])) {
let courseNumberAndSection: string[] =
const courseNumberAndSection: string[] =
encodedSearchTermParts[1].split('.');
if (encodedSearchTermParts.length == 2) {
return {
Expand Down Expand Up @@ -200,5 +197,3 @@ function parseURIEncodedSearchTerm(encodedSearchTerm: string): SearchQuery {
return { professorName: encodedSearchTerm.trim() };
}
}

const colors = ['#eb5757', '#2d9cdb', '#499F68'];
Loading

0 comments on commit 3e39ebe

Please sign in to comment.