import { Router } from "express";
import { requireAuth, requireRole } from "../middleware/auth.js";

export const adminRouter = Router();

adminRouter.use(requireAuth, requireRole("admin", "super_admin"));

adminRouter.get("/analytics", (_request, response) => {
  response.json({
    gmv: 86400000,
    revenue: 12900000,
    activeVendors: 1284,
    openDisputes: 23,
    fulfillmentSla: 96.2,
    channels: ["paystack", "flutterwave", "wallet", "bank_transfer", "cod"]
  });
});

adminRouter.post("/notifications", (request, response) => {
  request.app.get("io").emit("notification:broadcast", request.body);
  response.status(202).json({ message: "Notification broadcast queued" });
});

adminRouter.get("/reports/export", (_request, response) => {
  response.json({ message: "Report export queued", format: "csv" });
});
