feat(silo adjustments): added in email if % wrong

This commit is contained in:
2025-04-06 07:47:39 -05:00
parent 85e3d46b2e
commit 95bebbde2b
10 changed files with 178 additions and 11 deletions

View File

@@ -0,0 +1,24 @@
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
import { query } from "../../../sqlServer/prodSqlServer.js";
import { siloQuery } from "../../../sqlServer/querys/silo/siloQuery.js";
export const getStockSiloData = async () => {
/**
* will return the current stock info where the silo is checked
*/
const { data, error } = await tryCatch(query(siloQuery, "Get silo data"));
if (error) {
return {
success: false,
message: "There was a n error getting the silo data.",
};
}
return {
success: true,
message: "Current silo data from alplastock.",
data: data,
};
};

View File

@@ -0,0 +1,50 @@
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import { authMiddleware } from "../../../auth/middleware/authMiddleware.js";
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
import { getStockSiloData } from "../../controller/siloAdjustments/getCurrentStockSiloData.js";
const app = new OpenAPIHono();
app.openapi(
createRoute({
tags: ["logistics"],
summary: "Returns current stock levels for silos",
method: "get",
path: "/getstocksilo",
middleware: authMiddleware,
// request: {
// params: ParamsSchema,
// body: { content: { "application/json": { schema: Body } } },
// },
// description:
// "Creates a silo adjustment for the silo if and stores the stock numbers.",
responses: responses(),
}),
async (c) => {
//apiHit(c, { endpoint: "api/sqlProd/close" });
try {
//return apiReturn(c, true, access?.message, access?.data, 200);
const silo = await getStockSiloData();
return c.json(
{
success: silo.success,
message: silo.message,
data: silo.data,
},
200
);
} catch (error) {
return c.json(
{
success: false,
message: "Missing data please try again",
error,
},
400
);
}
}
);
export default app;