'use client'

import { useState, useCallback } from 'react'

export type DragState = 'idle' | 'dragging' | 'drag-over'

export function useNoteDrag() {
  const [draggedNoteId, setDraggedNoteId] = useState<string | null>(null)
  const [dragOverNotebookId, setDragOverNotebookId] = useState<string | null>(null)

  const startDrag = useCallback((noteId: string) => {
    setDraggedNoteId(noteId)
  }, [])

  const endDrag = useCallback(() => {
    setDraggedNoteId(null)
    setDragOverNotebookId(null)
  }, [])

  const dragOver = useCallback((notebookId: string | null) => {
    setDragOverNotebookId(notebookId)
  }, [])

  const isDragging = draggedNoteId !== null
  const isDragOver = dragOverNotebookId !== null

  return {
    draggedNoteId,
    dragOverNotebookId,
    startDrag,
    endDrag,
    dragOver,
    isDragging,
    isDragOver,
  }
}
