Skip to content

Commit

Permalink
randomise delegates order
Browse files Browse the repository at this point in the history
  • Loading branch information
RedBeardEth committed Jan 8, 2025
1 parent 04f2bef commit 3608bec
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions apps/nextjs/src/app/(app)/account/delegates/DelegatesList.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"use client";
import { api } from "@/trpc/react";

import type { RouterOutputs } from "@realms-world/api";
import { use } from "react";
import { api } from "@/trpc/react";

import { DelegateCard } from "./DelegateCard";

export const DelegatesList = ({
Expand All @@ -18,17 +20,20 @@ export const DelegatesList = ({
},
);

const shuffledDelegates = delegatesInfo.items
.filter(
(delegate) =>
delegate.user !==
"0x0000000000000000000000000000000000000000000000000000000000000000",
)
.sort(() => Math.random() - 0.5)
.sort((a, b) => (a.delegatedVotesRaw === "0" ? 1 : -1));

return (
<div className="my-4 grid grid-cols-1 gap-4 overflow-x-hidden md:grid-cols-3">
{delegatesInfo.items
.filter(
(delegate) =>
delegate.user !==
"0x0000000000000000000000000000000000000000000000000000000000000000",
)
.map((delegate) => (
<DelegateCard key={delegate.id} delegate={delegate} />
))}
{shuffledDelegates.map((delegate) => (
<DelegateCard key={delegate.id} delegate={delegate} />
))}
</div>
);
};

0 comments on commit 3608bec

Please sign in to comment.