"use client" import { useState, use } from "react" import { ArrowLeft, MessageSquare, ThumbsUp, ThumbsDown, Share2, FileText, Filter } from "lucide-react" import Link from "next/link" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { Textarea } from "@/components/ui/textarea" import { Separator } from "@/components/ui/separator" import { Progress } from "@/components/ui/progress" // Mock data for the issue const mockIssues = { "climate-action": { id: "climate-action", title: "Climate Action Policies", description: "Discussion on policies to address climate change and reduce carbon emissions.", category: "Environmental Policy", dateCreated: "2024-01-10", status: "active", metrics: { perspectives: 324, insights: 18, contributions: 5, participants: 156 } }, "education-reform": { id: "education-reform", title: "Education System Reform", description: "Ideas for improving educational outcomes and accessibility for all students.", category: "Education", status: "active", metrics: { perspectives: 187, insights: 12, contributions: 3, participants: 89 } } } // Mock perspectives for issues const mockPerspectivesByIssue = { "climate-action": [ { id: 1, userId: "user1", userName: "Alex Johnson", userAvatar: "", content: "We should focus on renewable energy investments. Solar and wind power have become more cost-effective and could replace fossil fuels in many regions.", dateSubmitted: "2024-03-01", likes: 45, dislikes: 3 }, { id: 2, userId: "user2", userName: "Jamie Smith", userAvatar: "", content: "Carbon pricing is the most efficient way to reduce emissions. It creates market incentives for businesses to innovate and cut their carbon footprint.", dateSubmitted: "2024-02-28", likes: 38, dislikes: 7 }, { id: 3, userId: "user3", userName: "Taylor Reed", userAvatar: "", content: "We need to address transportation emissions through better public transit and EV infrastructure. This sector is a major contributor to greenhouse gases.", dateSubmitted: "2024-02-25", likes: 52, dislikes: 4 } ], "education-reform": [ { id: 1, userId: "user4", userName: "Morgan Lee", userAvatar: "", content: "Teachers need better resources and smaller class sizes to effectively improve student outcomes.", dateSubmitted: "2024-03-02", likes: 62, dislikes: 5 }, { id: 2, userId: "user5", userName: "Casey Wilson", userAvatar: "", content: "Access to early childhood education should be a priority as it sets the foundation for all future learning.", dateSubmitted: "2024-02-27", likes: 41, dislikes: 2 } ] } // Mock insights for issues const mockInsightsByIssue = { "climate-action": [ { id: 1, title: "Renewable Energy Investment", description: "67% of perspectives support increased government funding for renewable energy projects, with solar and wind being the most frequently mentioned technologies.", votes: { yes: 124, no: 18 }, status: "consensus", // voting, consensus, rejected perspectives: [1, 5, 8, 12] // Reference to perspective IDs }, { id: 2, title: "Carbon Pricing Mechanism", description: "A majority of users advocate for carbon pricing policies, with 58% specifically mentioning tax incentives for low-emission businesses.", votes: { yes: 98, no: 32 }, status: "voting", // voting, consensus, rejected perspectives: [2, 7, 15] // Reference to perspective IDs } ], "education-reform": [ { id: 1, title: "Teacher Support Systems", description: "78% of perspectives emphasize the need for better resources and support for teachers, including smaller class sizes and professional development.", votes: { yes: 112, no: 15 }, status: "consensus", perspectives: [1, 3, 7] }, { id: 2, title: "Early Childhood Education Access", description: "64% of perspectives advocate for universal access to early childhood education to establish a strong foundation for learning.", votes: { yes: 87, no: 34 }, status: "voting", perspectives: [2, 8, 10] } ] } export default function IssueDetails({ params }: { params: Promise<{ id: string }> }) { // Properly unwrap params using React.use() const { id: issueId } = use(params) const [activeTab, setActiveTab] = useState("overview") const [commentText, setCommentText] = useState("") // Get the issue data from our mock data const issue = mockIssues[issueId as keyof typeof mockIssues] || mockIssues["climate-action"] const perspectives = mockPerspectivesByIssue[issueId as keyof typeof mockPerspectivesByIssue] || [] const insights = mockInsightsByIssue[issueId as keyof typeof mockInsightsByIssue] || [] const handleSubmitComment = (e: React.FormEvent) => { e.preventDefault() if (commentText.trim()) { // In a real app, submit the comment to the backend console.log("Submitting comment:", commentText) setCommentText("") } } return (

{issue.title}

{issue.category} {issue.status}

{issue.description}

{issue.metrics.perspectives}

Perspectives

{issue.metrics.insights}

Insights

{issue.metrics.contributions}

Contributions

{issue.metrics.participants}

Participants

Overview Perspectives Insights Issue Summary Key information and progress on this issue

Progress

Perspectives Gathering 75%
Insight Formation 45%
Contribution Validation 20%

Timeline

1

Perspectives Collection

In progress - Ends Apr 15, 2024

2

Insight Voting

Apr 16 - May 1, 2024

3

Resolution Formation

May 2 - May 15, 2024

Recent Perspectives

{perspectives.map((perspective) => (
{perspective.userName.charAt(0)}

{perspective.userName}

{perspective.dateSubmitted}

{perspective.content}

))}
Add Your Perspective