Skip to content

Commit

Permalink
SMA-106: updated HostEventComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
ivamach committed Apr 22, 2024
1 parent 6758239 commit 74995df
Showing 1 changed file with 1 addition and 31 deletions.
32 changes: 1 addition & 31 deletions frontend/sportsmatch-app/src/components/HostEventComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
HostEventDTO,
EventDTO,
ApiError,
OpenAPI,
ExSecuredEndpointService,
} from '../generated/api'
import DatePicker from 'react-datepicker'
import 'react-datepicker/dist/react-datepicker.css'
Expand Down Expand Up @@ -44,8 +42,6 @@ function HostEventComponent() {
const [nearbyEvents, setNearbyEvents] = useState<EventDTO[]>([])
const [selectedEvent, setSelectedEvent] = useState<EventDTO>()
const { isOpen, toggle } = useModal()
const [usersRank, setUsersRank] = useState(0)
const [userIsInRank, setUserIsInRank] = useState(false)
const [searchQuery, setSearchQuery] = useState<string>('') // no implementation yet

console.log(searchQuery)
Expand Down Expand Up @@ -136,35 +132,13 @@ function HostEventComponent() {

// handle join event pop up after cliking on the event
const handleEventSelection = (e: EventDTO) => {
window.scrollTo(0, 0)
if (isOpen) {
toggle()
}
setSelectedEvent(e)
if (usersRank >= e.minElo && usersRank <= e.maxElo) {
setUserIsInRank(true)
} else {
setUserIsInRank(false)
}
toggle()
}

// retrieving users rank
useEffect(() => {
const fetchUsersRank = async () => {
OpenAPI.TOKEN = localStorage.getItem('token')!
try {
const response = await ExSecuredEndpointService.getUserMainPage()
if (response) {
setUsersRank(response.elo)
}
} catch (error) {
console.error(error as ApiError)
}
}
fetchUsersRank()
})

return (
<>
<div className="row">
Expand Down Expand Up @@ -295,11 +269,7 @@ function HostEventComponent() {
</div>
</div>
<Modal isOpen={isOpen} toggle={toggle} preventClosing={true}>
<JoinEventComponent
toggle={toggle}
isInRank={userIsInRank}
event={selectedEvent!}
/>
<JoinEventComponent toggle={toggle} event={selectedEvent!} />
</Modal>
<div className="row">
<div className="col">
Expand Down

0 comments on commit 74995df

Please sign in to comment.