import { Router } from "express";
import { authenticateToken } from "../middleware/authMiddleware";
import * as salesEstimateController from "../controllers/salesEstimateController";

const router = Router();
router.use(authenticateToken);

router.get("/list", salesEstimateController.getList);
router.get("/generate-number", salesEstimateController.generateNumber);

// G6 메일 발송 — /:id 라우트보다 위에 (mail-info/managers는 path param 충돌 방지)
router.post("/mail", salesEstimateController.sendMail);
router.get("/mail-info/:id", salesEstimateController.getMailInfo);
router.get("/customer/:customerObjid/managers", salesEstimateController.getMailManagers);

// G5 견적작성 (estimate_template) — /:id 라우트보다 위에
router.post("/template1", salesEstimateController.saveTemplate1);
router.post("/template2", salesEstimateController.saveTemplate2);
router.get("/template/:templateObjid", salesEstimateController.getTemplate);
router.get("/templates/:contractObjid", salesEstimateController.listTemplates);

// G4/G11 동일 패턴 — 견적 결재상신 (Amaranth SSO URL 발급) — /:id 라우트보다 위에
router.post("/:id/amaranth-approval", salesEstimateController.startApproval);

router.get("/:id", salesEstimateController.getById);
router.post("/", salesEstimateController.create);
router.put("/:id", salesEstimateController.update);
router.delete("/:id", salesEstimateController.remove);

export default router;
