import {
  BookOpen,
  Library,
  ClipboardList,
  Users,
  MessageSquare,
  Megaphone,
  CalendarCheck,
} from "lucide-react";

import { QuickSetupWizard, type WizardStep, type QuickCreate } from "@/components/QuickSetupWizard";
import { lmsService } from "@/services/lms.service";
import { assignmentsService } from "@/services/assignments.service";

/**
 * Teacher smart-setup wizard.
 *
 * Walks a teacher through the "launch a new course" happy path:
 * create course → add chapters → upload resources → assign & track.
 * The same cards are available later as ad-hoc "quick creates".
 */

const steps: WizardStep[] = [
  {
    id: "course",
    titleKey: "quickSetup.teacher.step1.title",
    descriptionKey: "quickSetup.teacher.step1.description",
    helpKey: "quickSetup.teacher.step1.help",
    to: "/teacher/courses/new",
    icon: BookOpen,
    check: async () => {
      const res = await lmsService.listCourses({ page: 1, size: 1 });
      return (res.items?.length ?? 0) > 0;
    },
  },
  {
    id: "chapters",
    titleKey: "quickSetup.teacher.step2.title",
    descriptionKey: "quickSetup.teacher.step2.description",
    helpKey: "quickSetup.teacher.step2.help",
    to: "/teacher/courses",
    icon: Library,
    // Chapter counts live under /courses/:id/chapters — too expensive to
    // sample for existence across all courses, so leave uncheckable.
  },
  {
    id: "resources",
    titleKey: "quickSetup.teacher.step3.title",
    descriptionKey: "quickSetup.teacher.step3.description",
    helpKey: "quickSetup.teacher.step3.help",
    to: "/teacher/library",
    icon: Library,
  },
  {
    id: "assignments",
    titleKey: "quickSetup.teacher.step4.title",
    descriptionKey: "quickSetup.teacher.step4.description",
    helpKey: "quickSetup.teacher.step4.help",
    to: "/teacher/assignments",
    icon: ClipboardList,
    check: async () => {
      const res = await assignmentsService.listSchedules({ page: 1, size: 1 });
      return (res.items?.length ?? 0) > 0;
    },
  },
  {
    id: "track",
    titleKey: "quickSetup.teacher.step5.title",
    descriptionKey: "quickSetup.teacher.step5.description",
    helpKey: "quickSetup.teacher.step5.help",
    to: "/teacher/students",
    icon: Users,
  },
];

const quickCreates: QuickCreate[] = [
  {
    id: "discussion",
    titleKey: "quickSetup.teacher.quick.discussion.title",
    descriptionKey: "quickSetup.teacher.quick.discussion.description",
    to: "/teacher/discussions",
    icon: MessageSquare,
  },
  {
    id: "announcement",
    titleKey: "quickSetup.teacher.quick.announcement.title",
    descriptionKey: "quickSetup.teacher.quick.announcement.description",
    to: "/teacher/announcements",
    icon: Megaphone,
  },
  {
    id: "attendance",
    titleKey: "quickSetup.teacher.quick.attendance.title",
    descriptionKey: "quickSetup.teacher.quick.attendance.description",
    to: "/teacher/attendance",
    icon: CalendarCheck,
  },
];

export default function TeacherQuickSetup() {
  return (
    <QuickSetupWizard
      titleKey="quickSetup.teacherTitle"
      subtitleKey="quickSetup.teacherSubtitle"
      steps={steps}
      quickCreates={quickCreates}
    />
  );
}
