-
Notifications
You must be signed in to change notification settings - Fork 107
feat: add filters to search results page #1588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
calebwongg
wants to merge
24
commits into
main
Choose a base branch
from
cwong/search-results-filter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
eed8eff
visualization method
calebwongg d0c5976
add mock filters / placeholders
calebwongg 36d98a8
add clear and delete logic
calebwongg 4399bf9
add search filter logic
calebwongg c127008
add working test scripts
calebwongg 63d6250
adjust sizing
calebwongg d26ea78
change styling
calebwongg cb999f0
adjust size of the filter button
calebwongg 62a787c
display sort filter as all uppercase
calebwongg 6fa9bab
move search filter to course pane button row
calebwongg 56ef37c
remove from sectiontable row
calebwongg 12507c5
consistent styling
calebwongg 71cbb09
Merge branch 'main' of https://github.com/icssc/AntAlmanac into cwong…
calebwongg d5f633a
remove enrollment filter
calebwongg 80c5004
update search options
calebwongg 9a27222
feat: search by gpa
calebwongg b520f19
delete day filtering
calebwongg 8f2fa33
refactor grade query logic to avoid dupe queries and race conditions'
calebwongg 962dec9
prevent promise from failing on grade queries
calebwongg e05251e
fix: merge conflicts
calebwongg 2ffc12d
feat: filter sorts whole courses instead of individual sections
calebwongg 9e8d5e4
undo random prettier formats to clean diff
calebwongg 870d9f1
fix: set gpa filter hook to falback onto the cache
calebwongg b1c0ca1
fix truthiness check on averagegpa
calebwongg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
apps/antalmanac/src/components/RightPane/SectionTable/SearchFilter.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { Sort } from '@mui/icons-material'; | ||
| import { IconButton, Menu, MenuItem, Tooltip, type SxProps } from '@mui/material'; | ||
| import { useCallback, useState } from 'react'; | ||
|
|
||
| import { SORT_OPTIONS, useSectionFilterStore, type SortOption } from '$stores/SectionFilterStore'; | ||
|
|
||
| interface SearchFilterProps { | ||
| buttonSx?: SxProps; | ||
| } | ||
|
|
||
| export function SearchFilter({ buttonSx }: SearchFilterProps) { | ||
| const { sortBy, setSortBy } = useSectionFilterStore(); | ||
| const [anchorEl, setAnchorEl] = useState<HTMLElement>(); | ||
| const open = Boolean(anchorEl); | ||
|
|
||
| const handleClick = useCallback((event: React.MouseEvent<HTMLButtonElement>) => { | ||
| setAnchorEl(event.currentTarget); | ||
| }, []); | ||
|
|
||
| const handleClose = useCallback(() => { | ||
| setAnchorEl(undefined); | ||
| }, []); | ||
|
|
||
| const handleSelect = useCallback( | ||
| (value: SortOption) => { | ||
| setSortBy(value); | ||
| handleClose(); | ||
| }, | ||
| [setSortBy, handleClose] | ||
| ); | ||
|
|
||
| const currentLabel = SORT_OPTIONS.find((o) => o.value === sortBy)?.label ?? 'Default'; | ||
|
|
||
| return ( | ||
| <> | ||
| <Tooltip title={`Sort: ${currentLabel}`}> | ||
| <IconButton onClick={handleClick} sx={buttonSx}> | ||
| <Sort /> | ||
| </IconButton> | ||
| </Tooltip> | ||
|
|
||
| <Menu anchorEl={anchorEl} open={open} onClose={handleClose}> | ||
| {SORT_OPTIONS.map((option) => ( | ||
| <MenuItem | ||
| key={option.value} | ||
| selected={option.value === sortBy} | ||
| onClick={() => handleSelect(option.value)} | ||
| > | ||
| {option.label} | ||
| </MenuItem> | ||
| ))} | ||
| </Menu> | ||
| </> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { create } from 'zustand'; | ||
|
|
||
| export const SORT_OPTIONS = [ | ||
| { value: 'default', label: 'Default' }, | ||
|
calebwongg marked this conversation as resolved.
|
||
| { value: 'status', label: 'Status' }, | ||
| { value: 'time_asc', label: 'Time' }, | ||
| { value: 'gpa_descending', label: 'GPA' }, | ||
| ] as const; | ||
|
|
||
| export type SortOption = (typeof SORT_OPTIONS)[number]['value']; | ||
|
|
||
| interface SectionFilterStore { | ||
| sortBy: SortOption; | ||
| setSortBy: (option: SortOption) => void; | ||
| } | ||
|
|
||
| export const useSectionFilterStore = create<SectionFilterStore>((set) => ({ | ||
| sortBy: 'default', | ||
| setSortBy: (sortBy) => set({ sortBy }), | ||
| })); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.