This commit is contained in:
2026-02-05 13:40:04 +01:00
parent 7046857e0b
commit a5214925a8
3 changed files with 56 additions and 44 deletions
+5 -44
View File
@@ -16,53 +16,14 @@ import {
import { cn } from "@/lib/utils";
import LiveRunRow from "./components/LiveRunNow";
import StatCard from "@/components/app/StatCard";
/* ---------------- mock data ---------------- */
const liveRuns = [
{
id: 1,
username: "speedmaster_x",
problem: "Two Sum Dash",
category: "Any%",
time: "1:52.34",
pace: "-0:03",
status: "pb",
},
{
id: 2,
username: "algo_ninja",
problem: "Binary Sprint",
category: "Any%",
time: "2:04.11",
pace: "+0:05",
status: "normal",
},
{
id: 3,
username: "stackattack",
problem: "String Scramble",
category: "Easy",
time: "0:48.92",
pace: "-0:01",
status: "pb",
},
{
id: 4,
username: "reset_king",
problem: "Linked List Rush",
category: "Any%",
time: "1:31.77",
pace: "+0:12",
status: "danger",
},
];
/* ---------------- page ---------------- */
import useAction from "@/hook/use-action";
import { getLiveRuns } from "@/modules/live-run/actions";
export default function LiveRuns() {
const [liveRuns, liveRunsLoaded, liveRunsError] = useAction(getLiveRuns);
// Sort top runners (status === 'pb') to the top
const sortedRuns = [...liveRuns].sort((a, b) => {
const sortedRuns = [...(liveRuns || [])].sort((a, b) => {
if (a.status === "pb" && b.status !== "pb") return -1;
if (a.status !== "pb" && b.status === "pb") return 1;
return 0;