const express = require("express");
const { body } = require("express-validator");
const validation = require("../../../../middlewares/routeValidation");
const isAuth = require("../../../../middlewares/authorization");
const jsonParser = require("../../../../helpers/jsonParser");
const pagination = require("../../../../middlewares/pagination");

const {
  getAllOrderForm,
  getOrderFormByIdWithOrderDetails,
  updateOrderForm,
  dashboardOrderData,
  qrScanOrder,
} = require("../../../../controllers/seller/order-form");
const checkPermissionMiddleware = require("../../../../middlewares/permission");
const { SELLER_ORDERS_MODULE } = require("../../../../helpers/common");

const router = express.Router();

router.use(pagination);
router.get(
  "/",
  isAuth,
  checkPermissionMiddleware(SELLER_ORDERS_MODULE, "view"),
  getAllOrderForm
);
router.get(
  "/:reference_no",
  isAuth,
  checkPermissionMiddleware(SELLER_ORDERS_MODULE, "view"),
  getOrderFormByIdWithOrderDetails
);
router.patch(
  "/:reference_no",
  isAuth,
  jsonParser,
  checkPermissionMiddleware(SELLER_ORDERS_MODULE, "edit"),
  updateOrderForm
);
router.get("/dashboard/data", isAuth, dashboardOrderData);
router.post(
  "/qr-scan",
  isAuth,
  checkPermissionMiddleware(SELLER_ORDERS_MODULE, "add"),
  qrScanOrder
);

module.exports = router;
