MCPcopy Create free account
hub / github.com/code100x/cms / Page

Function Page

src/app/bounty/page.tsx:12–151  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10import { Skeleton } from '@/components/ui/skeleton';
11
12export default function Page() {
13 const [isBountyDialogOpen, setIsBountyDialogOpen] = useState<boolean>(false);
14 const [upiAddresses, setUpiAddresses] = useState<UpiId[]>([]);
15 const [solanaAddresses, setSolanaAddresses] = useState<SolanaAddress[]>([]);
16 const [bounties, setBounties] = useState<BountySubmission[]>([]);
17 const [isLoading, setIsLoading] = useState<boolean>(true);
18
19 const fetchPayoutMethods = async () => {
20 const result = await getPayoutMethods();
21 if (result.error) {
22 return;
23 }
24 if (result) {
25 setUpiAddresses(result.upiIds!);
26 setSolanaAddresses(result.solanaAddresses!);
27 setIsLoading(false);
28 }
29 };
30
31 const fetchUserBounties = async () => {
32 setIsLoading(true);
33 try {
34 const userBounties = await getUserBounties();
35
36 const sortedBounties = userBounties.sort((a, b) => {
37 return (
38 new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
39 );
40 });
41
42 setBounties(sortedBounties);
43 } catch (error) {
44 toast.error('Failed to fetch bounties');
45 } finally {
46 setIsLoading(false);
47 }
48 };
49
50 useEffect(() => {
51 fetchPayoutMethods();
52 fetchUserBounties();
53 }, []);
54
55 const handleBountyDialogOpen = () => {
56 if (upiAddresses?.length || solanaAddresses?.length) {
57 setIsBountyDialogOpen(true);
58 } else {
59 toast.error('Add at least 1 payment method');
60 }
61 };
62
63 const handleBountyDialogClose = () => {
64 setIsBountyDialogOpen(false);
65 fetchUserBounties();
66 };
67
68 return (
69 <>

Callers

nothing calls this directly

Calls 2

fetchUserBountiesFunction · 0.85
fetchPayoutMethodsFunction · 0.70

Tested by

no test coverage detected