diff --git a/app/src/internal/admin/controller/systemAdminRole.ts b/app/src/internal/admin/controller/systemAdminRole.ts index e58867a..51c1b9f 100644 --- a/app/src/internal/admin/controller/systemAdminRole.ts +++ b/app/src/internal/admin/controller/systemAdminRole.ts @@ -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"); }; diff --git a/app/src/internal/admin/routes/grantRole.ts b/app/src/internal/admin/routes/grantRole.ts index 797082c..67e6d21 100644 --- a/app/src/internal/admin/routes/grantRole.ts +++ b/app/src/internal/admin/routes/grantRole.ts @@ -14,6 +14,7 @@ const roleSchema = z.object({ "siloAdjustments", "demandManagement", "logistics", + "helperCommands", "production", "quality", "eom", diff --git a/frontend/src/routeTree.gen.ts b/frontend/src/routeTree.gen.ts index 0bec7d4..d1b588b 100644 --- a/frontend/src/routeTree.gen.ts +++ b/frontend/src/routeTree.gen.ts @@ -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: diff --git a/frontend/src/routes/_app/_adminLayout/-components/ExpandedRow.tsx b/frontend/src/routes/_app/_adminLayout/-components/ExpandedRow.tsx index 0d4ec5e..9e4bbaf 100644 --- a/frontend/src/routes/_app/_adminLayout/-components/ExpandedRow.tsx +++ b/frontend/src/routes/_app/_adminLayout/-components/ExpandedRow.tsx @@ -17,6 +17,7 @@ const modules: string[] = [ "siloAdjustments", "demandManagement", "logistics", + "helperCommands", "production", "quality", "eom", diff --git a/frontend/src/routes/_old/old/(logistics)/helperCommands/index.tsx b/frontend/src/routes/_old/old/(logistics)/helperCommands/index.tsx new file mode 100644 index 0000000..a22bc4c --- /dev/null +++ b/frontend/src/routes/_old/old/(logistics)/helperCommands/index.tsx @@ -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 ( +
+ +
+ ); +} diff --git a/frontend/src/routes/_old/old/-components/logistics/helperCommands/commands/Bookin.tsx b/frontend/src/routes/_old/old/-components/logistics/helperCommands/commands/Bookin.tsx new file mode 100644 index 0000000..3760ee0 --- /dev/null +++ b/frontend/src/routes/_old/old/-components/logistics/helperCommands/commands/Bookin.tsx @@ -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 ( + + +

Book in a pallet by running number

+
+
{ + 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} +
+ ); + }} + /> +
+ +
+
+
+
+ ); +} diff --git a/frontend/src/routes/_old/old/-components/logistics/helperCommands/commands/Relocate.tsx b/frontend/src/routes/_old/old/-components/logistics/helperCommands/commands/Relocate.tsx new file mode 100644 index 0000000..f7736d3 --- /dev/null +++ b/frontend/src/routes/_old/old/-components/logistics/helperCommands/commands/Relocate.tsx @@ -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 ( + + +

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/routes/_old/old/-components/logistics/helperCommands/commands/RemoveAsNonReusable.tsx b/frontend/src/routes/_old/old/-components/logistics/helperCommands/commands/RemoveAsNonReusable.tsx new file mode 100644 index 0000000..fa5f36f --- /dev/null +++ b/frontend/src/routes/_old/old/-components/logistics/helperCommands/commands/RemoveAsNonReusable.tsx @@ -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 ( + + +

Remove a pallet as non reusable

+
+
{ + 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 > 10 + ? undefined + : "Please enter a valid reason on why you needed to remove this pallet", + }} + children={(field) => { + return ( +
+ +