-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
123 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,68 @@ | ||
import './TournamentDetails.scss' | ||
import { getListOfTournaments } from './getListOfTournaments'; | ||
import { useParams } from 'react-router-dom'; | ||
import { connect } from 'react-redux'; | ||
import { Link } from 'react-router-dom'; | ||
import { login, logout } from '../User/store'; | ||
function TournamentDetails({isAuthenticated, user, login, logout }) { | ||
import {getListOfTournaments} from './getListOfTournaments'; | ||
import {useParams} from 'react-router-dom'; | ||
import {connect} from 'react-redux'; | ||
import {Link} from 'react-router-dom'; | ||
import {login, logout} from '../User/store'; | ||
import {TournamentService} from "../services/TournamentService"; | ||
import React, {useEffect, useState} from "react"; | ||
import {Buffer} from "buffer"; | ||
|
||
const { tournamentId } = useParams(); | ||
const tournament = getListOfTournaments().find(t => t.id === parseInt(tournamentId)); | ||
function TournamentDetails({isAuthenticated, user, login, logout}) { | ||
|
||
const {tournamentId} = useParams(); | ||
const [tournament, setTournament] = useState([]); | ||
const [message, setMessage] = useState(''); | ||
|
||
useEffect(() => { | ||
TournamentService.getTournament(tournamentId) | ||
.then((response) => { | ||
setTournament(response.data.data); | ||
} | ||
).catch((error) => { | ||
setMessage('Error loading tournaments'); | ||
}); | ||
}, []); | ||
|
||
console.log(tournament); | ||
if (!tournament) { | ||
return <div>Tournament not found</div>; | ||
} | ||
|
||
// alert(tournament) | ||
|
||
return ( | ||
<div className="tournamentWrapper"> | ||
<p>Szczegóły Turnieju</p> | ||
<p>Tournament details</p> | ||
<div className="tournamentDetails"> | ||
<div className="details"> | ||
<p>Nazwa: {tournament.name}</p> | ||
<p>Liczba uczestników: {tournament.participantsAmount}</p> | ||
<p>Max liczba uczestników: {tournament.maxParticipants}</p> | ||
<p>Data: {tournament.date}</p> | ||
<p>Ograniczenia: {tournament.limitations}</p> | ||
<p>Status: {tournament.state}</p> | ||
<p>Name: {tournament.tournamentTitle}</p> | ||
<p>Current amount of competitors: {tournament.playersBots?.length}</p> | ||
<p>Max amount of competitors: {tournament.playersLimit}</p> | ||
<p>Tournament date: {tournament.tournamentsDate}</p> | ||
<p>Limitations: {tournament.constraints}</p> | ||
<p>Status: {tournament.status}</p> | ||
<p>Game type: {tournament.gameName}</p> | ||
</div> | ||
{/* <img className="tournamentImage" src="" alt=""></img> */} | ||
<div className="tournamentImage"></div> | ||
{/* | ||
<div className="tournamentImage"> | ||
<img className='profile-image' src={`data:image/jpeg;base64,${tournament.image}`} alt='tournament image'/> | ||
</div> | ||
*/} | ||
</div> | ||
<p className="tournamentDescription">Opis: {tournament.description}</p> | ||
<p className="tournamentDescription">Description: {tournament.description}</p> | ||
{isAuthenticated ? ( | ||
<button className="btn"><Link to={`/tournaments/edit/${tournament.id}`}>Edit Tournament</Link></button> | ||
) : null} | ||
</div> | ||
); | ||
} | ||
|
||
const mapStateToProps = (state) => ({ | ||
isAuthenticated: state.isAuthenticated, | ||
user: state.user, | ||
}); | ||
const mapDispatchToProps = {login,logout,}; | ||
}); | ||
|
||
const mapDispatchToProps = {login, logout,}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(TournamentDetails); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.