Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | 20x 20x 20x 20x 20x 20x 20x 1x | import React from "react"; import { useParams } from "react-router-dom"; import { hasRole } from "main/utils/currentUser"; import LeaderboardTable from "main/components/Leaderboard/LeaderboardTable"; import BasicLayout from "main/layouts/BasicLayout/BasicLayout"; import { useBackend } from "main/utils/useBackend"; import { useCurrentUser } from "main/utils/currentUser"; import Background from "../../assets/PlayPageBackground.png"; import { Button } from 'react-bootstrap'; import { useNavigate } from 'react-router-dom'; export default function LeaderboardPage() { const { commonsId } = useParams(); const { data: currentUser } = useCurrentUser(); const navigate = useNavigate(); // Stryker disable all const { data: userCommons, error: _error, status: _status } = useBackend( [`/api/usercommons/commons/all?commonsId=${commonsId}`], { method: "GET", url: "/api/usercommons/commons/all", params: { commonsId: commonsId } }, [] ); // Stryker restore all // Stryker disable all const { data: commons, error: _commonsError, status: _commonsStatus } = useBackend( [`/api/commons?id=${commonsId}`], { method: "GET", url: "/api/commons", params: { id: commonsId } }, [] ); // Stryker restore all const showLeaderboard = (hasRole(currentUser, "ROLE_ADMIN") || commons.showLeaderboard ); return ( <div data-testid={"LeaderboardPage-main-div"} style={{backgroundSize: 'cover', backgroundImage: `url(${Background})`}}> <BasicLayout> <div className="pt-2"> <Button variant="primary" onClick={() => navigate(-1)} data-testid={"Leaderboard-back"} > Back </Button> <h1>Leaderboard</h1> { showLeaderboard? (<LeaderboardTable leaderboardUsers={userCommons} currentUser={currentUser} />) : (<p>You're not authorized to see the leaderboard.</p>) } </div> </BasicLayout> </div> ) } |