Skip to content

Commit

Permalink
SMA-105: places are now search by input from the searchbar
Browse files Browse the repository at this point in the history
  • Loading branch information
ivamach committed May 2, 2024
1 parent 6a0fecf commit d213d4b
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions frontend/sportsmatch-app/src/pages/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function MainPage() {
selectedSports,
0,
0,
searchQuery,
page,
size,
)
Expand All @@ -70,7 +71,7 @@ export default function MainPage() {
}
// call the method
fetchData()
}, [selectedSports, page])
}, [selectedSports, page, searchQuery])

// handle join event pop up after cliking on the event
const handleEventSelection = (e: EventDTO) => {
Expand Down Expand Up @@ -140,21 +141,15 @@ export default function MainPage() {
{filteredEvent.length === 0 ? (
<LoadingSpinner />
) : (
filteredEvent
.filter((e) =>
e.placeDTO.name
.toLowerCase()
.includes(searchQuery.toLowerCase()),
)
.map((event, index) => (
<div
className="nearby-events"
key={index}
onClick={() => handleEventSelection(event)}
>
<SportEvent event={event} />
</div>
))
filteredEvent.map((event, index) => (
<div
className="nearby-events"
key={index}
onClick={() => handleEventSelection(event)}
>
<SportEvent event={event} />
</div>
))
)}
</div>
</div>
Expand Down

0 comments on commit d213d4b

Please sign in to comment.