"use client";
import { useState } from "react";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
// Client component for selecting a lesson
function LessonSelector({ userId }: { userId: number }) {
  const [lessonId, setLessonId] = useState<string>("");

  return (
    <div className="container mx-auto py-8">
      <Card className="p-6 max-w-md mx-auto">
        <h1 className="text-2xl font-bold mb-6">Start Study Session</h1>

        <form action={`/study?lessonId=${lessonId}`}>
          <div className="space-y-4">
            <div>
              <Label htmlFor="lessonId">Lesson ID</Label>
              <Input
                id="lessonId"
                value={lessonId}
                onChange={(e) => setLessonId(e.target.value)}
                placeholder="Enter lesson ID"
                type="number"
                required
              />
            </div>

            <Button type="submit" className="w-full">
              Start Study Session
            </Button>
          </div>
        </form>

        <div className="mt-6 pt-6 border-t border-gray-200">
          <h2 className="text-lg font-medium mb-3">Available Lessons</h2>
          <p className="text-sm text-gray-500 mb-4">
            Here are some example lesson IDs you can use:
          </p>
          <div className="flex flex-wrap gap-2">
            <Button
              variant="outline"
              size="sm"
              onClick={() => setLessonId("1")}
            >
              Lesson 1
            </Button>
            <Button
              variant="outline"
              size="sm"
              onClick={() => setLessonId("2")}
            >
              Lesson 2
            </Button>
            <Button
              variant="outline"
              size="sm"
              onClick={() => setLessonId("5")}
            >
              Lesson 5
            </Button>
          </div>

          <div className="mt-4">
            <Button variant="ghost" size="sm" asChild className="text-blue-500">
              <a href="/">Back to Home</a>
            </Button>
          </div>
        </div>
      </Card>
    </div>
  );
}

export default LessonSelector;
