@@ -73,7 +81,7 @@ const ExploreRoute: React.FC = () => {
type="text"
id="search-category-type"
name="category"
- value=""
+ value={categories.join(",")}
hidden
/>
diff --git a/client/app/routes/search.tsx b/client/app/routes/search.tsx
index 2d1e023e..28ff8191 100644
--- a/client/app/routes/search.tsx
+++ b/client/app/routes/search.tsx
@@ -1,107 +1,81 @@
-import React, { useState } from "react";
-
+import React from "react";
+import { useSearch } from "../context/searchContext";
+import Checkbox from "../components/checkbox";
+import { CATEGORIES } from "../utils/constants";
const SearchRoute: React.FC = () => {
-const [categories, setCategories] = useState
([]);
+ const {
+ handleCategoryTypeChange,
+ handleSearch,
+ handleQueryChange,
+ categories,
+ results,
+ query,
+ } = useSearch();
- const handleCategoryTypeChange = (type: string) => {
- if (categories.includes(type)) {
- setCategories(categories.filter((category) => category !== type));
- } else {
- setCategories([...categories, type]);
- }
+ const onSubmit = (e: React.FormEvent) => {
+ e.preventDefault();
+ handleSearch(new FormData(e.currentTarget));
};
return (
);
};
-export default SearchRoute;
\ No newline at end of file
+export default SearchRoute;
diff --git a/client/app/utils/constants.ts b/client/app/utils/constants.ts
new file mode 100644
index 00000000..bc1e3b89
--- /dev/null
+++ b/client/app/utils/constants.ts
@@ -0,0 +1 @@
+export const CATEGORIES = ["places", "resources", "activities", "sources", "media"];
\ No newline at end of file