import bodyParser from "body-parser";
import { createSupport, deleteImageFromCloudinary, deleteSupport, getAllSupportTicket, getAllSupportTicketofuser, getOneSupportTicket, updateSupport } from "./supportController.js";
import { isAuthenticatedUser, authorizeRoles } from "../../middlewares/auth.js";
import express from "express";

const app = express();

// Configure bodyParser to parse the raw request body as a buffer
app.use(bodyParser.raw({ type: "application/json" }));

const router = express.Router();
//checkout Routes-------------------------//
router.route("/support/create/").post(isAuthenticatedUser,createSupport);
router.route("/support/getAll/").get(isAuthenticatedUser, authorizeRoles("admin"),getAllSupportTicket);
router.route("/support/userticket/").get(isAuthenticatedUser,getAllSupportTicketofuser);
router
  .route("/support/delete/:id")
  .delete( deleteSupport);
  router.route("/support/getOne/:id").get(isAuthenticatedUser, getOneSupportTicket);
  router
  .route("/support/update/:id")
  .patch(isAuthenticatedUser, updateSupport);
  router
  .route("/support/deleteImage/jatinMor/CustomerSupport/:public_id")
  .delete(
    isAuthenticatedUser,
    authorizeRoles("admin"),
    deleteImageFromCloudinary
  );
// ---------------------------------------------------------

export default router;
