import { Router } from "express";
import { PumpReadingController } from "./pumpReading.controller";
import { authMiddleware } from "../auth/auth.middleware";

const pumpReadingRouter = Router();

const controller = new PumpReadingController();

// Obtener todas las lecturas
pumpReadingRouter.get("/", authMiddleware, controller.getAll);

// Obtener lectura por ID
pumpReadingRouter.get("/:id", authMiddleware, controller.getById);

// Crear lectura
pumpReadingRouter.post("/",authMiddleware, controller.create
);

// Actualizar lectura
pumpReadingRouter.put("/:id", authMiddleware, controller.update);

// Eliminar lectura
pumpReadingRouter.delete("/:id", authMiddleware, controller.delete);

// Calcular galones despachados
pumpReadingRouter.post("/:id/calculate-dispensed", authMiddleware, controller.calculateDispensedGallons);

// Calcular galones registrados en el sistema
pumpReadingRouter.post("/:id/calculate-system", authMiddleware, controller.calculateSystemDispensed);

// Calcular diferencia
pumpReadingRouter.post("/:id/calculate-difference", authMiddleware, controller.calculateDifference);

// Actualizar estado
pumpReadingRouter.post("/:id/update-status",authMiddleware,controller.updateStatus);

// Actualizar Fuel Requests relacionadas
pumpReadingRouter.post("/:id/update-requests", authMiddleware, controller.updateFuelRequests);

// Crear anomalía por diferencia
pumpReadingRouter.post("/:id/create-anomaly", authMiddleware, controller.createDifferenceAnomaly);

// Cerrar lectura (realiza todo el proceso)
pumpReadingRouter.post("/:id/close", authMiddleware, controller.closeReading);

export default pumpReadingRouter;