-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: search course info button (#1082)
- Loading branch information
1 parent
5f667ab
commit 5c5ab75
Showing
21 changed files
with
94 additions
and
57 deletions.
There are no files selected for viewing
This file contains 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 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 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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 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 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 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 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
53 changes: 53 additions & 0 deletions
53
apps/antalmanac/src/components/RightPane/SectionTable/CourseInfo/CourseInfoSearchButton.tsx
This file contains 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,53 @@ | ||
import RightPaneStore from '$components/RightPane/RightPaneStore'; | ||
import { useCoursePaneStore } from '$stores/CoursePaneStore'; | ||
import { useTabStore } from '$stores/TabStore'; | ||
import { Search } from '@material-ui/icons'; | ||
import { Button } from '@mui/material'; | ||
import { AACourse } from '@packages/antalmanac-types'; | ||
import { useCallback } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
/** | ||
* Routes the user to the corresponding search result | ||
*/ | ||
export function CourseInfoSearchButton({ courseDetails, term }: { courseDetails: AACourse; term: string }) { | ||
const { setActiveTab } = useTabStore(); | ||
const { displaySections } = useCoursePaneStore(); | ||
|
||
const { deptCode, courseNumber } = courseDetails; | ||
|
||
const handleClick = useCallback(() => { | ||
RightPaneStore.updateFormValue('deptValue', deptCode); | ||
RightPaneStore.updateFormValue('courseNumber', courseNumber); | ||
RightPaneStore.updateFormValue('term', term); | ||
|
||
displaySections(); | ||
setActiveTab(1); | ||
}, []); | ||
|
||
const queryParams = { | ||
term: term, | ||
deptValue: deptCode, | ||
courseNumber: courseNumber, | ||
}; | ||
|
||
const href = `/?${Object.entries(queryParams) | ||
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`) | ||
.join('&')}`; | ||
|
||
return ( | ||
<div> | ||
<Button | ||
variant="contained" | ||
size="small" | ||
color="primary" | ||
style={{ minWidth: 'fit-content' }} | ||
to={href} | ||
component={Link} | ||
onClick={handleClick} | ||
> | ||
<Search /> | ||
</Button> | ||
</div> | ||
); | ||
} |
This file contains 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 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 |
---|---|---|
|
@@ -18,5 +18,3 @@ export const useTabStore = create<TabStore>((set) => { | |
}, | ||
}; | ||
}); | ||
|
||
export default useTabStore; |