Skip to content

Commit

Permalink
update leader board
Browse files Browse the repository at this point in the history
  • Loading branch information
sk337 committed Jan 23, 2024
1 parent a73e56a commit a57e0c2
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useEffect, useState } from "react";
import "@/App.css";
import { checkLogin, tokenlogin, getPubInfo, login } from "@/utils/login";
import cosmetics from "../cosmetics.json";
import {
Expand Down
44 changes: 35 additions & 9 deletions src/Leaderboard.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
import React, { useEffect, useState } from "react";
import Nav from "@/components/nav";

export default function Leaderboard() {
const [leaderboard, setLeaderboard] = useState([]);
const [profiles, setProfiles] = useState({});
const [range, setRange] = useState("all");
const [type, setType] = useState("xp");
const [total, setTotal] = useState(0);

export default function Leaderboard(){

useEffect(() => {
const fetchLeaderboard = async () => {};
}, []);


return (
<div>
<h1>Leaderboard</h1>
</div>
);
}
if (leaderboard.length == 0) {
return (
<main>
<Nav />
<div className="flex flex-col items-center">
<p className="text-3xl text-center font-bold">Leaderboard</p>
<table className="mt-10 w-4/5">
<tbody className="w-full" id="data">
<tr className="w-full bg-slate-700 text-center">
<td className="p-2 rounded-sm">lol</td>
</tr>
</tbody>
</table>
</div>
</main>
);
} else {
return (
<main>
<h1 className="m-5 text-3xl font-bold text-center">Loading...</h1>
<p className="font-symbol text-center text-6xl animate-spin"></p>
</main>
);
}
}
5 changes: 2 additions & 3 deletions src/components/nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ import {
NavigationMenuViewport,
} from "@/components/ui/navigation-menu"

import config from "@/config";

export default function Nav(){
return (
<NavigationMenu className="m-5 text-center">
<NavigationMenuList>
<NavigationMenuItem>
<a href="#/">Home</a>
<a href="#">Home</a>
</NavigationMenuItem>
<NavigationMenuItem>|</NavigationMenuItem>
<NavigationMenuItem>
<a href="#/leaderboard">Leaderboard</a>
<a href="#leaderboard">Leaderboard</a>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
Expand Down
3 changes: 0 additions & 3 deletions src/config.js

This file was deleted.

13 changes: 9 additions & 4 deletions src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import React from "react";
import ReactDOM from "react-dom/client";
import { RouterProvider, createHashRouter } from "react-router-dom";
import App from "./App";
// import Login from './Login'
import "@/App.css"
import Leaderboard from './Leaderboard'

const root = ReactDOM.createRoot(document.getElementById("root"));
console.log(window.location.hash);
console.log(window.location.hash.toLowerCase());

if (window.location.hash == "#/leaderboard") {
if (window.location.hash.toLowerCase() == "#leaderboard") {
root.render(
<React.StrictMode>
<Leaderboard />
</React.StrictMode>
)
} else {
root.render(
<React.StrictMode>
Expand Down
21 changes: 21 additions & 0 deletions src/utils/leaderboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export const types = {
'kills': 'Kills',
'coins': 'Coins',
'playtime': 'Survived',
'xp': 'XP',
'total-coins': 'Total Coins',
'total-kills': 'Total Stabs',
'total-playtime': 'Total Playtime',
}

export const ranges = {
'all': 'All-Time',
'day': 'Past Day',
'week': 'Past Week',
}

const ApiUrl = "https://sb-api-fb48ef34a197.herokuapp.com/"

export async function getLeaderboard(range, type){

}

0 comments on commit a57e0c2

Please sign in to comment.