-
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
50f5ac2
commit bda00ae
Showing
17 changed files
with
595 additions
and
304 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import {UserService } from '../../services/UserService'; | ||
import {useNavigate} from 'react-router-dom'; | ||
|
||
import './ProfileGameList.scss'; | ||
|
||
import notAvailableIcon from '../../resources/cross.svg'; | ||
|
||
export default function ProfileGameList({ userId }) { | ||
const navigate = useNavigate(); | ||
const [games, setGames] = useState([]); | ||
const [loading, setLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
UserService.getGamesForPlayer(userId).then((response) => { | ||
console.log(response); | ||
setGames(response.data.data); | ||
console.log(games); | ||
setLoading(false); | ||
}).catch((error) => { | ||
console.log(error); | ||
}); | ||
}, [userId]); | ||
|
||
const handleGameElementClick = (gameId) => { | ||
return () => navigate(`/game/details/${gameId}`); | ||
}; | ||
|
||
return ( | ||
<div className="user-info-table"> | ||
<div className="user-info-table-content"> | ||
{loading ? ( | ||
<p>Loading...</p> | ||
) : ( | ||
<> | ||
{games.map((game, index) => ( | ||
<div className={`${(index % 2) ? 'light' : 'dark'} game-list-element-container`} | ||
key={game.id} | ||
onClick={handleGameElementClick(game.id)}> | ||
<p className="game-list-element-name"> | ||
{game.gameFileName} | ||
</p> | ||
<p className="game-list-element-date"> | ||
{game.lastModificatiosn} | ||
</p> | ||
<div className="game-list-element-availability"> | ||
{game.isAvailableForPlay || ( | ||
<img className="not-available-icon" src={notAvailableIcon} alt="Not available" /> | ||
)} | ||
</div> | ||
</div> | ||
))} | ||
</>)} | ||
</div> | ||
</div> | ||
); | ||
} |
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,40 @@ | ||
.user-info-table { | ||
height: 100%; | ||
.user-info-table-content { | ||
overflow-y: scroll; | ||
.game-list-element-container { | ||
display: grid; | ||
grid-template-columns: max-content auto 15px; | ||
padding: 2px 5px; | ||
|
||
.game-list-element-availability { | ||
overflow: hidden; | ||
display: flex; | ||
.not-available-icon { | ||
top: 0; | ||
width: 100%; | ||
aspect-ratio: 1; | ||
} | ||
} | ||
|
||
p { | ||
font-size: 20px; | ||
transition: all 0.3s ease; | ||
} | ||
|
||
p:hover { | ||
cursor: pointer; | ||
text-shadow: #309e00 0px 0px 5px; | ||
color: #79ec48; | ||
} | ||
} | ||
|
||
.light { | ||
background-color: #222222; | ||
} | ||
|
||
.dark { | ||
background-color: #080808; | ||
} | ||
} | ||
} |
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.