feat(helpercommand): bookin pallets

This commit is contained in:
2025-05-02 19:12:28 -05:00
parent 3817c33638
commit 3a78f77475
5 changed files with 214 additions and 6 deletions

View File

@@ -0,0 +1,102 @@
import { LstCard } from "@/components/extendedUI/LstCard";
import { Button } from "@/components/ui/button";
import { CardContent, CardFooter, 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 Bookin() {
const [bookingIn, setBookingIn] = useState(false);
const form = useForm({
defaultValues: { runningNr: " " },
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 (
<LstCard>
<CardHeader>
<p>Book in a pallet by running number</p>
</CardHeader>
<form
onSubmit={(e) => {
e.preventDefault();
e.stopPropagation();
}}
>
<CardContent>
<form.Field
name="runningNr"
validators={{
// We can choose between form-wide and field-specific validators
onChange: ({ value }) =>
value.length > 2
? undefined
: "Please enter a valid running number",
}}
children={(field) => {
return (
<div className="m-2 min-w-48 max-w-96 p-2">
<Label htmlFor="runningNr" className="mb-2">
Runnning Number
</Label>
<Input
name={field.name}
value={field.state.value}
onBlur={field.handleBlur}
type="number"
onChange={(e) =>
field.handleChange(e.target.value)
}
/>
{field.state.meta.errors.length ? (
<em>
{field.state.meta.errors.join(",")}
</em>
) : null}
</div>
);
}}
/>
</CardContent>
<CardFooter>
<div className="flex justify-end">
<Button
onClick={form.handleSubmit}
disabled={bookingIn}
>
Book in
</Button>
</div>
</CardFooter>
</form>
</LstCard>
);
}

View File

@@ -0,0 +1,9 @@
import Bookin from "./commands/Bookin";
export default function HelperPage() {
return (
<div>
<Bookin />
</div>
);
}

View File

@@ -33,6 +33,7 @@ import { Route as ocmeCyclecountIndexImport } from './routes/(ocme)/cyclecount/i
import { Route as logisticsSiloAdjustmentsIndexImport } from './routes/(logistics)/siloAdjustments/index'
import { Route as logisticsOpenOrdersIndexImport } from './routes/(logistics)/openOrders/index'
import { Route as logisticsMaterialHelperIndexImport } from './routes/(logistics)/materialHelper/index'
import { Route as logisticsHelperCommandsIndexImport } from './routes/(logistics)/helperCommands/index'
import { Route as logisticsDmIndexImport } from './routes/(logistics)/dm/index'
import { Route as EomArticleAvImport } from './routes/_eom/article/$av'
import { Route as logisticsSiloAdjustmentsHistImport } from './routes/(logistics)/siloAdjustments/$hist'
@@ -173,6 +174,13 @@ const logisticsMaterialHelperIndexRoute =
getParentRoute: () => rootRoute,
} as any)
const logisticsHelperCommandsIndexRoute =
logisticsHelperCommandsIndexImport.update({
id: '/(logistics)/helperCommands/',
path: '/helperCommands/',
getParentRoute: () => rootRoute,
} as any)
const logisticsDmIndexRoute = logisticsDmIndexImport.update({
id: '/(logistics)/dm/',
path: '/dm/',
@@ -364,6 +372,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof logisticsDmIndexImport
parentRoute: typeof rootRoute
}
'/(logistics)/helperCommands/': {
id: '/(logistics)/helperCommands/'
path: '/helperCommands'
fullPath: '/helperCommands'
preLoaderRoute: typeof logisticsHelperCommandsIndexImport
parentRoute: typeof rootRoute
}
'/(logistics)/materialHelper/': {
id: '/(logistics)/materialHelper/'
path: '/materialHelper'
@@ -480,6 +495,7 @@ export interface FileRoutesByFullPath {
'/siloAdjustments/$hist': typeof logisticsSiloAdjustmentsHistRoute
'/article/$av': typeof EomArticleAvRoute
'/dm': typeof logisticsDmIndexRoute
'/helperCommands': typeof logisticsHelperCommandsIndexRoute
'/materialHelper': typeof logisticsMaterialHelperIndexRoute
'/openOrders': typeof logisticsOpenOrdersIndexRoute
'/siloAdjustments': typeof logisticsSiloAdjustmentsIndexRoute
@@ -509,6 +525,7 @@ export interface FileRoutesByTo {
'/siloAdjustments/$hist': typeof logisticsSiloAdjustmentsHistRoute
'/article/$av': typeof EomArticleAvRoute
'/dm': typeof logisticsDmIndexRoute
'/helperCommands': typeof logisticsHelperCommandsIndexRoute
'/materialHelper': typeof logisticsMaterialHelperIndexRoute
'/openOrders': typeof logisticsOpenOrdersIndexRoute
'/siloAdjustments': typeof logisticsSiloAdjustmentsIndexRoute
@@ -541,6 +558,7 @@ export interface FileRoutesById {
'/(logistics)/siloAdjustments/$hist': typeof logisticsSiloAdjustmentsHistRoute
'/_eom/article/$av': typeof EomArticleAvRoute
'/(logistics)/dm/': typeof logisticsDmIndexRoute
'/(logistics)/helperCommands/': typeof logisticsHelperCommandsIndexRoute
'/(logistics)/materialHelper/': typeof logisticsMaterialHelperIndexRoute
'/(logistics)/openOrders/': typeof logisticsOpenOrdersIndexRoute
'/(logistics)/siloAdjustments/': typeof logisticsSiloAdjustmentsIndexRoute
@@ -572,6 +590,7 @@ export interface FileRouteTypes {
| '/siloAdjustments/$hist'
| '/article/$av'
| '/dm'
| '/helperCommands'
| '/materialHelper'
| '/openOrders'
| '/siloAdjustments'
@@ -600,6 +619,7 @@ export interface FileRouteTypes {
| '/siloAdjustments/$hist'
| '/article/$av'
| '/dm'
| '/helperCommands'
| '/materialHelper'
| '/openOrders'
| '/siloAdjustments'
@@ -630,6 +650,7 @@ export interface FileRouteTypes {
| '/(logistics)/siloAdjustments/$hist'
| '/_eom/article/$av'
| '/(logistics)/dm/'
| '/(logistics)/helperCommands/'
| '/(logistics)/materialHelper/'
| '/(logistics)/openOrders/'
| '/(logistics)/siloAdjustments/'
@@ -653,6 +674,7 @@ export interface RootRouteChildren {
OcpIndexRoute: typeof OcpIndexRoute
logisticsSiloAdjustmentsHistRoute: typeof logisticsSiloAdjustmentsHistRoute
logisticsDmIndexRoute: typeof logisticsDmIndexRoute
logisticsHelperCommandsIndexRoute: typeof logisticsHelperCommandsIndexRoute
logisticsMaterialHelperIndexRoute: typeof logisticsMaterialHelperIndexRoute
logisticsOpenOrdersIndexRoute: typeof logisticsOpenOrdersIndexRoute
logisticsSiloAdjustmentsIndexRoute: typeof logisticsSiloAdjustmentsIndexRoute
@@ -675,6 +697,7 @@ const rootRouteChildren: RootRouteChildren = {
OcpIndexRoute: OcpIndexRoute,
logisticsSiloAdjustmentsHistRoute: logisticsSiloAdjustmentsHistRoute,
logisticsDmIndexRoute: logisticsDmIndexRoute,
logisticsHelperCommandsIndexRoute: logisticsHelperCommandsIndexRoute,
logisticsMaterialHelperIndexRoute: logisticsMaterialHelperIndexRoute,
logisticsOpenOrdersIndexRoute: logisticsOpenOrdersIndexRoute,
logisticsSiloAdjustmentsIndexRoute: logisticsSiloAdjustmentsIndexRoute,
@@ -709,6 +732,7 @@ export const routeTree = rootRoute
"/ocp/",
"/(logistics)/siloAdjustments/$hist",
"/(logistics)/dm/",
"/(logistics)/helperCommands/",
"/(logistics)/materialHelper/",
"/(logistics)/openOrders/",
"/(logistics)/siloAdjustments/",
@@ -805,6 +829,9 @@ export const routeTree = rootRoute
"/(logistics)/dm/": {
"filePath": "(logistics)/dm/index.tsx"
},
"/(logistics)/helperCommands/": {
"filePath": "(logistics)/helperCommands/index.tsx"
},
"/(logistics)/materialHelper/": {
"filePath": "(logistics)/materialHelper/index.tsx"
},