Skip to content

Commit 586e430

Browse files
committed
Fixed leaderboard logic and updated README
1 parent 9702bcb commit 586e430

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,14 @@ Move the `.env` file into the project root directory, then run the following to
3333
```bash
3434
# if you want to use the latest node binary replace nodejs -> node
3535
nodejs ./src/backend/server.js
36+
```
37+
38+
## :chart_with_upwards_trend: Production
39+
You will need to install a dependency to use `serve`, this is recommended after running `npm run build`.
40+
```bash
41+
sudo npm install -g serve
42+
```
43+
Prepare production build and serve as a static server.
44+
```bash
45+
npm run build && server -s build
3646
```

src/pages/leaderboard.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,17 @@ export function Leaderboard() {
3535

3636
const data = await response.json();
3737
if (data) {
38-
setUserData({"username": data.username, "team": data.team})
38+
if (data.username && data.team) {
39+
setUserData({"username": data.username, "team": data.team})
40+
} else {
41+
setUserData(null)
42+
}
43+
} else {
44+
setUserData(null)
3945
}
4046
} catch (error) {
4147
console.error("Error sending request:", error);
48+
setUserData(null)
4249
}
4350
}
4451
GetInfo();
@@ -75,7 +82,8 @@ export function Leaderboard() {
7582

7683
<div className="container mt-2 d-flex justify-content-center gap-3">
7784
{/* THIS CARD ONLY SHOWS WHEN A USER IS AUTHENTICATED */}
78-
{userData && (
85+
{console.log(userData)}
86+
{(userData) && (
7987
<div
8088
className="card shadow-sm"
8189
style={{ minWidth: '200px', maxWidth: '300px', width: '100%' }}

0 commit comments

Comments
 (0)