feat(migration): moved helper commands
This commit is contained in:
@@ -4,72 +4,77 @@ import { createLogger } from "../../../pkg/logger/logger.js";
|
||||
import { tryCatch } from "../../../pkg/utils/tryCatch.js";
|
||||
|
||||
export const systemAdminRole = async (userId: string) => {
|
||||
const log = createLogger({
|
||||
module: "admin",
|
||||
subModule: "systemAdminSetup",
|
||||
});
|
||||
const systemAdminRoles = [
|
||||
{
|
||||
userId: userId,
|
||||
module: "users",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "admin",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "ocp",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "siloAdjustments",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "demandManagement",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "logistics",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "production",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "quality",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "eom",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "forklifts",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
];
|
||||
const { data, error } = await tryCatch(
|
||||
db.insert(userRoles).values(systemAdminRoles).onConflictDoNothing()
|
||||
);
|
||||
const log = createLogger({
|
||||
module: "admin",
|
||||
subModule: "systemAdminSetup",
|
||||
});
|
||||
const systemAdminRoles = [
|
||||
{
|
||||
userId: userId,
|
||||
module: "users",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "admin",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "ocp",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "siloAdjustments",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "demandManagement",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "logistics",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "production",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "quality",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "eom",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "forklifts",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
module: "helperCommands",
|
||||
role: "systemAdmin",
|
||||
},
|
||||
];
|
||||
const { data, error } = await tryCatch(
|
||||
db.insert(userRoles).values(systemAdminRoles).onConflictDoNothing(),
|
||||
);
|
||||
|
||||
if (error) {
|
||||
log.error(
|
||||
{ stack: { error: error } },
|
||||
"There was an error creating the system admin roles"
|
||||
);
|
||||
}
|
||||
if (error) {
|
||||
log.error(
|
||||
{ stack: { error: error } },
|
||||
"There was an error creating the system admin roles",
|
||||
);
|
||||
}
|
||||
|
||||
log.info({ data }, "New system admin roles created");
|
||||
log.info({ data }, "New system admin roles created");
|
||||
};
|
||||
|
||||
@@ -14,6 +14,7 @@ const roleSchema = z.object({
|
||||
"siloAdjustments",
|
||||
"demandManagement",
|
||||
"logistics",
|
||||
"helperCommands",
|
||||
"production",
|
||||
"quality",
|
||||
"eom",
|
||||
|
||||
@@ -36,6 +36,7 @@ import { Route as AppAdminLayoutAdminUsersRouteRouteImport } from './routes/_app
|
||||
import { Route as OldOldocmeCyclecountIndexRouteImport } from './routes/_old/old/(ocme)/cyclecount/index'
|
||||
import { Route as OldOldlogisticsSiloAdjustmentsIndexRouteImport } from './routes/_old/old/(logistics)/siloAdjustments/index'
|
||||
import { Route as OldOldlogisticsMaterialHelperIndexRouteImport } from './routes/_old/old/(logistics)/materialHelper/index'
|
||||
import { Route as OldOldlogisticsHelperCommandsIndexRouteImport } from './routes/_old/old/(logistics)/helperCommands/index'
|
||||
import { Route as OldOldlogisticsSiloAdjustmentsHistRouteImport } from './routes/_old/old/(logistics)/siloAdjustments/$hist'
|
||||
import { Route as AppAdminLayoutAdminUsersUsersRouteImport } from './routes/_app/_adminLayout/admin/_users/users'
|
||||
import { Route as AppAdminLayoutAdminUsersProdUsersRouteImport } from './routes/_app/_adminLayout/admin/_users/prodUsers'
|
||||
@@ -184,6 +185,12 @@ const OldOldlogisticsMaterialHelperIndexRoute =
|
||||
path: '/materialHelper/',
|
||||
getParentRoute: () => OldOldRouteRoute,
|
||||
} as any)
|
||||
const OldOldlogisticsHelperCommandsIndexRoute =
|
||||
OldOldlogisticsHelperCommandsIndexRouteImport.update({
|
||||
id: '/(logistics)/helperCommands/',
|
||||
path: '/helperCommands/',
|
||||
getParentRoute: () => OldOldRouteRoute,
|
||||
} as any)
|
||||
const OldOldlogisticsSiloAdjustmentsHistRoute =
|
||||
OldOldlogisticsSiloAdjustmentsHistRouteImport.update({
|
||||
id: '/(logistics)/siloAdjustments/$hist',
|
||||
@@ -238,6 +245,7 @@ export interface FileRoutesByFullPath {
|
||||
'/admin/prodUsers': typeof AppAdminLayoutAdminUsersProdUsersRoute
|
||||
'/admin/users': typeof AppAdminLayoutAdminUsersUsersRoute
|
||||
'/old/siloAdjustments/$hist': typeof OldOldlogisticsSiloAdjustmentsHistRoute
|
||||
'/old/helperCommands': typeof OldOldlogisticsHelperCommandsIndexRoute
|
||||
'/old/materialHelper': typeof OldOldlogisticsMaterialHelperIndexRoute
|
||||
'/old/siloAdjustments': typeof OldOldlogisticsSiloAdjustmentsIndexRoute
|
||||
'/old/cyclecount': typeof OldOldocmeCyclecountIndexRoute
|
||||
@@ -266,6 +274,7 @@ export interface FileRoutesByTo {
|
||||
'/admin/prodUsers': typeof AppAdminLayoutAdminUsersProdUsersRoute
|
||||
'/admin/users': typeof AppAdminLayoutAdminUsersUsersRoute
|
||||
'/old/siloAdjustments/$hist': typeof OldOldlogisticsSiloAdjustmentsHistRoute
|
||||
'/old/helperCommands': typeof OldOldlogisticsHelperCommandsIndexRoute
|
||||
'/old/materialHelper': typeof OldOldlogisticsMaterialHelperIndexRoute
|
||||
'/old/siloAdjustments': typeof OldOldlogisticsSiloAdjustmentsIndexRoute
|
||||
'/old/cyclecount': typeof OldOldocmeCyclecountIndexRoute
|
||||
@@ -300,6 +309,7 @@ export interface FileRoutesById {
|
||||
'/_app/_adminLayout/admin/_users/prodUsers': typeof AppAdminLayoutAdminUsersProdUsersRoute
|
||||
'/_app/_adminLayout/admin/_users/users': typeof AppAdminLayoutAdminUsersUsersRoute
|
||||
'/_old/old/(logistics)/siloAdjustments/$hist': typeof OldOldlogisticsSiloAdjustmentsHistRoute
|
||||
'/_old/old/(logistics)/helperCommands/': typeof OldOldlogisticsHelperCommandsIndexRoute
|
||||
'/_old/old/(logistics)/materialHelper/': typeof OldOldlogisticsMaterialHelperIndexRoute
|
||||
'/_old/old/(logistics)/siloAdjustments/': typeof OldOldlogisticsSiloAdjustmentsIndexRoute
|
||||
'/_old/old/(ocme)/cyclecount/': typeof OldOldocmeCyclecountIndexRoute
|
||||
@@ -331,6 +341,7 @@ export interface FileRouteTypes {
|
||||
| '/admin/prodUsers'
|
||||
| '/admin/users'
|
||||
| '/old/siloAdjustments/$hist'
|
||||
| '/old/helperCommands'
|
||||
| '/old/materialHelper'
|
||||
| '/old/siloAdjustments'
|
||||
| '/old/cyclecount'
|
||||
@@ -359,6 +370,7 @@ export interface FileRouteTypes {
|
||||
| '/admin/prodUsers'
|
||||
| '/admin/users'
|
||||
| '/old/siloAdjustments/$hist'
|
||||
| '/old/helperCommands'
|
||||
| '/old/materialHelper'
|
||||
| '/old/siloAdjustments'
|
||||
| '/old/cyclecount'
|
||||
@@ -392,6 +404,7 @@ export interface FileRouteTypes {
|
||||
| '/_app/_adminLayout/admin/_users/prodUsers'
|
||||
| '/_app/_adminLayout/admin/_users/users'
|
||||
| '/_old/old/(logistics)/siloAdjustments/$hist'
|
||||
| '/_old/old/(logistics)/helperCommands/'
|
||||
| '/_old/old/(logistics)/materialHelper/'
|
||||
| '/_old/old/(logistics)/siloAdjustments/'
|
||||
| '/_old/old/(ocme)/cyclecount/'
|
||||
@@ -589,6 +602,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof OldOldlogisticsMaterialHelperIndexRouteImport
|
||||
parentRoute: typeof OldOldRouteRoute
|
||||
}
|
||||
'/_old/old/(logistics)/helperCommands/': {
|
||||
id: '/_old/old/(logistics)/helperCommands/'
|
||||
path: '/helperCommands'
|
||||
fullPath: '/old/helperCommands'
|
||||
preLoaderRoute: typeof OldOldlogisticsHelperCommandsIndexRouteImport
|
||||
parentRoute: typeof OldOldRouteRoute
|
||||
}
|
||||
'/_old/old/(logistics)/siloAdjustments/$hist': {
|
||||
id: '/_old/old/(logistics)/siloAdjustments/$hist'
|
||||
path: '/siloAdjustments/$hist'
|
||||
@@ -725,6 +745,7 @@ interface OldOldRouteRouteChildren {
|
||||
OldOldOcpIndexRoute: typeof OldOldOcpIndexRoute
|
||||
OldOldRfidIndexRoute: typeof OldOldRfidIndexRoute
|
||||
OldOldlogisticsSiloAdjustmentsHistRoute: typeof OldOldlogisticsSiloAdjustmentsHistRoute
|
||||
OldOldlogisticsHelperCommandsIndexRoute: typeof OldOldlogisticsHelperCommandsIndexRoute
|
||||
OldOldlogisticsMaterialHelperIndexRoute: typeof OldOldlogisticsMaterialHelperIndexRoute
|
||||
OldOldlogisticsSiloAdjustmentsIndexRoute: typeof OldOldlogisticsSiloAdjustmentsIndexRoute
|
||||
OldOldocmeCyclecountIndexRoute: typeof OldOldocmeCyclecountIndexRoute
|
||||
@@ -738,6 +759,8 @@ const OldOldRouteRouteChildren: OldOldRouteRouteChildren = {
|
||||
OldOldRfidIndexRoute: OldOldRfidIndexRoute,
|
||||
OldOldlogisticsSiloAdjustmentsHistRoute:
|
||||
OldOldlogisticsSiloAdjustmentsHistRoute,
|
||||
OldOldlogisticsHelperCommandsIndexRoute:
|
||||
OldOldlogisticsHelperCommandsIndexRoute,
|
||||
OldOldlogisticsMaterialHelperIndexRoute:
|
||||
OldOldlogisticsMaterialHelperIndexRoute,
|
||||
OldOldlogisticsSiloAdjustmentsIndexRoute:
|
||||
|
||||
@@ -17,6 +17,7 @@ const modules: string[] = [
|
||||
"siloAdjustments",
|
||||
"demandManagement",
|
||||
"logistics",
|
||||
"helperCommands",
|
||||
"production",
|
||||
"quality",
|
||||
"eom",
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import HelperPage from "../../-components/logistics/helperCommands/helperPage";
|
||||
|
||||
export const Route = createFileRoute("/_old/old/(logistics)/helperCommands/")({
|
||||
component: RouteComponent,
|
||||
// beforeLoad: async () => {
|
||||
// const auth = localStorage.getItem("auth_token");
|
||||
// if (!auth) {
|
||||
// throw redirect({
|
||||
// to: "/login",
|
||||
// search: {
|
||||
// // Use the current location to power a redirect after login
|
||||
// // (Do not use `router.state.resolvedLocation` as it can
|
||||
// // potentially lag behind the actual current location)
|
||||
// redirect: location.pathname + location.search,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
return (
|
||||
<div>
|
||||
<HelperPage />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import { useForm } from "@tanstack/react-form";
|
||||
import axios from "axios";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
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 { LstCard } from "../../../extendedUi/LstCard";
|
||||
|
||||
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("/lst/old/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="">
|
||||
<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>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<div className="flex mt-2 justify-end">
|
||||
<Button onClick={form.handleSubmit} disabled={bookingIn}>
|
||||
Book in
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</form>
|
||||
</LstCard>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
import { useForm } from "@tanstack/react-form";
|
||||
import axios from "axios";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
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 { LstCard } from "../../../extendedUi/LstCard";
|
||||
|
||||
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("/lst/old/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>Relocate a pallet to another lane</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="">
|
||||
<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>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<form.Field
|
||||
name="lane"
|
||||
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="">
|
||||
<Label htmlFor="runningNr" className="mb-2">
|
||||
Enter lane
|
||||
</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>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<div className="flex mt-2 justify-end">
|
||||
<Button onClick={form.handleSubmit} disabled={bookingIn}>
|
||||
Relocate
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</form>
|
||||
</LstCard>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
import { useForm } from "@tanstack/react-form";
|
||||
import axios from "axios";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
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 { Textarea } from "@/components/ui/textarea";
|
||||
import { LstCard } from "../../../extendedUi/LstCard";
|
||||
|
||||
export default function RemoveAsNonReusable() {
|
||||
const [stockOut, setStockOut] = useState(false);
|
||||
const form = useForm({
|
||||
defaultValues: { runningNr: " ", reason: " " },
|
||||
onSubmit: async ({ value }) => {
|
||||
// Do something with form data
|
||||
setStockOut(true);
|
||||
|
||||
//console.log(value);
|
||||
|
||||
try {
|
||||
const res = await axios.post(
|
||||
"/lst/old/api/logistics/removeasreusable",
|
||||
|
||||
value, // this is basically the data field
|
||||
);
|
||||
|
||||
if (res.data.success) {
|
||||
toast.success(res.data.message);
|
||||
form.reset();
|
||||
setStockOut(false);
|
||||
} else {
|
||||
console.log(res.data);
|
||||
toast.error(res.data?.message);
|
||||
form.reset();
|
||||
setStockOut(false);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log(error);
|
||||
toast.error(error.message);
|
||||
setStockOut(false);
|
||||
}
|
||||
},
|
||||
});
|
||||
return (
|
||||
<LstCard>
|
||||
<CardHeader>
|
||||
<p>Remove a pallet as non reusable</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="w-96">
|
||||
<Label htmlFor="runningNr" className="mb-2">
|
||||
Runnning Number
|
||||
</Label>
|
||||
<Input
|
||||
name={field.name}
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
required
|
||||
type="number"
|
||||
onChange={(e) => field.handleChange(e.target.value)}
|
||||
/>
|
||||
{field.state.meta.errors.length ? (
|
||||
<em>{field.state.meta.errors.join(",")}</em>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<form.Field
|
||||
name="reason"
|
||||
validators={{
|
||||
// We can choose between form-wide and field-specific validators
|
||||
onChange: ({ value }) =>
|
||||
value.length > 10
|
||||
? undefined
|
||||
: "Please enter a valid reason on why you needed to remove this pallet",
|
||||
}}
|
||||
children={(field) => {
|
||||
return (
|
||||
<div className="">
|
||||
<Label htmlFor="reason" className="mb-2">
|
||||
Reason for removing
|
||||
</Label>
|
||||
<Textarea
|
||||
name={field.name}
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
//type="number"
|
||||
onChange={(e) => field.handleChange(e.target.value)}
|
||||
/>
|
||||
{field.state.meta.errors.length ? (
|
||||
<div className="text-pretty max-w-96">
|
||||
<em>{field.state.meta.errors.join(",")}</em>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<div className="flex mt-2 justify-end">
|
||||
<Button onClick={form.handleSubmit} disabled={stockOut}>
|
||||
Remove
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</form>
|
||||
</LstCard>
|
||||
);
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
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 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="">
|
||||
<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>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<div className="flex mt-2 justify-end">
|
||||
<Button
|
||||
onClick={form.handleSubmit}
|
||||
disabled={bookingIn}
|
||||
>
|
||||
Book in
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</form>
|
||||
</LstCard>
|
||||
);
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
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 (
|
||||
<LstCard>
|
||||
<CardHeader>
|
||||
<p>Relocate a pallet to another lane</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="">
|
||||
<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>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<form.Field
|
||||
name="lane"
|
||||
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="">
|
||||
<Label htmlFor="runningNr" className="mb-2">
|
||||
Enter lane
|
||||
</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>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<div className="flex mt-2 justify-end">
|
||||
<Button
|
||||
onClick={form.handleSubmit}
|
||||
disabled={bookingIn}
|
||||
>
|
||||
Relocate
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</form>
|
||||
</LstCard>
|
||||
);
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
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 { Textarea } from "@/components/ui/textarea";
|
||||
import { useForm } from "@tanstack/react-form";
|
||||
import axios from "axios";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export default function RemoveAsNonReusable() {
|
||||
const [stockOut, setStockOut] = useState(false);
|
||||
const form = useForm({
|
||||
defaultValues: { runningNr: " ", reason: " " },
|
||||
onSubmit: async ({ value }) => {
|
||||
// Do something with form data
|
||||
setStockOut(true);
|
||||
|
||||
//console.log(value);
|
||||
|
||||
try {
|
||||
const res = await axios.post(
|
||||
"/api/logistics/removeasreusable",
|
||||
|
||||
value // this is basically the data field
|
||||
);
|
||||
|
||||
if (res.data.success) {
|
||||
toast.success(res.data.message);
|
||||
form.reset();
|
||||
setStockOut(false);
|
||||
} else {
|
||||
console.log(res.data);
|
||||
toast.error(res.data?.message);
|
||||
form.reset();
|
||||
setStockOut(false);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log(error);
|
||||
toast.error(error.message);
|
||||
setStockOut(false);
|
||||
}
|
||||
},
|
||||
});
|
||||
return (
|
||||
<LstCard>
|
||||
<CardHeader>
|
||||
<p>Remove a pallet as non reusable</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="w-96">
|
||||
<Label htmlFor="runningNr" className="mb-2">
|
||||
Runnning Number
|
||||
</Label>
|
||||
<Input
|
||||
name={field.name}
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
required
|
||||
type="number"
|
||||
onChange={(e) =>
|
||||
field.handleChange(e.target.value)
|
||||
}
|
||||
/>
|
||||
{field.state.meta.errors.length ? (
|
||||
<em>
|
||||
{field.state.meta.errors.join(",")}
|
||||
</em>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<form.Field
|
||||
name="reason"
|
||||
validators={{
|
||||
// We can choose between form-wide and field-specific validators
|
||||
onChange: ({ value }) =>
|
||||
value.length > 10
|
||||
? undefined
|
||||
: "Please enter a valid reason on why you needed to remove this pallet",
|
||||
}}
|
||||
children={(field) => {
|
||||
return (
|
||||
<div className="">
|
||||
<Label htmlFor="reason" className="mb-2">
|
||||
Reason for removing
|
||||
</Label>
|
||||
<Textarea
|
||||
name={field.name}
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
//type="number"
|
||||
onChange={(e) =>
|
||||
field.handleChange(e.target.value)
|
||||
}
|
||||
/>
|
||||
{field.state.meta.errors.length ? (
|
||||
<div className="text-pretty max-w-96">
|
||||
<em>
|
||||
{field.state.meta.errors.join(
|
||||
","
|
||||
)}
|
||||
</em>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<div className="flex mt-2 justify-end">
|
||||
<Button onClick={form.handleSubmit} disabled={stockOut}>
|
||||
Remove
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</form>
|
||||
</LstCard>
|
||||
);
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
import { LstCard } from "@/components/extendedUI/LstCard";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CardHeader } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import axios from "axios";
|
||||
import { useState } from "react";
|
||||
|
||||
import { useForm } from "react-hook-form";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export default function ConsumeMaterial() {
|
||||
const {
|
||||
register: register1,
|
||||
handleSubmit: handleSubmit1,
|
||||
reset,
|
||||
} = useForm();
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
const handleConsume = async (data: any) => {
|
||||
setSubmitting(true);
|
||||
try {
|
||||
// const result = await axios.post(`/api/logistics/consume`, data, {
|
||||
// headers: {Authorization: `Bearer ${token}`},
|
||||
// });
|
||||
const result = await axios.post(`/api/logistics/consume`, data);
|
||||
if (result.data.success) {
|
||||
toast.success(result.data.message);
|
||||
setSubmitting(false);
|
||||
reset();
|
||||
}
|
||||
if (!result.data.success) {
|
||||
//console.log(result.data);
|
||||
setSubmitting(false);
|
||||
|
||||
toast.error(result.data.message);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log(error);
|
||||
setSubmitting(false);
|
||||
if (error.status === 401) {
|
||||
toast.error("Unauthorized to do this task.");
|
||||
} else {
|
||||
toast.error(
|
||||
"Unexpected error if this continues please constact an admin."
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className="m-2">
|
||||
<LstCard>
|
||||
<CardHeader>
|
||||
<p className="text-center text-lg">Consuming Material.</p>
|
||||
</CardHeader>
|
||||
<div className="flex m-1">
|
||||
<div className="w-96 m-1">
|
||||
<LstCard>
|
||||
<form onSubmit={handleSubmit1(handleConsume)}>
|
||||
<div className="m-2">
|
||||
<Label htmlFor="runningNr">
|
||||
Enter unit running number
|
||||
</Label>
|
||||
<Input
|
||||
className="mt-2"
|
||||
//defaultValue="634"
|
||||
type="number"
|
||||
{...register1("runningNr")}
|
||||
/>
|
||||
</div>
|
||||
<div className="m-2">
|
||||
<Label htmlFor="lotNum">
|
||||
Enter lot number
|
||||
</Label>
|
||||
<Input
|
||||
className="mt-2"
|
||||
//defaultValue="634"
|
||||
type="number"
|
||||
{...register1("lotNum")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
className="m-2"
|
||||
color="primary"
|
||||
type="submit"
|
||||
disabled={submitting}
|
||||
>
|
||||
Consume materal
|
||||
</Button>
|
||||
</form>
|
||||
</LstCard>
|
||||
</div>
|
||||
<div className="m-1 p-1">
|
||||
<LstCard>
|
||||
<div className="w-96 p-1">
|
||||
<ol>
|
||||
<li>
|
||||
1. Enter the running number of the
|
||||
material you would like to consume
|
||||
</li>
|
||||
<li>
|
||||
2. Enter the lot number you will be
|
||||
consuming to
|
||||
</li>
|
||||
<li>3. Press consume material</li>
|
||||
</ol>
|
||||
<p className="text-pretty w-96">
|
||||
*This process is only for barcoded material,
|
||||
if it is set to auto consume you will
|
||||
encounter and error.
|
||||
</p>
|
||||
</div>
|
||||
</LstCard>
|
||||
</div>
|
||||
</div>
|
||||
</LstCard>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
import { LstCard } from "@/components/extendedUI/LstCard";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CardHeader } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { useSessionStore } from "@/lib/store/sessionStore";
|
||||
import axios from "axios";
|
||||
import { useState } from "react";
|
||||
|
||||
import { useForm } from "react-hook-form";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export default function PreformReturn() {
|
||||
const {
|
||||
register: register1,
|
||||
handleSubmit: handleSubmit1,
|
||||
reset,
|
||||
} = useForm();
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const { token } = useSessionStore();
|
||||
|
||||
const handleConsume = async (data: any) => {
|
||||
setSubmitting(true);
|
||||
try {
|
||||
const result = await axios.post(`/api/logistics/consume`, data, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
if (result.data.success) {
|
||||
toast.success(result.data.message);
|
||||
setSubmitting(false);
|
||||
reset();
|
||||
}
|
||||
if (!result.data.success) {
|
||||
//console.log(result.data);
|
||||
setSubmitting(false);
|
||||
|
||||
toast.error(result.data.message);
|
||||
}
|
||||
} catch (error: any) {
|
||||
//console.log(error);
|
||||
setSubmitting(false);
|
||||
if (error.status === 401) {
|
||||
toast.error("Unauthorized to do this task.");
|
||||
} else {
|
||||
toast.error(
|
||||
"Unexpected error if this continues please constact an admin."
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className="m-2">
|
||||
<LstCard>
|
||||
<CardHeader>
|
||||
<p className="text-center text-lg">Preform Return.</p>
|
||||
</CardHeader>
|
||||
<div className="flex m-1">
|
||||
<div className="w-96 m-1">
|
||||
<LstCard>
|
||||
<form onSubmit={handleSubmit1(handleConsume)}>
|
||||
<div className="m-2">
|
||||
<Label htmlFor="runningNr">
|
||||
Enter unit running number
|
||||
</Label>
|
||||
<Input
|
||||
className="mt-2"
|
||||
//defaultValue="634"
|
||||
type="number"
|
||||
{...register1("runningNr")}
|
||||
/>
|
||||
</div>
|
||||
<div className="m-2">
|
||||
<Label htmlFor="lotNum">
|
||||
Enter the new wight of the gaylord of
|
||||
preforms
|
||||
</Label>
|
||||
<Input
|
||||
className="mt-2"
|
||||
//defaultValue="634"
|
||||
type="number"
|
||||
{...register1("lotNum")}
|
||||
/>
|
||||
</div>
|
||||
<div className="m-2">
|
||||
<Label htmlFor="lotNum">
|
||||
Select the printer you would like to
|
||||
print to
|
||||
</Label>
|
||||
<Input
|
||||
className="mt-2"
|
||||
//defaultValue="634"
|
||||
type="number"
|
||||
{...register1("lotNum")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="m-2">
|
||||
<Label htmlFor="lotNum">
|
||||
Select the staging location to be
|
||||
returned to.
|
||||
</Label>
|
||||
<Input
|
||||
className="mt-2"
|
||||
//defaultValue="634"
|
||||
type="number"
|
||||
{...register1("lotNum")}
|
||||
/>
|
||||
</div>
|
||||
<div className="m-2">
|
||||
<Label htmlFor="lotNum">
|
||||
Select type of material coming back.
|
||||
</Label>
|
||||
<Input
|
||||
className="mt-2"
|
||||
//defaultValue="634"
|
||||
type="number"
|
||||
{...register1("lotNum")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
className="m-2"
|
||||
color="primary"
|
||||
type="submit"
|
||||
disabled={submitting}
|
||||
>
|
||||
Preform return
|
||||
</Button>
|
||||
</form>
|
||||
</LstCard>
|
||||
</div>
|
||||
<div className="m-1 p-1">
|
||||
<LstCard>
|
||||
<div className="w-96 p-1">
|
||||
<ol>
|
||||
<li>
|
||||
1. Enter the running number of the
|
||||
preform cage you would like to return
|
||||
</li>
|
||||
<li>
|
||||
2. Enter the new weight of the gaylord
|
||||
</li>
|
||||
<li>
|
||||
3. Select the printer you would like to
|
||||
print to
|
||||
</li>
|
||||
</ol>
|
||||
<p className="text-pretty w-96">
|
||||
*As soon as you press preform return it will
|
||||
print a new label and return to the staging
|
||||
location.
|
||||
</p>
|
||||
</div>
|
||||
</LstCard>
|
||||
</div>
|
||||
</div>
|
||||
</LstCard>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,478 +0,0 @@
|
||||
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 { Switch } from "@/components/ui/switch";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { useAppForm } from "@/utils/formStuff";
|
||||
import axios from "axios";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { Info } from "lucide-react";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { useSettingStore } from "@/lib/store/useSettings";
|
||||
|
||||
export default function TransferToNextLot() {
|
||||
const [gaylordFilled, setGaylordFilled] = useState([0]);
|
||||
const [actualAmount, setActualAmount] = useState(0);
|
||||
const [tab, setTab] = useState("esitmate");
|
||||
const [typeSwitch, setTypeSwitch] = useState(false);
|
||||
const { settings } = useSettingStore();
|
||||
|
||||
const server = settings.filter((n: any) => n.name === "plantToken");
|
||||
const form = useAppForm({
|
||||
defaultValues: {
|
||||
runningNumber: "",
|
||||
lotNumber: "",
|
||||
originalAmount: "",
|
||||
amount: "",
|
||||
},
|
||||
onSubmit: async ({ value }) => {
|
||||
//console.log(transferData);
|
||||
//toast.success("603468: qty: 361, was transfered to lot:24897");
|
||||
try {
|
||||
const res = await axios.post("/api/ocp/materiallottransfer", {
|
||||
runningNumber: Number(value.runningNumber),
|
||||
lotNumber: Number(value.lotNumber),
|
||||
originalAmount: Number(value.originalAmount),
|
||||
level: Number(
|
||||
gaylordFilled.length === 1
|
||||
? 0.25
|
||||
: gaylordFilled.length === 2
|
||||
? 0.5
|
||||
: gaylordFilled.length === 3
|
||||
? 0.75
|
||||
: gaylordFilled.length === 4 && 0.95
|
||||
),
|
||||
amount: actualAmount,
|
||||
type: typeSwitch ? "eom" : "lot",
|
||||
});
|
||||
|
||||
if (res.data.success) {
|
||||
toast.success(`${res.data.message}`);
|
||||
form.reset();
|
||||
setGaylordFilled([0]);
|
||||
setActualAmount(0);
|
||||
}
|
||||
//console.log(res.data);
|
||||
|
||||
if (!res.data.success) {
|
||||
toast.error(res.data.message);
|
||||
}
|
||||
} catch (error) {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
//toast.error(error)
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
return (
|
||||
<div>
|
||||
<LstCard>
|
||||
<CardHeader>
|
||||
<p className="text-center text-lg">
|
||||
Material Transfer to Next lot
|
||||
</p>
|
||||
</CardHeader>
|
||||
<div>
|
||||
<div className="flex flex-wrap m-2 gap-2">
|
||||
<div className="flex gap-2">
|
||||
<div>
|
||||
<LstCard className="">
|
||||
<Tabs
|
||||
defaultValue={tab}
|
||||
onValueChange={setTab}
|
||||
>
|
||||
<TabsList>
|
||||
<TabsTrigger value="esitmate">
|
||||
Estimate Amount
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="actual">
|
||||
Actual Amount
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="esitmate">
|
||||
<div className="grid columns-1">
|
||||
<button
|
||||
className={`box-border h-16 w-96 border-3 ${
|
||||
gaylordFilled.includes(
|
||||
4
|
||||
)
|
||||
? " bg-green-500"
|
||||
: ""
|
||||
}`}
|
||||
onClick={() =>
|
||||
setGaylordFilled([
|
||||
1, 2, 3, 4,
|
||||
])
|
||||
}
|
||||
>
|
||||
<p className="text-center">
|
||||
Almost full - 95%
|
||||
</p>
|
||||
</button>
|
||||
<button
|
||||
className={`box-border h-16 w-96 border-3 ${
|
||||
gaylordFilled.includes(
|
||||
3
|
||||
)
|
||||
? " bg-green-500"
|
||||
: ""
|
||||
}`}
|
||||
onClick={() =>
|
||||
setGaylordFilled([
|
||||
1, 2, 3,
|
||||
])
|
||||
}
|
||||
>
|
||||
<p className="text-center">
|
||||
About full - 75%
|
||||
</p>
|
||||
</button>
|
||||
<button
|
||||
className={`box-border h-16 w-96 border-3 ${
|
||||
gaylordFilled.includes(
|
||||
2
|
||||
)
|
||||
? " bg-green-500"
|
||||
: ""
|
||||
}`}
|
||||
onClick={() =>
|
||||
setGaylordFilled([1, 2])
|
||||
}
|
||||
>
|
||||
<p className="text-center">
|
||||
Half full - 50%
|
||||
</p>
|
||||
</button>
|
||||
<button
|
||||
className={`box-border h-16 w-96 border-3 ${
|
||||
gaylordFilled.includes(
|
||||
1
|
||||
)
|
||||
? " bg-green-500"
|
||||
: ""
|
||||
}`}
|
||||
onClick={() =>
|
||||
setGaylordFilled(() => [
|
||||
1,
|
||||
])
|
||||
}
|
||||
>
|
||||
<p className="text-center">
|
||||
Almost empty - 25%
|
||||
</p>
|
||||
</button>
|
||||
</div>
|
||||
<div className="flex justify-end pr-1">
|
||||
<Button
|
||||
onClick={() =>
|
||||
setGaylordFilled([0])
|
||||
}
|
||||
>
|
||||
Reset Gaylord
|
||||
</Button>
|
||||
</div>
|
||||
</TabsContent>
|
||||
<TabsContent
|
||||
value="actual"
|
||||
className="w-96"
|
||||
>
|
||||
<CardHeader>
|
||||
<p>
|
||||
Enter the total amount of
|
||||
the cage/gaylord
|
||||
</p>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Input
|
||||
type="number"
|
||||
//placeholder="35"
|
||||
onChange={(e) =>
|
||||
setActualAmount(
|
||||
Number(
|
||||
e.target.value
|
||||
)
|
||||
)
|
||||
}
|
||||
/>
|
||||
</CardContent>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</LstCard>
|
||||
</div>
|
||||
<div>
|
||||
<div className="w-96">
|
||||
<LstCard>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.handleSubmit();
|
||||
}}
|
||||
>
|
||||
<div className="mt-3 p-2">
|
||||
<form.AppField
|
||||
name="runningNumber"
|
||||
children={(field) => (
|
||||
<field.InputField
|
||||
label="Running Number"
|
||||
inputType="number"
|
||||
required={true}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-3 p-2">
|
||||
<form.AppField
|
||||
name="lotNumber"
|
||||
children={(field) => (
|
||||
<field.InputField
|
||||
label="Lot Number"
|
||||
inputType="number"
|
||||
required={true}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{tab !== "actual" && (
|
||||
<div className="mt-3 p-2">
|
||||
<form.AppField
|
||||
name="originalAmount"
|
||||
children={(
|
||||
field
|
||||
) => (
|
||||
<field.InputField
|
||||
label="Orignal Quantity"
|
||||
inputType="number"
|
||||
required={
|
||||
true
|
||||
}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-between p-2">
|
||||
<div className="flex items-center space-x-2">
|
||||
<Switch
|
||||
checked={typeSwitch}
|
||||
onCheckedChange={
|
||||
setTypeSwitch
|
||||
}
|
||||
/>
|
||||
<span>
|
||||
{typeSwitch ? (
|
||||
<div className="flex items-center space-x-2">
|
||||
<span>
|
||||
"EOM
|
||||
Transfer"
|
||||
</span>
|
||||
<Tooltip>
|
||||
<TooltipTrigger>
|
||||
<Info className="h-[16px] w-[16px]" />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p>
|
||||
Click
|
||||
the
|
||||
toggle
|
||||
if
|
||||
you
|
||||
will
|
||||
be
|
||||
transfering
|
||||
at
|
||||
EOM,
|
||||
NOTE:
|
||||
This
|
||||
will
|
||||
trigger
|
||||
the
|
||||
delayed
|
||||
transfer.
|
||||
</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center space-x-2">
|
||||
<span>
|
||||
"Lot
|
||||
Transfer"
|
||||
</span>
|
||||
<Tooltip>
|
||||
<TooltipTrigger>
|
||||
<Info className="h-[16px] w-[16px]" />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p>
|
||||
Click
|
||||
the
|
||||
toggle
|
||||
if
|
||||
you
|
||||
will
|
||||
be
|
||||
transferring
|
||||
at
|
||||
EOM,
|
||||
NOTE:
|
||||
This
|
||||
will
|
||||
trigger
|
||||
the
|
||||
delayed
|
||||
transfer.
|
||||
</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<form.AppForm>
|
||||
<form.SubmitButton>
|
||||
Transfer To Lot
|
||||
</form.SubmitButton>
|
||||
</form.AppForm>
|
||||
</div>
|
||||
</form>
|
||||
</LstCard>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<LstCard className="p-2">
|
||||
<CardHeader>
|
||||
<p className="text-center text-lg">
|
||||
Moving material to the next lot.
|
||||
</p>
|
||||
</CardHeader>
|
||||
{tab !== "actual" ? (
|
||||
<div>
|
||||
<ol>
|
||||
<li>
|
||||
1. Grab the gaylord running
|
||||
number from the gaylord at the
|
||||
line/next to the tschritter
|
||||
</li>
|
||||
<li>
|
||||
2. Grab the next lot number you
|
||||
are going to be running (or the
|
||||
one that state no Main material
|
||||
prepared)
|
||||
</li>
|
||||
<li>
|
||||
3. Enter the total gaylord
|
||||
weight (this is how much the
|
||||
gaylord weighed when it came in
|
||||
from the supplier.)
|
||||
</li>
|
||||
<li>
|
||||
4. *Click the level of the
|
||||
gaylord (this is just an
|
||||
estimate to move to the next
|
||||
lot.)
|
||||
</li>
|
||||
<li>
|
||||
5. type in running number on the
|
||||
gaylord.
|
||||
</li>
|
||||
<li>
|
||||
6. Type in the new lot number.
|
||||
</li>
|
||||
<li>7. Press "Transfer To Lot"</li>
|
||||
</ol>
|
||||
<br></br>
|
||||
<p>
|
||||
* to reduce the time needed to get
|
||||
the lot going we will use an
|
||||
estimate of how full the gaylord is.
|
||||
</p>
|
||||
<p>
|
||||
NOTE: This is not the return
|
||||
process, this process will just get
|
||||
the gaylord to the next lot.
|
||||
</p>
|
||||
<br />
|
||||
{settings.length > 0 && (
|
||||
<p>
|
||||
For more in depth instructions
|
||||
please{" "}
|
||||
<a
|
||||
href={`https://${server[0].value}prod.alpla.net/lst/d/docs/ocp/ocp#tranfer-partial-estimated-quantity-to-the-next-lot`}
|
||||
target="_blank"
|
||||
>
|
||||
<em>CLICK HERE</em>
|
||||
</a>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
<ol>
|
||||
<li>
|
||||
1. Grab the gaylord running
|
||||
number from the gaylord at the
|
||||
line/next to the tschritter
|
||||
</li>
|
||||
<li>
|
||||
2. Grab the next lot number you
|
||||
are going to be running (or the
|
||||
one that state no Main material
|
||||
prepared)
|
||||
</li>
|
||||
<li>
|
||||
3. Take the gaylord to the scale
|
||||
and weight it
|
||||
</li>
|
||||
<li>
|
||||
4. Enter the weight of the
|
||||
gaylord minus the tar weight.
|
||||
</li>
|
||||
<li>
|
||||
5. type in running number on the
|
||||
gaylord.
|
||||
</li>
|
||||
<li>
|
||||
6. Type in the new lot number.
|
||||
</li>
|
||||
<li>7. Press "Transfer To Lot"</li>
|
||||
</ol>
|
||||
<br></br>
|
||||
|
||||
<p>
|
||||
NOTE: This is not the return
|
||||
process, this process will just get
|
||||
the gaylord to the next lot.
|
||||
</p>
|
||||
<br />
|
||||
{settings.length > 0 && (
|
||||
<p>
|
||||
For more in depth instructions
|
||||
please{" "}
|
||||
<a
|
||||
href={`https://${server[0].value}.alpla.net/lst/d/docs/ocp/ocp#tranfer-partial-estimated-quantity-to-the-next-lot`}
|
||||
target="_blank"
|
||||
>
|
||||
<em>CLICK HERE</em>
|
||||
</a>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</LstCard>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</LstCard>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export default function MaterialHelperPage() {
|
||||
return <div>materialHelperPage</div>;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import HelperPage from "@/components/logistics/helperCommands/helperPage";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute("/(logistics)/helperCommands/")({
|
||||
component: RouteComponent,
|
||||
// beforeLoad: async () => {
|
||||
// const auth = localStorage.getItem("auth_token");
|
||||
// if (!auth) {
|
||||
// throw redirect({
|
||||
// to: "/login",
|
||||
// search: {
|
||||
// // Use the current location to power a redirect after login
|
||||
// // (Do not use `router.state.resolvedLocation` as it can
|
||||
// // potentially lag behind the actual current location)
|
||||
// redirect: location.pathname + location.search,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
return (
|
||||
<div>
|
||||
<HelperPage />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
import ConsumeMaterial from "@/components/logistics/materialHelper/consumption/ConsumeMaterial";
|
||||
import PreformReturn from "@/components/logistics/materialHelper/consumption/MaterialReturn";
|
||||
import TransferToNextLot from "@/components/logistics/materialHelper/consumption/TransferToNextLot";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute(
|
||||
"/(logistics)/materialHelper/consumption/"
|
||||
)({
|
||||
component: RouteComponent,
|
||||
head: () => ({
|
||||
meta: [
|
||||
{
|
||||
name: "description",
|
||||
content: "My App is a web application",
|
||||
},
|
||||
{
|
||||
title: "LST - Logistics",
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
const url: string = window.location.host.split(":")[0];
|
||||
const auth = localStorage.getItem("auth_token");
|
||||
return (
|
||||
<div className="flex flex-wrap">
|
||||
{auth ? (
|
||||
<>
|
||||
<ConsumeMaterial />
|
||||
{url === "localhost" && <PreformReturn />}
|
||||
<TransferToNextLot />
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<ConsumeMaterial />
|
||||
<TransferToNextLot />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import MaterialHelperPage from "@/components/logistics/materialHelper/materialHelperPage";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute("/(logistics)/materialHelper/")({
|
||||
component: RouteComponent,
|
||||
head: () => ({
|
||||
meta: [
|
||||
{
|
||||
name: "description",
|
||||
content: "My App is a web application",
|
||||
},
|
||||
{
|
||||
title: "LST - Logistics",
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
return (
|
||||
<div>
|
||||
<MaterialHelperPage />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
|
||||
export const Route = createFileRoute('/(logistics)/materialHelper/siloLink/')({
|
||||
component: RouteComponent,
|
||||
})
|
||||
|
||||
function RouteComponent() {
|
||||
return <div>Hello "/(logistics)/materialHelper/siloLink/"!</div>
|
||||
}
|
||||
@@ -118,7 +118,7 @@ const newSubModules = [
|
||||
subSubModule: [],
|
||||
},
|
||||
{
|
||||
name: "Helper Commands",
|
||||
name: "helperCommands",
|
||||
moduleName: "logistics",
|
||||
description: "Commands to assist when a scanner is not avalible",
|
||||
link: "/lst/app/old/helpercommands",
|
||||
|
||||
Reference in New Issue
Block a user