diff --git a/src/components/Filter/Filter.jsx b/src/components/Filter/Filter.jsx
deleted file mode 100644
index eb0bf87..0000000
--- a/src/components/Filter/Filter.jsx
+++ /dev/null
@@ -1,56 +0,0 @@
-import styles from "./Filter.module.css";
-import Button from "../ui/button/button.tsx"
-
-function Filter({isFilterVisible, filters, setFilters}){
- const setAlphabeticalOrder = (order) => {
- setFilters(prev => ({
- ...prev,
- alphabetical : prev.alphabetical === order ? null : order
- }));
- };
-
- const setYearOrder = (order) => {
- setFilters(prev => ({
- ...prev,
- yearOrder: prev.yearOrder === order ? null : order
- }));
- };
-
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- )
-}
-
-export default Filter;
\ No newline at end of file
diff --git a/src/components/Filter/Filter.tsx b/src/components/Filter/Filter.tsx
new file mode 100644
index 0000000..d917928
--- /dev/null
+++ b/src/components/Filter/Filter.tsx
@@ -0,0 +1,78 @@
+import styles from "./Filter.module.css";
+import Button from "../ui/button/button";
+import React from "react";
+
+type FiltersType = {
+ alphabetical: "asc" | "desc" | null;
+ yearOrder: "asc" | "desc" | null;
+ [key: string]: any;
+};
+
+type FilterProps = {
+ isFilterVisible: boolean;
+ filters: FiltersType;
+ setFilters: React.Dispatch>;
+};
+
+function Filter({ isFilterVisible, filters, setFilters }: FilterProps): any {
+
+ const setAlphabeticalOrder = (order: "asc" | "desc"): void => {
+ setFilters((prev) => ({
+ ...prev,
+ alphabetical: prev.alphabetical === order ? null : order
+ }));
+ };
+
+ const setYearOrder = (order: "asc" | "desc"): void => {
+ setFilters((prev) => ({
+ ...prev,
+ yearOrder: prev.yearOrder === order ? null : order
+ }));
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default Filter;
diff --git a/src/components/SearchBar/SearchBar.jsx b/src/components/SearchBar/SearchBar.jsx
deleted file mode 100644
index a1dded2..0000000
--- a/src/components/SearchBar/SearchBar.jsx
+++ /dev/null
@@ -1,100 +0,0 @@
-import styles from "./SearchBar.module.css"
-import {Link} from "react-router";
-import {useEffect, useState} from "react";
-import searchEvents from "../../utils/events/searchEvents.js";
-import searchUsers from "../../utils/users/searchUsers.js";
-import { useLocation } from "react-router";
-
-
-function SearchBar() {
- const [searchQuery, setSearchQuery] = useState('');
- const [searchResults, setSearchResults] = useState([]);
- const location = useLocation();
-
- useEffect(() => {
- const performSearch = async (query) => {
- if (query.trim() === '') {
- setSearchResults([]);
- return;
- }
-
- let data;
-
- if (location.pathname.includes("events")) {
- data = await searchEvents(query);
- } else if (location.pathname.includes("volunteers")) {
- data = await searchUsers(query);
- }
-
-
- if (data) {
- setSearchResults(data);
- } else {
- setSearchResults([]);
- }
- };
-
-
- const handler = setTimeout(() => {
- performSearch(searchQuery);
- }, 300);
-
- return () => {
- clearTimeout(handler);
- };
- }, [searchQuery]);
-
- return (
-
-
-
-
- {searchResults.length > 0 ? (
-
- ) : null}
-
-
-
- {searchResults.map((result, i) => (
- (location.pathname.includes("events")) ? (
-
-
-
- {result.image == null ? (
-

- ) : (
-

- )}
-
-
{result.name}
-
-
- ) : location.pathname.includes("volunteers") ? (
-
-
-
- {result.image == null ? (
-

- ) : (
-

- )}
-
-
{result.name} {result.lastname}
-
-
- ) : null
- ))}
-
-
- );
-}
-
-export default SearchBar;
\ No newline at end of file
diff --git a/src/components/SearchBar/SearchBar.module.css b/src/components/SearchBar/SearchBar.module.css
index d35c808..c6a093d 100644
--- a/src/components/SearchBar/SearchBar.module.css
+++ b/src/components/SearchBar/SearchBar.module.css
@@ -1,6 +1,8 @@
.searchBarContainer{
position: fixed;
- top: 4rem;
+ top: 20vh;
+ left: 50%;
+ transform: translateX(-50%);
z-index: 100;
width: 60%;
background: #fff;
diff --git a/src/components/SearchBar/SearchBar.tsx b/src/components/SearchBar/SearchBar.tsx
new file mode 100644
index 0000000..d1ef4c6
--- /dev/null
+++ b/src/components/SearchBar/SearchBar.tsx
@@ -0,0 +1,120 @@
+import styles from "./SearchBar.module.css";
+import { Link } from "react-router";
+import { useEffect, useState } from "react";
+import searchEvents from "../../utils/events/searchEvents.js";
+import searchUsers from "../../utils/users/searchUsers.js";
+import { useLocation } from "react-router";
+
+function SearchBar(): any {
+ const [searchQuery, setSearchQuery] = useState("");
+ const [searchResults, setSearchResults] = useState([]);
+ const location: any = useLocation();
+
+ useEffect(() => {
+ const performSearch = async (query: string): Promise => {
+ if (query.trim() === "") {
+ setSearchResults([]);
+ return;
+ }
+
+ let data: any;
+
+ if (location.pathname.includes("events")) {
+ data = await searchEvents(query);
+ } else if (location.pathname.includes("volunteers")) {
+ data = await searchUsers(query);
+ }
+
+ if (data) {
+ setSearchResults(data);
+ } else {
+ setSearchResults([]);
+ }
+ };
+
+ const handler: ReturnType = setTimeout(() => {
+ performSearch(searchQuery);
+ }, 300);
+
+ return () => {
+ clearTimeout(handler);
+ };
+ }, [searchQuery, location.pathname]);
+
+ return (
+
+
+
+
+ {searchResults.length > 0 ? (
+
+ ) : null}
+
+
+
+ {searchResults.map((result: any, i: number) =>
+ location.pathname.includes("events") ? (
+
+
+
+ {result.image == null ? (
+

+ ) : (
+

+ )}
+
+
{result.name}
+
+
+ ) : location.pathname.includes("volunteers") ? (
+
+
+
+ {result.image == null ? (
+

+ ) : (
+

+ )}
+
+
+ {result.name} {result.lastname}
+
+
+
+ ) : null
+ )}
+
+
+ );
+}
+
+export default SearchBar;
diff --git a/src/components/ToolBar/ToolBar.jsx b/src/components/ToolBar/ToolBar.jsx
index 874fa70..4461da7 100644
--- a/src/components/ToolBar/ToolBar.jsx
+++ b/src/components/ToolBar/ToolBar.jsx
@@ -1,59 +1,16 @@
import styles from "./ToolBar.module.css"
-import Filter from "../Filter/Filter.jsx";
-import {useContext, useEffect, useState} from "react";
-import SearchBar from "../SearchBar/SearchBar.jsx";
-import CreateEventBtn from "../createEventBtn/CreateEventBtn.jsx";
-import Button from "../ui/button/button.tsx";
-import {AuthContext} from "../../contexts/auth/AuthContext.js";
+import CreateEventBtn from "./tools/createEventBtn/CreateEventBtn.jsx";
+import SearchBtn from "./tools/SearchBtn.tsx";
+import FilterBtn from "./tools/FilterBtn.tsx";
function ToolBar({setFilters, filters, showCreate = true}) {
- const { user } = useContext(AuthContext);
- const [isFilterVisible, setIsFilterVisible] = useState(false);
- const [isSearchVisible, setIsSearchVisible] = useState(false);
- const toggleFilters = () => {
- setIsFilterVisible(prev => !prev);
- };
-
-
- useEffect(() => {
- if (isSearchVisible) {
- document.documentElement.style.overflow = 'hidden';
- } else {
- document.documentElement.style.overflow = '';
- }
-
- return () => {
- document.documentElement.style.overflow = '';
- };
- }, [isSearchVisible]);
-
-
return (
- {isSearchVisible ? (
-
-
setIsSearchVisible(false)}>
-
-
- ) : null}
- {showCreate && user.isAdmin ? (
-
- ) : null}
-
-
-
-
-
-
-
-
-
+ {showCreate &&
}
+
+
);
diff --git a/src/components/ToolBar/tools/FilterBtn.tsx b/src/components/ToolBar/tools/FilterBtn.tsx
new file mode 100644
index 0000000..0f87ae9
--- /dev/null
+++ b/src/components/ToolBar/tools/FilterBtn.tsx
@@ -0,0 +1,32 @@
+import styles from "../ToolBar.module.css"
+import Button from "../../ui/button/button";
+import { useState } from "react";
+import Filter from "../../Filter/Filter";
+
+interface Filters {
+ alphabetical: "asc" | "desc";
+ yearOrder: "asc" | "desc";
+}
+
+interface FilterBtnProps {
+ setFilters: any
+ filters: Filters
+}
+
+export default function FilterBtn({ setFilters, filters }: FilterBtnProps) {
+
+ const [isFilterVisible, setIsFilterVisible] = useState(false);
+
+ const toggleFilters = () => {
+ setIsFilterVisible(prev => !prev);
+ };
+
+ return
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/src/components/ToolBar/tools/SearchBtn.tsx b/src/components/ToolBar/tools/SearchBtn.tsx
new file mode 100644
index 0000000..316db18
--- /dev/null
+++ b/src/components/ToolBar/tools/SearchBtn.tsx
@@ -0,0 +1,38 @@
+import styles from "../ToolBar.module.css"
+import Button from "../../ui/button/button";
+import { useEffect, useState } from "react";
+import SearchBar from "../../SearchBar/SearchBar";
+
+export default function SearchBtn() {
+
+ const [isSearchVisible, setIsSearchVisible] = useState(false);
+
+ useEffect(() => {
+ if (isSearchVisible) {
+ document.documentElement.style.overflow = 'hidden';
+ } else {
+ document.documentElement.style.overflow = '';
+ }
+
+ return () => {
+ document.documentElement.style.overflow = '';
+ };
+ }, [isSearchVisible]);
+
+ return <>
+
+ {isSearchVisible ? (
+
+
setIsSearchVisible(false)}>
+
+
+ ) : null}
+
+
+
+
+
+ >
+}
\ No newline at end of file
diff --git a/src/components/createEventBtn/CreateEventBtn.jsx b/src/components/ToolBar/tools/createEventBtn/CreateEventBtn.jsx
similarity index 85%
rename from src/components/createEventBtn/CreateEventBtn.jsx
rename to src/components/ToolBar/tools/createEventBtn/CreateEventBtn.jsx
index 019b836..11b96d6 100644
--- a/src/components/createEventBtn/CreateEventBtn.jsx
+++ b/src/components/ToolBar/tools/createEventBtn/CreateEventBtn.jsx
@@ -1,14 +1,16 @@
import styles from "./createEventBtn.module.css"
import { useState, useContext } from "react";
-import Modal from "../ui/modal/modal.tsx";
-import Button from "../ui/button/button.tsx";
-import TextInput from "../ui/input/input.tsx";
-import { EventContext } from "../../contexts/events/EventContext.js";
+import Modal from "../../../ui/modal/modal.tsx";
+import Button from "../../../ui/button/button.tsx";
+import TextInput from "../../../ui/input/input.tsx";
+import { EventContext } from "../../../../contexts/events/EventContext.js";
+import {AuthContext} from "../../../../contexts/auth/AuthContext.ts";
export default function CreateEventBtn() {
const { addEvent } = useContext(EventContext);
+ const { user } = useContext(AuthContext);
const [isOpen, setIsOpen] = useState(false);
const [name, setName] = useState("");
@@ -24,6 +26,8 @@ export default function CreateEventBtn() {
setIsOpen(false);
}
+ if(!user.isAdmin) return null;
+
return <>
diff --git a/src/components/createEventBtn/createEventBtn.module.css b/src/components/ToolBar/tools/createEventBtn/createEventBtn.module.css
similarity index 100%
rename from src/components/createEventBtn/createEventBtn.module.css
rename to src/components/ToolBar/tools/createEventBtn/createEventBtn.module.css