diff --git a/src/components/search/filter/search-filter-date-select.tsx b/src/components/search/filter/search-filter-date-select.tsx
index eb747d3..49cc4ef 100644
--- a/src/components/search/filter/search-filter-date-select.tsx
+++ b/src/components/search/filter/search-filter-date-select.tsx
@@ -1,40 +1,38 @@
+import { useCallback } from "react";
import { Calendar } from "@/components/ui/calendar";
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover";
+import { useSearchContext } from "@/contexts/search-context/search-context";
import { cn } from "@/lib/utils";
import { format } from "date-fns";
import { CalendarIcon } from "lucide-react";
import { Button } from "../../ui/button";
-interface SearchFilterDateSelectProps {
- onStartChange: (input: Date | undefined) => void;
- onEndChange: (input: Date | undefined) => void;
- start: Date | undefined;
- end: Date | undefined;
-}
+export function SearchFilterDateSelect() {
+ const { start, setStart, end, setEnd } = useSearchContext();
-export function SearchFilterDateSelect({
- onStartChange,
- onEndChange,
- start,
- end,
-}: SearchFilterDateSelectProps) {
- const handleStartChange = (date: Date | undefined) => {
- if (!date) {
- console.error("No start date selected");
- return;
- }
+ const handleStartChange = useCallback(
+ (date: Date | undefined) => {
+ if (!date) {
+ console.error("No start date selected");
+ return;
+ }
- onStartChange(date);
- };
+ setStart(date);
+ },
+ [setStart]
+ );
- const handleEndChange = (date: Date | undefined) => {
- onEndChange(date);
- };
+ const handleEndChange = useCallback(
+ (date: Date | undefined) => {
+ setEnd(date);
+ },
+ [setEnd]
+ );
return (
diff --git a/src/components/search/filter/search-filter-institution-dropdown.tsx b/src/components/search/filter/search-filter-institution-dropdown.tsx
index 5859c85..c7aee3f 100644
--- a/src/components/search/filter/search-filter-institution-dropdown.tsx
+++ b/src/components/search/filter/search-filter-institution-dropdown.tsx
@@ -6,19 +6,19 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
+import { useSearchContext } from "@/contexts/search-context/search-context";
interface SearchFilterInstitutionDropdownProps {
- value: string;
- onChange: (input: string) => void;
courses: CourseObject[] | undefined;
}
export function SearchFilterInstitutionDropdown({
- value,
- onChange,
courses,
}: SearchFilterInstitutionDropdownProps) {
- const uniqueColleges = value == "Any Institution" ? [] : [value];
+ const { institution, setInstitution } = useSearchContext();
+
+ const uniqueColleges =
+ institution == "Any Institution" ? [] : [institution];
const sendingInstitutions = courses?.map(
(course: CourseObject) => course.sendingInstitution
@@ -40,8 +40,8 @@ export function SearchFilterInstitutionDropdown({
Teaching Institution