const express = require("express");
const router = express.Router();
const {
  getChartData,
  getHomeData,
  getCompanyName,
  getSharepointInfo,
  setupSharepointLists,
} = require("../controllers/companies");
const {
  getSharepointStatus,
  getSharepointLists,
  saveSharepointMapping,
  autoCreateSharepointLists,
} = require("../controllers/companySharepoint");
const authMiddleware = require("../middleware/authMiddleware");
const adminMiddleware = require("../middleware/adminMiddleware");

router.get("/chart", authMiddleware, getChartData);

router.get("/", authMiddleware, getHomeData);

router.post("/company-name", getCompanyName);

router.get("/sharepoint/info", authMiddleware, getSharepointInfo);
router.post("/sharepoint/setup", authMiddleware, adminMiddleware, setupSharepointLists);
router.get("/sharepoint/status", authMiddleware, getSharepointStatus);
router.get("/sharepoint/lists", authMiddleware, adminMiddleware, getSharepointLists);
router.post("/sharepoint/mapping", authMiddleware, adminMiddleware, saveSharepointMapping);
router.post("/sharepoint/auto-create", authMiddleware, adminMiddleware, autoCreateSharepointLists);

module.exports = router;
