diff --git a/frontend/sportsmatch-app/src/components/AllSportsList.tsx b/frontend/sportsmatch-app/src/components/AllSportsList.tsx
index 13e70b8..01d5eab 100644
--- a/frontend/sportsmatch-app/src/components/AllSportsList.tsx
+++ b/frontend/sportsmatch-app/src/components/AllSportsList.tsx
@@ -89,6 +89,7 @@ export function AllSportsList(p: AllSportsProps) {
onChange={(query: string) => {
setSearchQuery(query)
}}
+ placeholder="Find your sport"
/>
{sportList}
diff --git a/frontend/sportsmatch-app/src/components/HostEventComponent.tsx b/frontend/sportsmatch-app/src/components/HostEventComponent.tsx
index 09d1931..65da1f7 100644
--- a/frontend/sportsmatch-app/src/components/HostEventComponent.tsx
+++ b/frontend/sportsmatch-app/src/components/HostEventComponent.tsx
@@ -290,6 +290,7 @@ function HostEventComponent() {
onChange={(query: string) => {
setSearchQuery(query)
}}
+ placeholder="search"
/>
diff --git a/frontend/sportsmatch-app/src/components/SearchBar.tsx b/frontend/sportsmatch-app/src/components/SearchBar.tsx
index f35b87e..88dd0ff 100644
--- a/frontend/sportsmatch-app/src/components/SearchBar.tsx
+++ b/frontend/sportsmatch-app/src/components/SearchBar.tsx
@@ -3,6 +3,7 @@ import '../styles/Sport.css'
interface Params {
onChange: (query: string) => void
+ placeholder: string
}
export function SearchBar(p: Params) {
@@ -16,7 +17,7 @@ export function SearchBar(p: Params) {
diff --git a/frontend/sportsmatch-app/src/pages/Index.tsx b/frontend/sportsmatch-app/src/pages/Index.tsx
index e9e99f6..0edc45d 100644
--- a/frontend/sportsmatch-app/src/pages/Index.tsx
+++ b/frontend/sportsmatch-app/src/pages/Index.tsx
@@ -3,7 +3,7 @@ import SportEvent from '../components/SportEvent'
import LoadingSpinner from '../components/LoadingSpinner'
import { SearchBar } from '../components/SearchBar'
import { useEffect, useState } from 'react'
-import { useLocation, useNavigate } from 'react-router-dom'
+import { useNavigate } from 'react-router-dom'
import '../styles/Index.css'
import {
ApiError,
@@ -17,31 +17,30 @@ import Modal from '../components/Modal'
import JoinEventComponent from '../components/JoinEventComponent'
export default function MainPage() {
- const [searchQuery, setSearchQuery] = useState('') // no implementation yet
+ const [searchQuery, setSearchQuery] = useState('')
const [filteredEvent, setFilteredEvent] = useState([])
const [selectedSports, setSelectedSports] = useState([])
const [clearFilters, setClearFilters] = useState(false)
const [selectedEvent, setSelectedEvent] = useState()
const [usersRank, setUsersRank] = useState(0)
const [userIsInRank, setUserIsInRank] = useState(false)
- const location = useLocation()
const navigate = useNavigate()
const { isOpen, toggle } = useModal()
const [page, setPage] = useState(0)
- const size = 5
-
- // search bar is not yet implemented
- useEffect(() => {
- console.log(`query`, searchQuery)
- }, [searchQuery])
+ const size = 3
// handle sports name selected from sportButtoncomponent
const handleSportSelectionChange = (selectedButtonSports: string[]) => {
setSelectedSports(selectedButtonSports)
}
+ // setting the page to 0 when selected sports change to clear the filteredEvent
+ useEffect(() => {
+ setPage(0)
+ }, [selectedSports])
+
const clear = () => {
- navigate(location.pathname, { state: undefined })
+ setPage(0)
setSelectedSports([])
setClearFilters(true)
setTimeout(() => {
@@ -83,7 +82,6 @@ export default function MainPage() {
// handle join event pop up after cliking on the event
const handleEventSelection = (e: EventDTO) => {
- window.scrollTo(0, 0)
if (isOpen) {
toggle()
}
@@ -158,6 +156,7 @@ export default function MainPage() {
onChange={(query: string) => {
setSearchQuery(query)
}}
+ placeholder="Find your place"
/>
@@ -174,15 +173,21 @@ export default function MainPage() {
{filteredEvent.length === 0 ? (
) : (
- filteredEvent.map((event, index) => (
- handleEventSelection(event)}
- >
-
-
- ))
+ filteredEvent
+ .filter((e) =>
+ e.placeDTO.name
+ .toLowerCase()
+ .includes(searchQuery.toLowerCase()),
+ )
+ .map((event, index) => (
+ handleEventSelection(event)}
+ >
+
+
+ ))
)}