import { Router } from "express";

import { apiReturn } from "../utils/returnHelper.utils.js";
import loadUnit from "./dockdoor.loadUnits.js";

const r = Router();

r.post("/", async (req, res) => {
	const unit = await loadUnit({
		dockId: req.body.dockId,
		runningNo: req.body.runningNo,
	});

	return apiReturn(res, {
		success: unit.success,
		level: "info",
		module: "dockdoor",
		subModule: "loadingUnit",
		message: unit.message,
		data: unit?.data ?? [],
		status: unit.success ? 200 : 400,
	});
});

export default r;
