From e865c1dcaf8e9ee3710f8d9f65e95118bb3fa3e7 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 12 Jun 2025 21:12:15 -0500 Subject: [PATCH] test(added in commands): relocate and updated to remove --- .../helperCommands/commands/Relocate.tsx | 133 ++++++++++++++++++ .../logistics/helperCommands/helperPage.tsx | 3 + .../materialHelper/consumption/index.tsx | 9 +- .../(logistics)/materialHelper/index.tsx | 2 +- .../commands/removeAsNonReusable.ts | 2 +- .../ocp/controller/printers/updatePrinters.ts | 2 + server/services/prodUser/prodUser.ts | 3 +- 7 files changed, 149 insertions(+), 5 deletions(-) create mode 100644 frontend/src/components/logistics/helperCommands/commands/Relocate.tsx diff --git a/frontend/src/components/logistics/helperCommands/commands/Relocate.tsx b/frontend/src/components/logistics/helperCommands/commands/Relocate.tsx new file mode 100644 index 0000000..e3116ad --- /dev/null +++ b/frontend/src/components/logistics/helperCommands/commands/Relocate.tsx @@ -0,0 +1,133 @@ +import { LstCard } from "@/components/extendedUI/LstCard"; +import { Button } from "@/components/ui/button"; +import { CardContent, CardHeader } from "@/components/ui/card"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { useForm } from "@tanstack/react-form"; +import axios from "axios"; +import { useState } from "react"; +import { toast } from "sonner"; + +export default function Relocate() { + const [bookingIn, setBookingIn] = useState(false); + const form = useForm({ + defaultValues: { runningNr: " ", lane: "" }, + onSubmit: async ({ value }) => { + // Do something with form data + setBookingIn(true); + + try { + const res = await axios.post("/api/ocp/bookin", { + runningNr: parseInt(value.runningNr), + }); + + if (res.data.success) { + toast.success(res.data.message); + form.reset(); + setBookingIn(false); + } else { + console.log(res.data.data.errors); + toast.error(res.data.data.errors[0]?.message); + form.reset(); + setBookingIn(false); + } + } catch (error) { + console.log(error); + toast.error( + "There was an error booking in pallet please validate you entered the correct info and try again." + ); + setBookingIn(false); + } + }, + }); + return ( + + +

Relocate a pallet to another lane

+
+
{ + e.preventDefault(); + e.stopPropagation(); + }} + > + + + value.length > 2 + ? undefined + : "Please enter a valid running number", + }} + children={(field) => { + return ( +
+ + + field.handleChange(e.target.value) + } + /> + {field.state.meta.errors.length ? ( + + {field.state.meta.errors.join(",")} + + ) : null} +
+ ); + }} + /> + + value.length > 2 + ? undefined + : "Please enter a valid running number", + }} + children={(field) => { + return ( +
+ + + field.handleChange(e.target.value) + } + /> + {field.state.meta.errors.length ? ( + + {field.state.meta.errors.join(",")} + + ) : null} +
+ ); + }} + /> +
+ +
+
+
+
+ ); +} diff --git a/frontend/src/components/logistics/helperCommands/helperPage.tsx b/frontend/src/components/logistics/helperCommands/helperPage.tsx index d403a11..3f45e77 100644 --- a/frontend/src/components/logistics/helperCommands/helperPage.tsx +++ b/frontend/src/components/logistics/helperCommands/helperPage.tsx @@ -1,7 +1,9 @@ import Bookin from "./commands/Bookin"; +import Relocate from "./commands/Relocate"; import RemoveAsNonReusable from "./commands/RemoveAsNonReusable"; export default function HelperPage() { + const url: string = window.location.host.split(":")[0]; return (
@@ -11,6 +13,7 @@ export default function HelperPage() {
+
{url === "localhost" && }
); } diff --git a/frontend/src/routes/(logistics)/materialHelper/consumption/index.tsx b/frontend/src/routes/(logistics)/materialHelper/consumption/index.tsx index 9f98756..93251cc 100644 --- a/frontend/src/routes/(logistics)/materialHelper/consumption/index.tsx +++ b/frontend/src/routes/(logistics)/materialHelper/consumption/index.tsx @@ -1,7 +1,10 @@ import ConsumeMaterial from "@/components/logistics/materialHelper/consumption/ConsumeMaterial"; -import {createFileRoute} from "@tanstack/react-router"; +import PreformReturn from "@/components/logistics/materialHelper/consumption/PreformReturn"; +import { createFileRoute } from "@tanstack/react-router"; -export const Route = createFileRoute("/(logistics)/materialHelper/consumption/")({ +export const Route = createFileRoute( + "/(logistics)/materialHelper/consumption/" +)({ component: RouteComponent, head: () => ({ meta: [ @@ -17,9 +20,11 @@ export const Route = createFileRoute("/(logistics)/materialHelper/consumption/") }); function RouteComponent() { + const url: string = window.location.host.split(":")[0]; return (
+ {url === "localhost" && }
); } diff --git a/frontend/src/routes/(logistics)/materialHelper/index.tsx b/frontend/src/routes/(logistics)/materialHelper/index.tsx index 2f94d5d..42cfc7f 100644 --- a/frontend/src/routes/(logistics)/materialHelper/index.tsx +++ b/frontend/src/routes/(logistics)/materialHelper/index.tsx @@ -1,5 +1,5 @@ import MaterialHelperPage from "@/components/logistics/materialHelper/materialHelperPage"; -import {createFileRoute} from "@tanstack/react-router"; +import { createFileRoute } from "@tanstack/react-router"; export const Route = createFileRoute("/(logistics)/materialHelper/")({ component: RouteComponent, diff --git a/server/services/logistics/controller/commands/removeAsNonReusable.ts b/server/services/logistics/controller/commands/removeAsNonReusable.ts index cc0d570..15a0be4 100644 --- a/server/services/logistics/controller/commands/removeAsNonReusable.ts +++ b/server/services/logistics/controller/commands/removeAsNonReusable.ts @@ -72,7 +72,7 @@ export const removeAsNonReusable = async (data: any) => { if (stage === 0) { stage = 1; scanner.write( - `${STX}${scannerID[0].value}${label.data[0].Barcode}${ETX}` + `${STX}${scannerID[0].value}@${label.data[0].Barcode}${ETX}` ); } else if (stage === 1) { scanner.end(); diff --git a/server/services/ocp/controller/printers/updatePrinters.ts b/server/services/ocp/controller/printers/updatePrinters.ts index fffa36c..3b17bf8 100644 --- a/server/services/ocp/controller/printers/updatePrinters.ts +++ b/server/services/ocp/controller/printers/updatePrinters.ts @@ -44,6 +44,7 @@ export const updatePrinters = async () => { ipAddress: prodPrinterInfo[i].ipAddress, port: prodPrinterInfo[i].port, remark: prodPrinterInfo[i].remark, + processes: prodPrinterInfo[i].processes, }; const { data, error } = await tryCatch( db @@ -57,6 +58,7 @@ export const updatePrinters = async () => { ipAddress: prodPrinterInfo[i].ipAddress, port: prodPrinterInfo[i].port, remark: prodPrinterInfo[i].remark, + processes: prodPrinterInfo[i].processes, upd_date: sql`NOW()`, //printDelay: "90", // need to remove in a couple weeks }, diff --git a/server/services/prodUser/prodUser.ts b/server/services/prodUser/prodUser.ts index 26d843a..ee238b5 100644 --- a/server/services/prodUser/prodUser.ts +++ b/server/services/prodUser/prodUser.ts @@ -1,10 +1,11 @@ import { OpenAPIHono } from "@hono/zod-openapi"; import produser from "./routes/produser.js"; import createProdRole from "./routes/addProdRole.js"; +import getRoles from "./routes/getProdRoles.js"; import { prodRoles } from "./utils/prodRoles.js"; const app = new OpenAPIHono(); -const routes = [produser, createProdRole] as const; +const routes = [produser, createProdRole, getRoles] as const; const appRoutes = routes.forEach((route) => { app.route("/produser", route);