import { Router } from "express";
import {
  createOrder,
  deleteOrder,
  getOrderById,
  getOrders,
  updateOrderStatus,
  payOrder,
  updateOrder,
  getDashboardStats
} from "../controllers/ordersController.js";
import { requirePermission } from "../middleware/auth.js";

const router = Router();

router.get("/stats/dashboard", getDashboardStats);
router.get("/", getOrders);
router.get("/:id", getOrderById);
router.post("/", requirePermission("orders", "create"), createOrder);
router.put("/:id/status", requirePermission("orders", "edit"), updateOrderStatus);
router.post("/:id/pay", requirePermission("orders", "edit"), payOrder);
router.put("/:id", requirePermission("orders", "edit"), updateOrder);
router.delete("/:id", requirePermission("orders", "delete"), deleteOrder);

export default router;
