import express from "express";
import YardLayoutController from "../controllers/YardLayoutController";
import { authenticateToken } from "../middleware/authMiddleware";

const router = express.Router();

// 모든 라우트에 인증 미들웨어 적용
router.use(authenticateToken);

// 야드 레이아웃 관리
router.get("/", YardLayoutController.getAllLayouts);
router.get("/:id", YardLayoutController.getLayoutById);
router.post("/", YardLayoutController.createLayout);
router.put("/:id", YardLayoutController.updateLayout);
router.delete("/:id", YardLayoutController.deleteLayout);
router.post("/:id/duplicate", YardLayoutController.duplicateLayout);

// 자재 배치 관리
router.get("/:id/placements", YardLayoutController.getPlacementsByLayoutId);
router.post("/:id/placements", YardLayoutController.addMaterialPlacement);
router.put("/:id/placements/batch", YardLayoutController.batchUpdatePlacements);

// 개별 배치 관리 (별도 경로)
router.put("/placements/:id", YardLayoutController.updatePlacement);
router.delete("/placements/:id", YardLayoutController.removePlacement);

export default router;
