From 0b0d9e8a79081d48d5554dac93d6c1eee91eceb2 Mon Sep 17 00:00:00 2001 From: WeiViv <100058931+WeiViv@users.noreply.github.com> Date: Sat, 12 Oct 2024 15:44:14 -0500 Subject: [PATCH] build(edit course, style courses on the profile card, course filter): 1. write the util functions to use the courses data stored in firestore 2. build the course selection section on the edit profile page 3. style the profile page 4. build the course filter on home page --- src/components/Home/StudentFilter.jsx | 29 ++++++++++++++++-- src/components/Home/StudentList.jsx | 11 +++++-- src/components/HomePage.jsx | 4 +++ src/components/Profile/EditProfile.jsx | 41 ++++++++++++++++++++++---- src/components/Profile/ProfilePage.jsx | 17 ++++++----- src/hooks/data/useCourses.js | 21 +++++++++++++ src/hooks/useEditProfileForm.js | 29 +++++++++++++----- src/utils/firestore/general.js | 24 +++++++++++++++ 8 files changed, 149 insertions(+), 27 deletions(-) create mode 100644 src/hooks/data/useCourses.js diff --git a/src/components/Home/StudentFilter.jsx b/src/components/Home/StudentFilter.jsx index ab2fb9e..46a0fdc 100644 --- a/src/components/Home/StudentFilter.jsx +++ b/src/components/Home/StudentFilter.jsx @@ -1,5 +1,6 @@ import React from 'react'; +import useCourses from '@data/useCourses'; import useMajors from '@data/useMajors'; import { Box, @@ -16,10 +17,13 @@ import { export default function StudentFilter({ selectedMajors, setSelectedMajors, + selectedCourses, + setSelectedCourses, selectedYears, setSelectedYears, }) { const majorsList = useMajors(); + const coursesList = useCourses(); return ( @@ -36,7 +40,28 @@ export default function StudentFilter({ sx={{ flex: 1, mb: 2, minWidth: 200, maxWidth: '100%' }} /> - {/* 2. Year filter */} + {/* 2. Course filter */} + option} + value={selectedCourses} + onChange={(event, newValue) => setSelectedCourses(newValue)} + renderInput={(params) => ( + + )} + filterOptions={(options, { inputValue }) => { + // Convert inputValue to lowercase for case-insensitive matching + const lowercasedInput = inputValue.toLowerCase(); + + // Only include options that start with the input + return options.filter((option) => option.toLowerCase().startsWith(lowercasedInput)); + }} + sx={{ flex: 1, mb: 2, minWidth: 200, maxWidth: '100%' }} + freeSolo + /> + + {/* 3. Year filter */} Filter by Year(s)