import { useState } from "react" import { useNavigate } from "react-router-dom" import { X, Plus, Check, ArrowLeft } from "lucide-react" import { Button } from "../../components/ui/button" import { Card } from "../../components/ui/card" import { Input } from "../../components/ui/input" import { Textarea } from "../../components/ui/textarea" import { Select } from "../../components/ui/select" import { Stepper } from "../../components/ui/stepper" import { Badge } from "../../components/ui/badge" import { Avatar, AvatarFallback, AvatarImage } from "../../components/ui/avatar" type QuestionType = "multiple-choice" | "short-answer" | "true-false" interface Question { id: string question: string type: QuestionType options: string[] correctAnswer: string points: number } interface PracticeFormData { title: string description: string category: string difficulty: string duration: string tags: string participants: string[] questions: Question[] } const STEPS = ["Details", "Questions", "Review"] export function AddPracticePage() { const navigate = useNavigate() const [currentStep, setCurrentStep] = useState(1) const [formData, setFormData] = useState({ title: "", description: "", category: "", difficulty: "", duration: "", tags: "", participants: [], questions: [], }) const [currentQuestion, setCurrentQuestion] = useState>({ question: "", type: "multiple-choice", options: ["", "", "", ""], correctAnswer: "", points: 10, }) const mockParticipants = [ { id: "1", name: "Sarah", avatar: "" }, { id: "2", name: "Jon", avatar: "" }, { id: "3", name: "Priya", avatar: "" }, { id: "4", name: "Jake", avatar: "" }, { id: "5", name: "Emma", avatar: "" }, { id: "6", name: "Robert", avatar: "" }, { id: "7", name: "Luke", avatar: "" }, { id: "8", name: "Ethan", avatar: "" }, ] const toggleParticipant = (id: string) => { setFormData((prev) => ({ ...prev, participants: prev.participants.includes(id) ? prev.participants.filter((p) => p !== id) : [...prev.participants, id], })) } const addQuestion = () => { if (!currentQuestion.question || !currentQuestion.correctAnswer) return const newQuestion: Question = { id: Date.now().toString(), question: currentQuestion.question, type: currentQuestion.type as QuestionType, options: currentQuestion.options || [], correctAnswer: currentQuestion.correctAnswer, points: currentQuestion.points || 10, } setFormData((prev) => ({ ...prev, questions: [...prev.questions, newQuestion], })) setCurrentQuestion({ question: "", type: "multiple-choice", options: ["", "", "", ""], correctAnswer: "", points: 10, }) } const addOption = () => { setCurrentQuestion((prev) => ({ ...prev, options: [...(prev.options || []), ""], })) } const updateOption = (index: number, value: string) => { setCurrentQuestion((prev) => ({ ...prev, options: prev.options?.map((opt, i) => (i === index ? value : opt)), })) } const handleSubmit = () => { console.log("Practice data:", formData) // Handle form submission } const canProceedToStep2 = () => { return ( formData.title && formData.description && formData.category && formData.difficulty && formData.duration ) } const canProceedToStep3 = () => { return formData.questions.length > 0 } return (
{/* Header */}

Add practice

Draft a practice session with questions (demo flow — wire to API when ready).

{/* Stepper */}
{/* Step 1: Details */} {currentStep === 1 && (

Step 1: Details

Basics for this practice session.

setFormData({ ...formData, title: e.target.value })} placeholder="Enter practice title" required />