'use client'; import { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Label } from '@/components/ui/label'; import { Input } from '@/components/ui/input'; import { Slider } from '@/components/ui/slider'; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from '@/components/ui/alert-dialog'; import { CheckCircle2 } from 'lucide-react'; interface LiveVotingFormProps { sessionId?: string; projectId: string; onVoteSubmit: (vote: { score: number }) => void; disabled?: boolean; } export function LiveVotingForm({ sessionId, projectId, onVoteSubmit, disabled = false }: LiveVotingFormProps) { const [score, setScore] = useState(50); const [confirmDialogOpen, setConfirmDialogOpen] = useState(false); const [hasSubmitted, setHasSubmitted] = useState(false); const handleSubmit = () => { setConfirmDialogOpen(true); }; const handleConfirm = () => { onVoteSubmit({ score }); setHasSubmitted(true); setConfirmDialogOpen(false); }; if (hasSubmitted || disabled) { return ( Vote Submitted Score: {score}/100 ); } return ( <> Live Voting Rate this project on a scale of 0-100 Score setScore(Math.min(100, Math.max(0, parseInt(e.target.value) || 0)))} className="w-20 text-center" /> {score} setScore(values[0])} min={0} max={100} step={1} className="w-full" /> Poor (0) Average (50) Excellent (100) Submit Vote {/* Confirmation Dialog */} Confirm Your Vote You are about to submit a score of {score}/100. This action cannot be undone. Are you sure? Cancel Confirm Vote > ); }
Vote Submitted
Score: {score}/100