package router

import (
	"bookhoard/internal/handlers"
)

func registerQueueRoutes(cfg *Config) {
	e := cfg.Echo

	// JWT middleware for protected routes
	jwtMiddleware := createJWTMiddleware(cfg)

	protected := e.Group("/api", jwtMiddleware)

	// Sync queue management routes (protected - require user auth)
	queue := protected.Group("/queue")
	queue.GET("/devices/:device_id/stats", cfg.QueueHandler.GetDeviceQueueStats)
	queue.GET("/devices/:device_id/items", cfg.QueueHandler.ListDeviceQueueItems)
	queue.POST("/items/:item_id/retry", cfg.QueueHandler.RetryQueueItem)
	queue.DELETE("/items/:item_id", cfg.QueueHandler.DeleteQueueItem)
	queue.DELETE("/devices/:device_id/clear", cfg.QueueHandler.ClearDeviceQueue)

	// Admin-only queue routes
	adminQueue := queue.Group("", handlers.AdminMiddleware)
	adminQueue.GET("/items", cfg.QueueHandler.ListAllQueueItems)
}
