Skip to content

Commit

Permalink
feat: add search button
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinWu098 committed Dec 22, 2024
1 parent 5653bf8 commit 12527fe
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 27 deletions.
6 changes: 3 additions & 3 deletions apps/antalmanac/src/components/Calendar/CalendarRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { CalendarEvent, CourseEvent } from './CourseCalendarEvent';
import { CalendarCourseEvent } from '$components/Calendar/CalendarCourseEvent';
import { CalendarCourseEventWrapper } from '$components/Calendar/CalendarCourseEventWrapper';
import { CalendarEventPopover } from '$components/Calendar/CalendarEventPopover';
import { CalendarToolbar } from '$components/Calendar/toolbar/CalendarToolbar';
import { CalendarToolbar } from '$components/Calendar/Toolbar/CalendarToolbar';
import { getDefaultFinalsStartDate, getFinalsStartDateForTerm } from '$lib/termData';
import AppStore from '$stores/AppStore';
import { useHoveredStore } from '$stores/HoveredStore';
Expand Down Expand Up @@ -114,8 +114,8 @@ export const ScheduleCalendar = memo(() => {
const finalsDate = hoveredCalendarizedFinal
? getFinalsStartDateForTerm(hoveredCalendarizedFinal.term)
: onlyCourseEvents.length > 0
? getFinalsStartDateForTerm(onlyCourseEvents[0].term)
: getDefaultFinalsStartDate();
? getFinalsStartDateForTerm(onlyCourseEvents[0].term)
: getDefaultFinalsStartDate();

const finalsDateFormat = finalsDate ? 'ddd MM/DD' : 'ddd';
const date = showFinalsSchedule && finalsDate ? finalsDate : new Date(2018, 0, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Event } from 'react-big-calendar';
import { Link } from 'react-router-dom';

import { deleteCourse, deleteCustomEvent } from '$actions/AppStoreActions';
import CustomEventDialog from '$components/Calendar/toolbar/CustomEventDialog/';
import CustomEventDialog from '$components/Calendar/Toolbar/CustomEventDialog/';
import ColorPicker from '$components/ColorPicker';
import analyticsEnum, { logAnalytics } from '$lib/analytics';
import buildingCatalogue from '$lib/buildingCatalogue';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Box, Button, IconButton, Paper, Tooltip } from '@mui/material';
import { useState, useCallback, useEffect, memo } from 'react';

import { undoDelete } from '$actions/AppStoreActions';
import CustomEventDialog from '$components/Calendar/toolbar/CustomEventDialog';
import { SelectSchedulePopover } from '$components/Calendar/toolbar/ScheduleSelect/ScheduleSelect';
import CustomEventDialog from '$components/Calendar/Toolbar/CustomEventDialog';
import { SelectSchedulePopover } from '$components/Calendar/Toolbar/ScheduleSelect/ScheduleSelect';
import { ClearScheduleButton } from '$components/buttons/Clear';
import DownloadButton from '$components/buttons/Download';
import ScreenshotButton from '$components/buttons/Screenshot';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { Box, Button, Popover, Typography, useTheme, Tooltip } from '@mui/materi
import { useCallback, useEffect, useMemo, useState } from 'react';

import { changeCurrentSchedule } from '$actions/AppStoreActions';
import { AddScheduleButton } from '$components/Calendar/toolbar/ScheduleSelect/schedule-select-buttons/AddScheduleButton';
import { DeleteScheduleButton } from '$components/Calendar/toolbar/ScheduleSelect/schedule-select-buttons/DeleteScheduleButton';
import { RenameScheduleButton } from '$components/Calendar/toolbar/ScheduleSelect/schedule-select-buttons/RenameScheduleButton';
import { AddScheduleButton } from '$components/Calendar/Toolbar/ScheduleSelect/schedule-select-buttons/AddScheduleButton';
import { DeleteScheduleButton } from '$components/Calendar/Toolbar/ScheduleSelect/schedule-select-buttons/DeleteScheduleButton';
import { RenameScheduleButton } from '$components/Calendar/Toolbar/ScheduleSelect/schedule-select-buttons/RenameScheduleButton';
import { CopyScheduleButton } from '$components/buttons/Copy';
import analyticsEnum, { logAnalytics } from '$lib/analytics';
import AppStore from '$stores/AppStore';
Expand Down
18 changes: 8 additions & 10 deletions apps/antalmanac/src/components/Map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,13 @@ export default function CourseMap() {
*/
const startDestPairs = useMemo(() => {
const allEvents = [...markersToDisplay, ...customEventMarkersToDisplay];
return allEvents.reduce(
(acc, cur, index) => {
acc.push([cur]);
if (index > 0) {
acc[index - 1].push(cur);
}
return acc;
},
[] as (typeof allEvents)[]
);
return allEvents.reduce((acc, cur, index) => {
acc.push([cur]);
if (index > 0) {
acc[index - 1].push(cur);
}
return acc;
}, [] as (typeof allEvents)[]);
}, [markersToDisplay, customEventMarkersToDisplay]);

return (
Expand Down Expand Up @@ -357,6 +354,7 @@ export default function CourseMap() {
<Fragment key={Object.values(marker).join('')}>
<LocationMarker
{...marker}
key={marker.key}
label={today === 'All' ? undefined : (index + 1).toString()}
stackIndex={coursesSameBuildingPrior.length}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Link } from 'react-router-dom';
import ColorPicker from '../../ColorPicker';

import { deleteCustomEvent } from '$actions/AppStoreActions';
import CustomEventDialog from '$components/Calendar/toolbar/CustomEventDialog/';
import CustomEventDialog from '$components/Calendar/Toolbar/CustomEventDialog/';
import analyticsEnum from '$lib/analytics';
import buildingCatalogue from '$lib/buildingCatalogue';
import AppStore from '$stores/AppStore';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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);
}, []);

