Skip to content

Commit

Permalink
update leaderboard
Browse files Browse the repository at this point in the history
  • Loading branch information
sk337 committed Jan 24, 2024
1 parent 7ecedd1 commit e9bc02e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/Leaderboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import {
Select,
SelectContent,
SelectItem,
SelectGroup,
SelectLabel,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { ranges, types, getLeaderboard } from "@/utils/leaderboard";
import { ranges, types, rangeLst, typeLst, getLeaderboard } from "@/utils/leaderboard";

import { id2skin, prettyNum, playtimeParse } from "@/utils/jsutils";
import { getPubInfo } from "@/utils/login";

import UserCard from "@/components/usercard";

export default function Leaderboard() {
const [ignored, forceUpdate] = useReducer(x => x + 1, 0);
const [leaderboard, setLeaderboard] = useState([]);
const [profiles, setProfiles] = useState([]);
const [upd, setUpd] = useState(0);
const [range, setRange] = useState("all");
const [type, setType] = useState("xp");

Expand Down Expand Up @@ -52,10 +52,23 @@ export default function Leaderboard() {
<Nav />
<div className="flex flex-col items-center">
<div className="felx flex-row items-center justify-center">
<Select>
<Select onValueChange={(val) => {setRange(val)}}>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="All-Time" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectLabel>Range</SelectLabel>
{rangeLst.map((range) => (
<SelectItem
key={range[0]}
value={range[0]}
>
{range[1]}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
<Select>
<SelectTrigger className="w-[180px] mt-5">
Expand Down
3 changes: 3 additions & 0 deletions src/utils/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export const ranges = {
week: "Past Week",
};

export const rangeLst = [["all", "All-Time"], ["day", "Past Day"], ["week", "Past Week"]];
export const typeLst = [["kills", "Kills"], ["coins", "Coins"], ["playtime", "Survived"], ["xp", "XP"], ["coins", "Total Coins"], ["kills", "Total Stabs"], ["playtime", "Total Playtime"]];

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

export async function getLeaderboard(range, type) {
Expand Down

0 comments on commit e9bc02e

Please sign in to comment.