import { Router } from "express";
import { runProdApi } from "../utils/prodEndpoint.utils.js";
import { apiReturn } from "../utils/returnHelper.utils.js";

const router = Router();

router.post("/", async (req, res) => {
	const body = req.body;

	const lane = body.lane.split("#");

	console.log(lane[2]);
	const laneData = await runProdApi({
		method: "post",
		endpoint: "/public/v1.1/Warehousing/GetWarehouseUnits",
		data: [
			{
				laneIds: [lane[2]],
			},
		],
	});

	return apiReturn(res, {
		success: true,
		level: "info",
		module: "mobile",
		subModule: "lane check",
		message: `all data for lane Id: ${lane}`,
		data: laneData?.data ?? [],
		status: 200,
	});
});

export default router;
