diff --git a/packages/nextjs/app/communityDash/page.tsx b/packages/nextjs/app/communityDash/page.tsx index dd400ea..df508a4 100644 --- a/packages/nextjs/app/communityDash/page.tsx +++ b/packages/nextjs/app/communityDash/page.tsx @@ -12,17 +12,30 @@ import { DialogTrigger, } from "../../components/ui/dialog"; import { Label } from "../../components/ui/label"; -import { ReactNode } from "react"; +import { ReactNode, useState } from "react"; import { GlareCard } from "../../components/ui/glare-card"; +import { useScaffoldReadContract, useScaffoldWriteContract } from "~~/hooks/scaffold-eth"; interface CommunityCardProps { + communityId: string; communityName: string; description: string; + instagramHandle: string; + linkedinHandle: string; + twitterHandle: string; + creatorAddress: string; + followerCount: number; } interface CommunityDetailsDialogProps { + communityId: string; communityName: string; description: string; + instagramHandle: string; + linkedinHandle: string; + twitterHandle: string; + creatorAddress: string; + followerCount: number; } interface EventCardProps { @@ -31,30 +44,53 @@ interface EventCardProps { } export default function CommunityDashboard(): ReactNode { + const { data: communities } = useScaffoldReadContract({ + contractName: "YourContract", + functionName: "getAllCommunities", + }); + return (

Community Dashboard

- - {/* Add more CommunityCard components as needed */} + {communities && communities[0].map((id, index) => ( + + ))}
); } -function CommunityCard({ communityName, description }: CommunityCardProps): ReactNode { +function CommunityCard({ communityId, communityName, description, instagramHandle, linkedinHandle, twitterHandle, creatorAddress, followerCount }: CommunityCardProps): ReactNode { return (

{communityName}

{description}

+

Followers: {followerCount}

-
- +
{/* Reduced gap between buttons */} +
@@ -62,7 +98,22 @@ function CommunityCard({ communityName, description }: CommunityCardProps): Reac ); } -function CommunityDetailsDialog({ communityName, description }: CommunityDetailsDialogProps): ReactNode { +function CommunityDetailsDialog({ communityId, communityName, description, instagramHandle, linkedinHandle, twitterHandle, creatorAddress, followerCount }: CommunityDetailsDialogProps): ReactNode { + const [isFollowing, setIsFollowing] = useState(false); + const { writeContractAsync: writeYourContractAsync } = useScaffoldWriteContract("YourContract"); + + const handleFollowClick = async () => { + try { + await writeYourContractAsync({ + functionName: "followCommunity", + args: [BigInt(communityId)], + }); + setIsFollowing(!isFollowing); + } catch (e) { + console.error("Error following/unfollowing community:", e); + } + }; + return ( @@ -77,24 +128,30 @@ function CommunityDetailsDialog({ communityName, description }: CommunityDetails
-

@{communityName.toLowerCase().replace(/\s/g, '')}

+

@{instagramHandle}

-

linkedin.com/company/{communityName.toLowerCase().replace(/\s/g, '-')}

+

{linkedinHandle}

-

@{communityName.toLowerCase().replace(/\s/g, '_')}

+

@{twitterHandle}

-

0x1234...5678

+

{creatorAddress}

+
+
+ +

{followerCount}

- +