Skip to content

Commit

Permalink
Randomize projects order on display
Browse files Browse the repository at this point in the history
  • Loading branch information
sembrestels committed Sep 26, 2024
1 parent 38fca80 commit bf11e9c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/web/src/components/VotingCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from "@repo/ui/components/ui/card";
import { Input } from "@repo/ui/components/ui/input";
import { Skeleton } from "@repo/ui/components/ui/skeleton";
import React, { useEffect, useState } from "react";
import React, { useEffect, useMemo, useState } from "react";
import VotingButton from "./VotingButton";

type Project = { account: `0x${string}`; name: string };
Expand All @@ -33,6 +33,11 @@ const VotingCard = ({
maxVotedProjects?: number;
isLoading: boolean;
}) => {
const randomizedProjects = useMemo(
() => [...projects].sort(() => Math.random() - 0.5),
[projects],
);

const [votes, setVotes] = useState<Allocation>(
Object.fromEntries(
projects.map((project) => [
Expand Down Expand Up @@ -98,7 +103,7 @@ const VotingCard = ({
</span>
</div>
</div>
{projects.map((project) => {
{randomizedProjects.map((project) => {
return (
<div
key={project.account}
Expand Down

0 comments on commit bf11e9c

Please sign in to comment.