From da5808ca2ff404caf81bf90ddfa30b702295adea Mon Sep 17 00:00:00 2001 From: Kevin Wu Date: Thu, 11 Apr 2024 16:13:33 -0700 Subject: [PATCH 1/3] feat: remove unused filters --- components/search/filter/Filters.tsx | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/components/search/filter/Filters.tsx b/components/search/filter/Filters.tsx index 75a3924..1fe8037 100644 --- a/components/search/filter/Filters.tsx +++ b/components/search/filter/Filters.tsx @@ -3,7 +3,6 @@ import { CalendarFilter, CustomFilterCheckbox, InstitutionDropdown, - UnitsFilter, } from "./FilterComponents"; import { FaCircleXmark } from "react-icons/fa6"; import { CourseObject, FilterValues } from "../Search"; @@ -25,13 +24,10 @@ interface SearchFilterProps { export const SearchFilters = (props: SearchFilterProps) => { const { setFormat, - setEnrollment, setAvailable, setStart, setEnd, setInstitution, - setMin, - setMax, filterValues, courses, } = props; @@ -44,14 +40,6 @@ export const SearchFilters = (props: SearchFilterProps) => { onChange={setFormat} defaultValue={filterValues.format} /> - { onChange={setInstitution} courses={courses} /> - ); }; From fcfe54d64704282bb4e578ffa2acf57d97eb91c0 Mon Sep 17 00:00:00 2001 From: Kevin Wu Date: Thu, 11 Apr 2024 16:18:04 -0700 Subject: [PATCH 2/3] feat: default startDate to undefined --- components/search/Search.tsx | 4 ++-- components/search/filter/FilterComponents.tsx | 9 +++------ components/search/filter/Filters.tsx | 2 +- lib/utils/filter.ts | 8 ++++++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/search/Search.tsx b/components/search/Search.tsx index 3a72136..43ccf1e 100644 --- a/components/search/Search.tsx +++ b/components/search/Search.tsx @@ -47,7 +47,7 @@ export type FilterValues = { format: boolean[]; enrollment: boolean[]; available: boolean[]; - start: Date; + start: Date | undefined; end: Date | undefined; institution: string; min: number; @@ -106,7 +106,7 @@ const Search = () => { const [format, setFormat] = useState([true, true]); const [enrollment, setEnrollment] = useState([true]); const [available, setAvailable] = useState([true]); - const [start, setStart] = useState(new Date()); + const [start, setStart] = useState(); const [end, setEnd] = useState(); const [institution, setInstitution] = useState("Any Institution"); const [min, setMin] = useState(0); diff --git a/components/search/filter/FilterComponents.tsx b/components/search/filter/FilterComponents.tsx index 49e6fae..3a89fe8 100644 --- a/components/search/filter/FilterComponents.tsx +++ b/components/search/filter/FilterComponents.tsx @@ -77,18 +77,16 @@ export const CustomFilterCheckbox = (props: FilterCheckboxProps) => { }; interface CalendarFilterProps { - onStartChange: Dispatch>; + onStartChange: Dispatch>; onEndChange: Dispatch>; - defaultStart: Date; + defaultStart: Date | undefined; defaultEnd: Date | undefined; } export const CalendarFilter = (props: CalendarFilterProps) => { const { onStartChange, onEndChange, defaultStart, defaultEnd } = props; - const [startDate, setStartDate] = useState( - defaultStart ? new Date(defaultStart) : new Date(), - ); + const [startDate, setStartDate] = useState(defaultStart); const [endDate, setEndDate] = useState(defaultEnd); const handleStartChange = (date: Date | undefined) => { @@ -138,7 +136,6 @@ export const CalendarFilter = (props: CalendarFilterProps) => { selected={startDate} onSelect={handleStartChange} initialFocus - required /> diff --git a/components/search/filter/Filters.tsx b/components/search/filter/Filters.tsx index 1fe8037..9ab12d7 100644 --- a/components/search/filter/Filters.tsx +++ b/components/search/filter/Filters.tsx @@ -12,7 +12,7 @@ interface SearchFilterProps { setFormat: Dispatch>; setEnrollment: Dispatch>; setAvailable: Dispatch>; - setStart: Dispatch>; + setStart: Dispatch>; setEnd: Dispatch>; setInstitution: Dispatch>; setMin: Dispatch>; diff --git a/lib/utils/filter.ts b/lib/utils/filter.ts index 0a24fce..736e550 100644 --- a/lib/utils/filter.ts +++ b/lib/utils/filter.ts @@ -1,6 +1,10 @@ import { CourseObject, FilterValues } from "../../components/search/Search"; -export const startsAfter = (start: Date, result: CourseObject) => { +export const startsAfter = (start: Date | undefined, result: CourseObject) => { + if (start === undefined) { + return true; + } + const courseDate = new Date(result.startDate); courseDate.setHours(0, 0, 0, 0); @@ -10,7 +14,7 @@ export const startsAfter = (start: Date, result: CourseObject) => { }; export const endsBefore = (end: Date | undefined, result: CourseObject) => { - if (end == undefined) { + if (end === undefined) { return true; } From 8293747ccc2d84b7ed67e840d3d53d01cdb5b5de Mon Sep 17 00:00:00 2001 From: Kevin Wu Date: Thu, 11 Apr 2024 16:19:06 -0700 Subject: [PATCH 3/3] feat: default available seats to false --- components/search/Search.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/search/Search.tsx b/components/search/Search.tsx index 43ccf1e..554ae3b 100644 --- a/components/search/Search.tsx +++ b/components/search/Search.tsx @@ -105,7 +105,7 @@ const Search = () => { const [format, setFormat] = useState([true, true]); const [enrollment, setEnrollment] = useState([true]); - const [available, setAvailable] = useState([true]); + const [available, setAvailable] = useState([false]); const [start, setStart] = useState(); const [end, setEnd] = useState(); const [institution, setInstitution] = useState("Any Institution");