Skip to content

Commit

Permalink
Merge branch 'master' into improve-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
js0mmer authored Oct 21, 2023
2 parents 7ea8ab1 + 4b598ef commit f809b59
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions site/src/component/SearchModule/SearchModule.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React, { useState, useEffect, Component, FC } from 'react';
import './SearchModule.scss';
import wfs from 'websoc-fuzzy-search';
import axios from 'axios';
import { FC, useEffect } from 'react';
import { Search } from 'react-bootstrap-icons';
import Form from 'react-bootstrap/Form';
import InputGroup from 'react-bootstrap/InputGroup';
import { Search } from 'react-bootstrap-icons';
import wfs from 'websoc-fuzzy-search';
import './SearchModule.scss';


import { searchAPIResults } from '../../helpers/util';
import { useAppDispatch, useAppSelector } from '../../store/hooks';
import { setNames, setResults } from '../../store/slices/searchSlice';
import { searchAPIResults } from '../../helpers/util';
import { SearchIndex, BatchCourseData, CourseGQLResponse, ProfessorGQLResponse, BatchProfessorData } from '../../types/types';
import { SearchIndex } from '../../types/types';

const PAGE_SIZE = 10;
const SEARCH_TIMEOUT_MS = 500;
Expand All @@ -28,7 +27,7 @@ const SearchModule: FC<SearchModuleProps> = ({ index }) => {
// Search empty string to load some results
useEffect(() => {
searchNames('');
}, [])
}, [index])

// Refresh search results when names and page number changes
useEffect(() => {
Expand All @@ -54,10 +53,10 @@ const SearchModule: FC<SearchModuleProps> = ({ index }) => {
}
})
let names: string[] = [];
if (index == 'courses') {
if (index === 'courses') {
names = Object.keys(nameResults);
}
else if (index == 'professors') {
else if (index === 'professors') {
names = Object.keys(nameResults).map(n => nameResults[n].metadata.ucinetid) as string[];
}
console.log('From frontend search', names)
Expand Down Expand Up @@ -88,7 +87,7 @@ const SearchModule: FC<SearchModuleProps> = ({ index }) => {

let coursePlaceholder = 'Search a course number or department';
let professorPlaceholder = 'Search a professor';
let placeholder = index == 'courses' ? coursePlaceholder : professorPlaceholder;
let placeholder = index === 'courses' ? coursePlaceholder : professorPlaceholder;

return <div className='search-module'>
<Form.Group className="mb-3">
Expand Down

0 comments on commit f809b59

Please sign in to comment.