From 9a0bb18c5b9d5000cfd9c1c3e50a0442fb027bf2 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Wed, 17 Jun 2026 01:44:15 -0500 Subject: [PATCH] feat(dm): added in a repost incase we wanted do this instead of reuploading the file ref #31 --- .../logistics/logistics.dm.repost.route.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 backend/logistics/logistics.dm.repost.route.ts diff --git a/backend/logistics/logistics.dm.repost.route.ts b/backend/logistics/logistics.dm.repost.route.ts new file mode 100644 index 0000000..585a289 --- /dev/null +++ b/backend/logistics/logistics.dm.repost.route.ts @@ -0,0 +1,56 @@ +import { Router } from "express"; +import { requireAuth } from "../middleware/auth.middleware.js"; +import { apiReturn } from "../utils/returnHelper.utils.js"; +import { postData } from "./logistics.dm.postData.js"; + +const r = Router(); + +r.post("/", requireAuth, async (req, res) => { + let posting: any; + + if (req.body.type !== "forecast" || req.body.type !== "orders") { + return apiReturn(res, { + success: false, + level: "error", + module: "dm", + subModule: "repost", + message: "You must pass over a proper type.", + data: [], + status: 500, + }); + } + + if (req.body.type === "forecast") { + posting = await postData( + { + type: "forecast", + endpoint: "/public/v1.0/DemandManagement/DELFOR", + data: req.body.data as any, + }, + req.user, + ); + } + + if (req.body.type === "orders") { + posting = await postData( + { + type: "orders", + endpoint: "/public/v1.0/DemandManagement/ORDERS", + data: req.body.data as any, + }, + req.user, + ); + } + + return apiReturn(res, { + success: posting.success, + level: posting.success ? "info" : "error", + module: "dm", + subModule: "repost", + message: posting.message, + data: [], + status: 200, + }); +}); + +export default r;