"use client" import { useState } from "react" import Link from "next/link" import { ArrowLeft, FileText, HelpCircle, AlertTriangle, CheckCircle, Loader2 } from "lucide-react" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Textarea } from "@/components/ui/textarea" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Switch } from "@/components/ui/switch" import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert" import { useWalletStore } from "@/lib/wallet-store" import { useToast } from "@/components/ui/use-toast" // Categories for selection const categories = [ "Environmental Policy", "Education", "Healthcare", "Infrastructure", "Technology", "Economy", "Social Services", "Other" ] export default function ProposeIssuePage() { const { walletConnected } = useWalletStore() const { toast } = useToast() const [formData, setFormData] = useState({ title: "", description: "", category: "", details: "", keywords: "", publicProposal: true }) const [isSubmitting, setIsSubmitting] = useState(false) const [isSubmitted, setIsSubmitted] = useState(false) const [proposalId, setProposalId] = useState("") const handleInputChange = (e: React.ChangeEvent) => { const { name, value } = e.target setFormData(prev => ({ ...prev, [name]: value })) } const handleSelectChange = (name: string) => (value: string) => { setFormData(prev => ({ ...prev, [name]: value })) } const handleSwitchChange = (checked: boolean) => { setFormData(prev => ({ ...prev, publicProposal: checked })) } const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() if (!walletConnected) { toast({ title: "Wallet not connected", description: "Please connect your wallet to propose a new issue.", variant: "destructive" }) return } setIsSubmitting(true) try { // This would submit to the blockchain in production await new Promise(resolve => setTimeout(resolve, 2000)) // Simulate network delay // Generate a random ID for the demo const id = Math.random().toString(36).substring(2, 10) setProposalId(id) setIsSubmitted(true) } catch (error) { console.error("Error submitting proposal:", error) toast({ title: "Submission failed", description: "There was an error submitting your proposal. Please try again.", variant: "destructive" }) } finally { setIsSubmitting(false) } } if (isSubmitted) { return (

Issue Proposed Successfully!

Your issue proposal has been submitted and is now pending review.

Proposal ID: {proposalId}

) } return (

Propose a New Issue

Suggest a topic for community discussion and potential policy recommendation.

{!walletConnected && ( Wallet not connected You need to connect your wallet before proposing an issue. )}
Issue Information Provide details about the issue you want to propose for discussion.