) => {
course.sectionId =
- newSection !== null
+ newSection != null
? course.courseData.sections.findIndex(
(s) => s.number === newSection.number,
)
@@ -206,27 +210,24 @@ function SectionDropdown(props: { course: CourseStorage }) {
return (
-
);
@@ -409,20 +410,10 @@ function WorkspaceSearch() {
const indexedCourses = use(AllCourses);
const courses = Object.values(indexedCourses);
- // For some reason, options = [] on the second render, even though
- // courses = [...] by then and options should equal courses.
- // I came up with this hacky solution to get around that...
- // The dropdown options should re-render properly
- let [options, setOptions] = useState(courses);
- const [firstLoad, setFirstLoad] = useState(true);
- if (firstLoad && options.length === 0) {
- options = courses;
- }
-
const [selectedCourse, setCourse] = useState>(null);
- const handleSelect = (courseData: SingleValue) => {
- setCourse(courseData as CourseData);
+ const handleSelect = (courseData: Maybe) => {
+ setCourse(courseData);
if (courseData) {
state.addCourse({
courseData: courseData,
@@ -438,25 +429,26 @@ function WorkspaceSearch() {
selector: (item) => `${item.number} ${item.name}`,
});
- const sortCourses = (input: string) => {
- setOptions(fzf.find(input).map((item) => item.item));
- setFirstLoad(false);
- };
-
return (
-