return (
<div>
<Button
variant="contained"
size="small"
color="primary"
style={{ minWidth: 'fit-content' }}
to={`/?term=${term}&deptValue=${deptCode}&courseNumber=${courseNumber}`}
component={Link}
onClick={handleClick}
>
<Search />
</Button>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ import analyticsEnum from '$lib/analytics';
import { useColumnStore, SECTION_TABLE_COLUMNS, type SectionTableColumn } from '$stores/ColumnStore';
import { CourseInfoButton } from '$components/RightPane/SectionTable/CourseInfo/CourseInfoButton';
import { CourseInfoBar } from '$components/RightPane/SectionTable/CourseInfo/CourseInfoBar';
import { CourseInfoSearchButton } from '$components/RightPane/SectionTable/CourseInfo/CourseInfoSearchButton';
import { useTabStore } from '$stores/TabStore';

const TOTAL_NUM_COLUMNS = SECTION_TABLE_COLUMNS.length;

// uncomment when we get past enrollment data back and restore the files (https://github.com/icssc/AntAlmanac/tree/5e89e035e66f00608042871d43730ba785f756b0/src/components/RightPane/SectionTable/EnrollmentGraph)
// import AlmanacGraph from '../EnrollmentGraph/EnrollmentGraph';

interface TableHeaderColumnDetails {
label: string;
width?: string;
Expand Down Expand Up @@ -108,7 +107,7 @@ function SectionTable(props: SectionTableProps) {
const { courseDetails, term, allowHighlight, scheduleNames, analyticsCategory } = props;

const [activeColumns] = useColumnStore((store) => [store.activeColumns]);

const [activeTab] = useTabStore((store) => [store.activeTab]);
const isMobileScreen = useMediaQuery(`(max-width: ${MOBILE_BREAKPOINT})`);

const courseId = useMemo(() => {
Expand All @@ -135,7 +134,7 @@ function SectionTable(props: SectionTableProps) {
analyticsCategory={analyticsCategory}
/>

<CourseInfoButton analyticsCategory="" analyticsAction="" text="" icon={<Search />} />
{activeTab === 2 ? <CourseInfoSearchButton courseDetails={courseDetails} term={term} /> : null}

<CourseInfoButton
analyticsCategory={analyticsCategory}
Expand Down
2 changes: 0 additions & 2 deletions apps/antalmanac/src/stores/TabStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,3 @@ export const useTabStore = create<TabStore>((set) => {
},
};
});

export default useTabStore;

0 comments on commit 12527fe

Please sign in to comment.