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

export const printRouter = Router();

printRouter.post("/quote", (request, response) => {
  const { quantity = 100, material = "Matte Card", size = "Standard" } = request.body;
  const materialRate = String(material).includes("Vinyl") || String(material).includes("Flex") ? 95 : 52;
  const sizeRate = size === "Large Format" ? 3.5 : size === "A3" ? 2.2 : 1;
  response.json({ estimate: Math.round(Number(quantity) * materialRate * sizeRate), currency: "NGN" });
});

printRouter.post("/upload-artwork", requireAuth, upload.single("artwork"), (_request, response) => {
  response.status(201).json({ message: "Artwork received for validation", assetUrl: "cloudinary://pending-upload" });
});

printRouter.post("/approval/:orderId", requireAuth, (_request, response) => {
  response.json({ message: "Design approval workflow updated" });
});
