-
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.
- Loading branch information
1 parent
31ad2fc
commit 075d2d5
Showing
11 changed files
with
211 additions
and
62 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,2 +1,3 @@ | ||
node_modules/ | ||
.idea/ | ||
.idea/ | ||
.build/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { useEffect, useState } from "react"; | ||
import {GameService} from "../services/GameService"; | ||
import { useParams } from 'react-router-dom'; | ||
import { format } from 'date-fns'; | ||
import './GameDetails.scss' | ||
|
||
function GameDetails() { | ||
|
||
const { gameId } = useParams(); | ||
const [game, setGame] = useState(''); | ||
const [message, setMessage] = useState(''); | ||
const [date,setDate] = useState([]); | ||
const [file, setFile] = useState(); | ||
|
||
useEffect(() => { | ||
const fetchGameData = async () => { | ||
let gr | ||
try { | ||
gr = await GameService.getGame(gameId); | ||
setGame(gr.data.data); | ||
} catch (e) { | ||
setMessage('There was a problem with fetching match data.'); | ||
} | ||
try { | ||
console.log(game.gameFileName) | ||
const date = formatTimestamp(gr.data.data.lastModification); | ||
setDate(date); | ||
console.log() | ||
} catch (e) { | ||
console.log('There was a problem with fetching date.'); | ||
} | ||
try { | ||
const gf = await GameService.getGameFile(gr.data.data.fileId); | ||
setFile(gf.data.data); | ||
} catch (e) { | ||
console.log('There was a problem with fetching files.'); | ||
} | ||
}; | ||
|
||
fetchGameData(); | ||
},[gameId, game.gameFileName]); | ||
|
||
function formatTimestamp(timestamp) { | ||
try { | ||
const normalizedTimestamp = timestamp.replace(/\.\d{3,}/, match => match.slice(0, 4)); | ||
const date = new Date(normalizedTimestamp); | ||
|
||
if (isNaN(date.getTime())) { | ||
throw new Error("Invalid date"); | ||
} | ||
|
||
return [format(date, 'yyyy-MM-dd'), format(date, 'HH:mm:ss')]; | ||
} catch (error) { | ||
console.error("Error formatting timestamp:", error); | ||
return ["", ""]; | ||
} | ||
} | ||
console.log(file) | ||
return ( | ||
message.length === 0 ? | ||
<> | ||
<div className="game-info-container"> | ||
<h1>{game.gameFileName}</h1> | ||
<div className="article-content bold-text"> | ||
<p>{game.interfaceDefinition}</p> | ||
</div> | ||
<div className="article-content"> | ||
<p>{game.gameInstructions}</p> | ||
</div> | ||
<div className="game-info-table article-content"> | ||
<div className="game-info-col"> | ||
<span><p className="bold-text">modification</p></span> | ||
<p>{date[0]}</p> | ||
<p>{date[1]}</p> | ||
</div> | ||
<div className="game-info-col"> | ||
<span><p className="bold-text">players</p></span> | ||
<p>{game.numbersOfPlayer}</p> | ||
</div> | ||
<div className="game-info-col"> | ||
<span><p className="bold-text">available</p></span> | ||
<p>{game.isAvailableForPlay ? "Yes" : "no"}</p> | ||
</div> | ||
</div> | ||
<div className="font-bold"> | ||
{file ? 'łuuuuuuuuuuuu': 'no file'} | ||
</div> | ||
</div> | ||
</>:<> | ||
<div className="font-bold error-message"> | ||
<p>{message}</p> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export default GameDetails; | ||
|
||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
.game-info-container{ | ||
margin:auto; | ||
max-width: 80%; | ||
|
||
.game-info-table{ | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
height: 100%; | ||
justify-content: space-between; | ||
} | ||
|
||
.article-content{ | ||
border: 3px solid black; | ||
padding: 1.5% 5%; | ||
margin: 20px; | ||
} | ||
|
||
.bold-text{ | ||
font-weight: bold; | ||
font-size: 0.9em; | ||
font-family: Arial, Helvetica, sans-serif; | ||
text-shadow: none; | ||
letter-spacing: 1px; | ||
color: rgb(57, 185, 31); | ||
} | ||
|
||
.game-info-col{ | ||
span > p{ | ||
margin-bottom: 30px; | ||
} | ||
p{ | ||
text-align: center; | ||
} | ||
} | ||
|
||
} | ||
|
||
.error-message{ | ||
display:flex; | ||
align-items: center; | ||
flex-direction: column; | ||
justify-content: center; | ||
padding-top: 23% ; | ||
margin-top:auto; | ||
margin-bottom:auto; | ||
} |
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.