"use client"
import React from "react"
import { useRouter } from "next/navigation"
import { redirect } from "next/navigation"
import { useWalletStore } from "@/lib/wallet-store"
import { useTrustData } from "@/hooks/use-trust-data"
import { InfoCircle, ExternalLink, Shield, LockKeyhole, Award, CoinsStacked } from "@/icons"
import { ArrowRight, CheckCircle, Clock, Edit, MessageSquare, VoteIcon, User, Info } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Badge } from "@/components/ui/badge"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { ConnectWalletButton } from "@/components/connect-wallet-button"
// Mock data
const mockPerspectives = [
{
id: 1,
title: "Improve bike lane safety",
issue: "Infrastructure",
date: "2024-02-10",
status: "Synthesized",
},
{
id: 2,
title: "Expand library hours",
issue: "Education",
date: "2024-01-25",
status: "Synthesized",
},
{
id: 3,
title: "Community garden proposal",
issue: "Environmental Policy",
date: "2024-01-15",
status: "Pending",
},
]
const mockVotes = [
{
id: 1,
insight: "Increase Park Funding",
vote: "Yes",
date: "2024-02-15",
},
{
id: 2,
insight: "Public Transportation Expansion",
vote: "Yes",
date: "2024-02-10",
},
{
id: 3,
insight: "After-School Programs",
vote: "Yes",
date: "2024-01-28",
},
{
id: 4,
insight: "Bike Lane Network",
vote: "No",
date: "2024-01-20",
},
]
export default function ProfilePage() {
const router = useRouter()
const {
walletConnected,
walletAddress,
username,
isVerified,
country,
citizenshipVerified,
eligibilityVerified,
verificationStatus,
perspectivesSubmittedToday,
connectWallet
} = useWalletStore()
const { trustScore, dailyLimit, trustActions, isLoading } = useTrustData()
// Redirect to login if not connected
if (!walletConnected) {
return (
Connect Wallet to View Profile
Please connect your wallet to access your profile and view your participation metrics.
)
}
const getTrustLevel = (score: number) => {
if (score >= 80) return "Gold"
if (score >= 60) return "Silver"
if (score >= 40) return "Bronze"
if (score >= 20) return "Starter"
return "New"
}
const trustLevel = getTrustLevel(trustScore)
const trustColor = {
Gold: "text-yellow-600 bg-yellow-100 border-yellow-300",
Silver: "text-gray-600 bg-gray-100 border-gray-300",
Bronze: "text-amber-700 bg-amber-100 border-amber-300",
Starter: "text-blue-600 bg-blue-100 border-blue-300",
New: "text-green-600 bg-green-100 border-green-300"
}[trustLevel]
const progressPercent = Math.min(100, Math.max(0, trustScore))
// Get the badge style based on verification status
const getVerificationBadge = () => {
if (!isVerified) {
return (
);
}
if (verificationStatus === "Fully Eligible") {
return (
Fully Eligible
);
}
if (verificationStatus === "Verified" || citizenshipVerified) {
return (
Citizenship Verified
);
}
return (
);
};
return (
{!isVerified && (
Verify to participate fully
Without verification, you're in read-only mode with limited actions. Verify your identity to unlock all features.
)}
{/* Profile Info Section */}
{username ? username[0].toUpperCase() : "?"}
{username || "Anonymous User"}
{walletAddress}
{getVerificationBadge()}
{country && (
Country: {country}
)}
{/* Trust Score Section */}
Trust Score
{trustScore}
/ 100
Daily Perspective Limit:
{dailyLimit}
Perspectives Submitted Today:
{perspectivesSubmittedToday}
{/* How to earn trust section for unverified users */}
{!isVerified && (
How to Earn Trust
{trustActions.map((action, index) => (
-
{action.action}
+{action.points} points
))}
Higher trust scores increase your daily submission limit. Verified users have unlimited submissions.
)}
{/* Verification status details for verified users */}
{isVerified && (
Verification Status
-
Citizenship Verification: {citizenshipVerified ? "Verified" : "Not Verified"}
-
Eligibility Verification: {eligibilityVerified ? "Verified" : "Not Verified"}
{!eligibilityVerified && citizenshipVerified && (
)}
)}
{/* Privileges for verified users */}
{isVerified && (
Verified Privileges
-
Unlimited daily perspective submissions
-
Ability to moderate flagged content
-
Higher voting power in consensus
-
Access to verified-only discussions
)}
{/* Activity Section */}
Your Activity
{/* Tabs */}
{/* Perspectives Table */}
Title
|
Date
|
Status
|
Actions
|
{mockPerspectives.map((perspective) => (
{perspective.title}
|
{perspective.date}
|
{perspective.status}
|
View
|
))}
{/* Call to Action for creating new perspectives */}
Share your perspective
Have something to say on a current topic? Share your perspective and contribute to the discourse.
{/* New section: User Privileges based on verification status */}
Platform Privileges
{/* Unverified privileges */}
-
View public perspectives and insights
-
Submit {dailyLimit} perspectives per day
-
Limited voting power (0.5x)
{!isVerified && (
Current Status
)}
{/* Verified (citizenship only) privileges */}
-
All unverified privileges
-
Submit up to 20 perspectives per day
-
Standard voting power (1x)
{citizenshipVerified && !eligibilityVerified && (
Current Status
)}
{/* Fully Eligible privileges */}
-
All verified privileges
-
Unlimited perspective submissions
-
Enhanced voting power (1.5x)
-
Access to moderation tools
{citizenshipVerified && eligibilityVerified && (
Current Status
)}
)
}