"use client"

import { useState } from "react"
import type { KnowledgePoint } from "../types"

/**
 * 知识点相关对话框状态管理 Hook。
 *
 * 管理：编辑对话框、题目创建对话框、删除确认对话框。
 */
export function useKpDialogState() {
  const [editingKp, setEditingKp] = useState<KnowledgePoint | null>(null)
  const [editKpDialogOpen, setEditKpDialogOpen] = useState(false)
  const [isUpdatingKp, setIsUpdatingKp] = useState(false)

  const [questionDialogOpen, setQuestionDialogOpen] = useState(false)
  const [targetKpForQuestion, setTargetKpForQuestion] = useState<KnowledgePoint | null>(null)

  const [deleteConfirmOpen, setDeleteConfirmOpen] = useState(false)
  const [pendingDeleteKpId, setPendingDeleteKpId] = useState<string | null>(null)

  return {
    editingKp,
    setEditingKp,
    editKpDialogOpen,
    setEditKpDialogOpen,
    isUpdatingKp,
    setIsUpdatingKp,
    questionDialogOpen,
    setQuestionDialogOpen,
    targetKpForQuestion,
    setTargetKpForQuestion,
    deleteConfirmOpen,
    setDeleteConfirmOpen,
    pendingDeleteKpId,
    setPendingDeleteKpId,
  }
}
