diff --git a/src/components/Event/Event.jsx b/src/components/Event/Event.jsx
index deaec58..f3941b5 100644
--- a/src/components/Event/Event.jsx
+++ b/src/components/Event/Event.jsx
@@ -39,18 +39,20 @@ function Event({event}){
{event.name}
{event.description}
-
-
- {event.tasks
- .slice(0,5)
- .map((task, index) => (
- - - {task.name}
- ))}
- {event.tasks.length > 5 ? (
- - ...
- ) : null}
-
-
+ {event.tasks != null ? (
+
+
+ {event.tasks
+ .slice(0,5)
+ .map((task, index) => (
+ - - {task.name}
+ ))}
+ {event.tasks.length > 5 ? (
+ - ...
+ ) : null}
+
+
+ ) : null}
{windowSize.width > 768 ? (
diff --git a/src/components/SearchBar/SearchBar.jsx b/src/components/SearchBar/SearchBar.jsx
index fb7da99..8df2beb 100644
--- a/src/components/SearchBar/SearchBar.jsx
+++ b/src/components/SearchBar/SearchBar.jsx
@@ -1,16 +1,19 @@
import styles from "./SearchBar.module.css"
-function SearchBar() {
-
-
+function SearchBar({ searchQuery, setSearchQuery}) {
return (
);
diff --git a/src/pages/Events/EventsPage.jsx b/src/pages/Events/EventsPage.jsx
index 83f1e32..fba2bdf 100644
--- a/src/pages/Events/EventsPage.jsx
+++ b/src/pages/Events/EventsPage.jsx
@@ -4,11 +4,14 @@ import {Link} from "react-router";
import styles from "./EventsPage.module.css";
import Filter from "../../components/Filter/Filter.jsx";
import SearchBar from "../../components/SearchBar/SearchBar.jsx";
+import searchEvents from "../../utils/searchEvents.js"
function EventsPage(){
const [isFilterVisible, setIsFilterVisible] = useState(false);
const [isSearchVisible, setIsSearchVisible] = useState(false);
+ const [searchQuery, setSearchQuery] = useState('');
+ const [searchResults, setSearchResults] = useState([]);
const toggleFilters = () => {
setIsFilterVisible(prev => !prev);
};
@@ -18,17 +21,34 @@ function EventsPage(){
yearOrder: "asc",
});
+
+
+
useEffect(() => {
- if (isSearchVisible) {
- document.getElementById("root").style.overflow = 'hidden';
- } else {
- document.getElementById("root").style.overflow = '';
- }
+ const performSearch = async (query) => {
+ if (query.trim() === '') {
+ setSearchResults([]);
+ return;
+ }
+
+ const data = await searchEvents(query);
+ if (data) {
+ setSearchResults(data);
+ } else {
+ setSearchResults([]);
+ }
+ };
+
+
+ const handler = setTimeout(() => {
+ performSearch(searchQuery);
+ }, 300);
return () => {
- document.getElementById("root").style.overflow = '';
+ clearTimeout(handler);
};
- }, [isSearchVisible]);
+ }, [searchQuery]);
+
const [events] = useState([
{
@@ -239,7 +259,13 @@ function EventsPage(){
{isSearchVisible ? (
setIsSearchVisible(false)}>
-
+
+ {searchResults.map((event, index) => (
+
+ ))}
) : null}
diff --git a/src/pages/Events/EventsPage.module.css b/src/pages/Events/EventsPage.module.css
index bc8aa08..6c7a2a5 100644
--- a/src/pages/Events/EventsPage.module.css
+++ b/src/pages/Events/EventsPage.module.css
@@ -41,8 +41,6 @@
width: 100%;
height: 100%;
z-index: 100;
- background-color: rgba(0, 0, 0, 0.3);
- backdrop-filter: blur(4px);
}