diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index 7b76c35..0df8cea 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -3,7 +3,7 @@ import { useEffect, useState } from "react"; import Link from "next/link"; import { useRouter } from "next/navigation"; -import { TrendingUp, Wallet, ArrowUpRight, ArrowDownRight, type LucideIcon } from "lucide-react"; +import { TrendingUp, Wallet, ArrowUpRight, ArrowDownRight, ArrowUp, ArrowDown, type LucideIcon } from "lucide-react"; import { fetchMe, type DashboardData } from "@/lib/api/client"; import { Button } from "@/components/ui/button"; @@ -121,6 +121,11 @@ export default function DashboardPage() { const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); + const [sortOrder, setSortOrder] = useState<"asc" | "desc">("desc"); + + const handleSort = () => { + setSortOrder((prev) => (prev === "asc" ? "desc" : "asc")); + }; useEffect(() => { fetchMe() @@ -153,7 +158,15 @@ export default function DashboardPage() { ); } - const { user, funded_bounties, won_bounties, stats } = data; + const { user, funded_bounties, stats } = data; + + const sortedWonBounties = [...data.won_bounties].sort((a, b) => { + if (sortOrder === "asc") { + return a.total_amount - b.total_amount; + } else { + return b.total_amount - a.total_amount; + } + }); return (
@@ -214,6 +227,10 @@ export default function DashboardPage() {

Bounties You Won

+
{won_bounties.length === 0 ? ( @@ -222,7 +239,7 @@ export default function DashboardPage() {

Submit a PR to start earning!

) : ( - won_bounties.slice(0, 5).map((bounty) => ( + sortedWonBounties.slice(0, 5).map((bounty) => ( )) )}