Compare commits
3 Commits
99b2d762d6
...
dd6c2971f8
| Author | SHA1 | Date | |
|---|---|---|---|
| dd6c2971f8 | |||
| a19b03b8bf | |||
| c552b9eb1c |
@@ -1,5 +1,5 @@
|
|||||||
vars {
|
vars {
|
||||||
url: https://usmcd1vms036.alpla.net
|
url: http://localhost:5500
|
||||||
session_cookie:
|
session_cookie:
|
||||||
urlv2: http://localhost:3000
|
urlv2: http://localhost:3000
|
||||||
jwtV2:
|
jwtV2:
|
||||||
|
|||||||
@@ -8,17 +8,7 @@ router.get("/:userId", async (req: Request, res: Response) => {
|
|||||||
const cookieHeader = req.headers.cookie ?? "";
|
const cookieHeader = req.headers.cookie ?? "";
|
||||||
const authorization = req.headers.authorization ?? "";
|
const authorization = req.headers.authorization ?? "";
|
||||||
|
|
||||||
const data = await auth.api.setUserPassword({
|
//session stuff
|
||||||
body: {
|
|
||||||
newPassword: req.body.password, // required
|
|
||||||
userId: userId, // required
|
|
||||||
},
|
|
||||||
// This endpoint requires session cookies.
|
|
||||||
headers: {
|
|
||||||
cookie: cookieHeader,
|
|
||||||
authorization,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return res.status(200).json({ message: "Password was just changed." });
|
return res.status(200).json({ message: "Password was just changed." });
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
{
|
{
|
||||||
"name": "rfidReaders",
|
"name": "rfidReaders",
|
||||||
"category": "production",
|
"category": "production",
|
||||||
"icon": "Tags",
|
"icon": "Tag",
|
||||||
"link": "/lst/app/old/rfid",
|
"link": "/lst/app/old/rfid",
|
||||||
"active": false,
|
"active": false,
|
||||||
"roles": ["viewer", "manager", "tester", "systemAdmin", "admin"]
|
"roles": ["viewer", "manager", "tester", "systemAdmin", "admin"]
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
"name": "production",
|
"name": "production",
|
||||||
"category": "production",
|
"category": "production",
|
||||||
"active": false,
|
"active": false,
|
||||||
"icon": "",
|
"icon": "Tags",
|
||||||
"link": "",
|
"link": "",
|
||||||
"roles": ["admin", "systemAdmin", "manager", "viewer", "tester"]
|
"roles": ["admin", "systemAdmin", "manager", "viewer", "tester"]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { and, asc, eq } from "drizzle-orm";
|
import { asc } from "drizzle-orm";
|
||||||
import type { Request, Response } from "express";
|
import type { Request, Response } from "express";
|
||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { db } from "../../../../pkg/db/db.js";
|
import { db } from "../../../../pkg/db/db.js";
|
||||||
import { modules } from "../../../../pkg/db/schema/modules.js";
|
import { modules } from "../../../../pkg/db/schema/modules.js";
|
||||||
import { serverData } from "../../../../pkg/db/schema/servers.js";
|
|
||||||
import { tryCatch } from "../../../../pkg/utils/tryCatch.js";
|
import { tryCatch } from "../../../../pkg/utils/tryCatch.js";
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
@@ -24,6 +24,7 @@ router.get("/", async (req: Request, res: Response) => {
|
|||||||
.select()
|
.select()
|
||||||
.from(modules)
|
.from(modules)
|
||||||
//.where(and(...conditions))
|
//.where(and(...conditions))
|
||||||
|
//.groupBy(modules.category)
|
||||||
.orderBy(asc(modules.name)),
|
.orderBy(asc(modules.name)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import { createFileRoute } from '@tanstack/react-router'
|
|
||||||
|
|
||||||
export const Route = createFileRoute('/_old')({
|
|
||||||
component: RouteComponent,
|
|
||||||
})
|
|
||||||
|
|
||||||
function RouteComponent() {
|
|
||||||
return <div>Hello "/_old"!</div>
|
|
||||||
}
|
|
||||||
@@ -1,72 +1,79 @@
|
|||||||
import { Server, Settings, User, type LucideIcon } from "lucide-react";
|
|
||||||
import { userAccess, type UserRoles } from "../../lib/authClient";
|
|
||||||
import {
|
|
||||||
SidebarGroup,
|
|
||||||
SidebarGroupContent,
|
|
||||||
SidebarGroupLabel,
|
|
||||||
SidebarMenu,
|
|
||||||
SidebarMenuButton,
|
|
||||||
SidebarMenuItem,
|
|
||||||
} from "../ui/sidebar";
|
|
||||||
import { Link } from "@tanstack/react-router";
|
import { Link } from "@tanstack/react-router";
|
||||||
|
import { type LucideIcon, Server, Settings, User } from "lucide-react";
|
||||||
|
import { type UserRoles, userAccess } from "../../lib/authClient";
|
||||||
|
import {
|
||||||
|
SidebarGroup,
|
||||||
|
SidebarGroupContent,
|
||||||
|
SidebarGroupLabel,
|
||||||
|
SidebarMenu,
|
||||||
|
SidebarMenuButton,
|
||||||
|
SidebarMenuItem,
|
||||||
|
} from "../ui/sidebar";
|
||||||
|
|
||||||
type Items = {
|
type Items = {
|
||||||
title: string;
|
title: string;
|
||||||
url: string;
|
url: string;
|
||||||
icon: LucideIcon;
|
icon: LucideIcon;
|
||||||
role: UserRoles["role"][];
|
role: UserRoles["role"][];
|
||||||
module: string;
|
module: string;
|
||||||
active: boolean;
|
active: boolean;
|
||||||
};
|
};
|
||||||
export default function Admin() {
|
export default function Admin() {
|
||||||
const items: Items[] = [
|
const items: Items[] = [
|
||||||
{
|
{
|
||||||
title: "Users",
|
title: "Users",
|
||||||
url: "/lst/app/admin/users",
|
url: "/lst/app/admin/users",
|
||||||
icon: User,
|
icon: User,
|
||||||
role: ["systemAdmin", "admin"],
|
role: ["systemAdmin", "admin"],
|
||||||
module: "admin",
|
module: "admin",
|
||||||
active: true,
|
active: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Settings",
|
title: "System",
|
||||||
url: "/lst/app/admin/settings",
|
url: "/lst/app/admin/settings",
|
||||||
icon: Settings,
|
icon: Settings,
|
||||||
role: ["systemAdmin", "admin"],
|
role: ["systemAdmin", "admin"],
|
||||||
module: "admin",
|
module: "admin",
|
||||||
active: true,
|
active: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Servers",
|
title: "Modules",
|
||||||
url: "/lst/app/admin/servers",
|
url: "/lst/app/admin/modules",
|
||||||
icon: Server,
|
icon: Settings,
|
||||||
role: ["systemAdmin", "admin"],
|
role: ["systemAdmin", "admin"],
|
||||||
module: "admin",
|
module: "admin",
|
||||||
active: true,
|
active: true,
|
||||||
},
|
},
|
||||||
];
|
{
|
||||||
return (
|
title: "Servers",
|
||||||
<SidebarGroup>
|
url: "/lst/app/admin/servers",
|
||||||
<SidebarGroupLabel>Admin</SidebarGroupLabel>
|
icon: Server,
|
||||||
<SidebarGroupContent>
|
role: ["systemAdmin", "admin"],
|
||||||
<SidebarMenu>
|
module: "admin",
|
||||||
{items.map((item) => (
|
active: true,
|
||||||
<SidebarMenuItem key={item.title}>
|
},
|
||||||
<>
|
];
|
||||||
{userAccess(item.module, item.role) &&
|
return (
|
||||||
item.active && (
|
<SidebarGroup>
|
||||||
<SidebarMenuButton asChild>
|
<SidebarGroupLabel>Admin</SidebarGroupLabel>
|
||||||
<Link to={item.url}>
|
<SidebarGroupContent>
|
||||||
<item.icon />
|
<SidebarMenu>
|
||||||
<span>{item.title}</span>
|
{items.map((item) => (
|
||||||
</Link>
|
<SidebarMenuItem key={item.title}>
|
||||||
</SidebarMenuButton>
|
<>
|
||||||
)}
|
{userAccess(item.module, item.role) && item.active && (
|
||||||
</>
|
<SidebarMenuButton asChild>
|
||||||
</SidebarMenuItem>
|
<Link to={item.url}>
|
||||||
))}
|
<item.icon />
|
||||||
</SidebarMenu>
|
<span>{item.title}</span>
|
||||||
</SidebarGroupContent>
|
</Link>
|
||||||
</SidebarGroup>
|
</SidebarMenuButton>
|
||||||
);
|
)}
|
||||||
|
</>
|
||||||
|
</SidebarMenuItem>
|
||||||
|
))}
|
||||||
|
</SidebarMenu>
|
||||||
|
</SidebarGroupContent>
|
||||||
|
</SidebarGroup>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
17
frontend/src/lib/querys/admin/getModules.ts
Normal file
17
frontend/src/lib/querys/admin/getModules.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { queryOptions } from "@tanstack/react-query";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
export function getModules() {
|
||||||
|
return queryOptions({
|
||||||
|
queryKey: ["getModules"],
|
||||||
|
queryFn: () => fetchSession(),
|
||||||
|
staleTime: 5000,
|
||||||
|
refetchOnWindowFocus: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const fetchSession = async () => {
|
||||||
|
const { data } = await axios.get("/lst/api/system/modules");
|
||||||
|
|
||||||
|
return data.data;
|
||||||
|
};
|
||||||
@@ -26,13 +26,13 @@ import { Route as AppauthUserIndexRouteImport } from './routes/_app/(auth)/user/
|
|||||||
import { Route as MobileMobileLayoutMRelocateRouteImport } from './routes/_mobile/_mobileLayout/m/relocate'
|
import { Route as MobileMobileLayoutMRelocateRouteImport } from './routes/_mobile/_mobileLayout/m/relocate'
|
||||||
import { Route as MobileMobileLayoutMDeliveryRouteImport } from './routes/_mobile/_mobileLayout/m/delivery'
|
import { Route as MobileMobileLayoutMDeliveryRouteImport } from './routes/_mobile/_mobileLayout/m/delivery'
|
||||||
import { Route as MobileMobileLayoutMCyclecountsRouteImport } from './routes/_mobile/_mobileLayout/m/cyclecounts'
|
import { Route as MobileMobileLayoutMCyclecountsRouteImport } from './routes/_mobile/_mobileLayout/m/cyclecounts'
|
||||||
import { Route as AppAdminLayoutAdminSettingsRouteImport } from './routes/_app/_adminLayout/admin/settings'
|
|
||||||
import { Route as AppAdminLayoutAdminServersRouteImport } from './routes/_app/_adminLayout/admin/servers'
|
import { Route as AppAdminLayoutAdminServersRouteImport } from './routes/_app/_adminLayout/admin/servers'
|
||||||
import { Route as ApplogisticsLogisticsDeliveryScheduleRouteImport } from './routes/_app/(logistics)/logistics/deliverySchedule'
|
import { Route as ApplogisticsLogisticsDeliveryScheduleRouteImport } from './routes/_app/(logistics)/logistics/deliverySchedule'
|
||||||
import { Route as AppauthUserSignupRouteImport } from './routes/_app/(auth)/user/signup'
|
import { Route as AppauthUserSignupRouteImport } from './routes/_app/(auth)/user/signup'
|
||||||
import { Route as AppauthUserResetpasswordRouteImport } from './routes/_app/(auth)/user/resetpassword'
|
import { Route as AppauthUserResetpasswordRouteImport } from './routes/_app/(auth)/user/resetpassword'
|
||||||
import { Route as AppauthUserProfileRouteImport } from './routes/_app/(auth)/user/profile'
|
import { Route as AppauthUserProfileRouteImport } from './routes/_app/(auth)/user/profile'
|
||||||
import { Route as AppAdminLayoutAdminUsersRouteRouteImport } from './routes/_app/_adminLayout/admin/_users/route'
|
import { Route as AppAdminLayoutAdminUsersRouteRouteImport } from './routes/_app/_adminLayout/admin/_users/route'
|
||||||
|
import { Route as AppAdminLayoutAdminSystemRouteRouteImport } from './routes/_app/_adminLayout/admin/_system/route'
|
||||||
import { Route as OldOldocmeCyclecountIndexRouteImport } from './routes/_old/old/(ocme)/cyclecount/index'
|
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 OldOldlogisticsSiloAdjustmentsIndexRouteImport } from './routes/_old/old/(logistics)/siloAdjustments/index'
|
||||||
import { Route as OldOldlogisticsMaterialHelperIndexRouteImport } from './routes/_old/old/(logistics)/materialHelper/index'
|
import { Route as OldOldlogisticsMaterialHelperIndexRouteImport } from './routes/_old/old/(logistics)/materialHelper/index'
|
||||||
@@ -42,6 +42,8 @@ import { Route as OldOldlogisticsBarcodegenIndexRouteImport } from './routes/_ol
|
|||||||
import { Route as OldOldlogisticsSiloAdjustmentsHistRouteImport } from './routes/_old/old/(logistics)/siloAdjustments/$hist'
|
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 AppAdminLayoutAdminUsersUsersRouteImport } from './routes/_app/_adminLayout/admin/_users/users'
|
||||||
import { Route as AppAdminLayoutAdminUsersProdUsersRouteImport } from './routes/_app/_adminLayout/admin/_users/prodUsers'
|
import { Route as AppAdminLayoutAdminUsersProdUsersRouteImport } from './routes/_app/_adminLayout/admin/_users/prodUsers'
|
||||||
|
import { Route as AppAdminLayoutAdminSystemSettingsRouteImport } from './routes/_app/_adminLayout/admin/_system/settings'
|
||||||
|
import { Route as AppAdminLayoutAdminSystemModulesRouteImport } from './routes/_app/_adminLayout/admin/_system/modules'
|
||||||
import { Route as OldOldlogisticsMaterialHelperConsumptionIndexRouteImport } from './routes/_old/old/(logistics)/materialHelper/consumption/index'
|
import { Route as OldOldlogisticsMaterialHelperConsumptionIndexRouteImport } from './routes/_old/old/(logistics)/materialHelper/consumption/index'
|
||||||
import { Route as OldOldlogisticsSiloAdjustmentsCommentCommentRouteImport } from './routes/_old/old/(logistics)/siloAdjustments/comment/$comment'
|
import { Route as OldOldlogisticsSiloAdjustmentsCommentCommentRouteImport } from './routes/_old/old/(logistics)/siloAdjustments/comment/$comment'
|
||||||
|
|
||||||
@@ -130,12 +132,6 @@ const MobileMobileLayoutMCyclecountsRoute =
|
|||||||
path: '/m/cyclecounts',
|
path: '/m/cyclecounts',
|
||||||
getParentRoute: () => MobileMobileLayoutRouteRoute,
|
getParentRoute: () => MobileMobileLayoutRouteRoute,
|
||||||
} as any)
|
} as any)
|
||||||
const AppAdminLayoutAdminSettingsRoute =
|
|
||||||
AppAdminLayoutAdminSettingsRouteImport.update({
|
|
||||||
id: '/settings',
|
|
||||||
path: '/settings',
|
|
||||||
getParentRoute: () => AppAdminLayoutAdminRoute,
|
|
||||||
} as any)
|
|
||||||
const AppAdminLayoutAdminServersRoute =
|
const AppAdminLayoutAdminServersRoute =
|
||||||
AppAdminLayoutAdminServersRouteImport.update({
|
AppAdminLayoutAdminServersRouteImport.update({
|
||||||
id: '/servers',
|
id: '/servers',
|
||||||
@@ -169,6 +165,11 @@ const AppAdminLayoutAdminUsersRouteRoute =
|
|||||||
id: '/_users',
|
id: '/_users',
|
||||||
getParentRoute: () => AppAdminLayoutAdminRoute,
|
getParentRoute: () => AppAdminLayoutAdminRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
const AppAdminLayoutAdminSystemRouteRoute =
|
||||||
|
AppAdminLayoutAdminSystemRouteRouteImport.update({
|
||||||
|
id: '/_system',
|
||||||
|
getParentRoute: () => AppAdminLayoutAdminRoute,
|
||||||
|
} as any)
|
||||||
const OldOldocmeCyclecountIndexRoute =
|
const OldOldocmeCyclecountIndexRoute =
|
||||||
OldOldocmeCyclecountIndexRouteImport.update({
|
OldOldocmeCyclecountIndexRouteImport.update({
|
||||||
id: '/(ocme)/cyclecount/',
|
id: '/(ocme)/cyclecount/',
|
||||||
@@ -222,6 +223,18 @@ const AppAdminLayoutAdminUsersProdUsersRoute =
|
|||||||
path: '/prodUsers',
|
path: '/prodUsers',
|
||||||
getParentRoute: () => AppAdminLayoutAdminUsersRouteRoute,
|
getParentRoute: () => AppAdminLayoutAdminUsersRouteRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
const AppAdminLayoutAdminSystemSettingsRoute =
|
||||||
|
AppAdminLayoutAdminSystemSettingsRouteImport.update({
|
||||||
|
id: '/settings',
|
||||||
|
path: '/settings',
|
||||||
|
getParentRoute: () => AppAdminLayoutAdminSystemRouteRoute,
|
||||||
|
} as any)
|
||||||
|
const AppAdminLayoutAdminSystemModulesRoute =
|
||||||
|
AppAdminLayoutAdminSystemModulesRouteImport.update({
|
||||||
|
id: '/modules',
|
||||||
|
path: '/modules',
|
||||||
|
getParentRoute: () => AppAdminLayoutAdminSystemRouteRoute,
|
||||||
|
} as any)
|
||||||
const OldOldlogisticsMaterialHelperConsumptionIndexRoute =
|
const OldOldlogisticsMaterialHelperConsumptionIndexRoute =
|
||||||
OldOldlogisticsMaterialHelperConsumptionIndexRouteImport.update({
|
OldOldlogisticsMaterialHelperConsumptionIndexRouteImport.update({
|
||||||
id: '/(logistics)/materialHelper/consumption/',
|
id: '/(logistics)/materialHelper/consumption/',
|
||||||
@@ -247,7 +260,6 @@ export interface FileRoutesByFullPath {
|
|||||||
'/user/signup': typeof AppauthUserSignupRoute
|
'/user/signup': typeof AppauthUserSignupRoute
|
||||||
'/logistics/deliverySchedule': typeof ApplogisticsLogisticsDeliveryScheduleRoute
|
'/logistics/deliverySchedule': typeof ApplogisticsLogisticsDeliveryScheduleRoute
|
||||||
'/admin/servers': typeof AppAdminLayoutAdminServersRoute
|
'/admin/servers': typeof AppAdminLayoutAdminServersRoute
|
||||||
'/admin/settings': typeof AppAdminLayoutAdminSettingsRoute
|
|
||||||
'/m/cyclecounts': typeof MobileMobileLayoutMCyclecountsRoute
|
'/m/cyclecounts': typeof MobileMobileLayoutMCyclecountsRoute
|
||||||
'/m/delivery': typeof MobileMobileLayoutMDeliveryRoute
|
'/m/delivery': typeof MobileMobileLayoutMDeliveryRoute
|
||||||
'/m/relocate': typeof MobileMobileLayoutMRelocateRoute
|
'/m/relocate': typeof MobileMobileLayoutMRelocateRoute
|
||||||
@@ -255,6 +267,8 @@ export interface FileRoutesByFullPath {
|
|||||||
'/m': typeof MobileMobileLayoutMIndexRoute
|
'/m': typeof MobileMobileLayoutMIndexRoute
|
||||||
'/old/ocp': typeof OldOldOcpIndexRoute
|
'/old/ocp': typeof OldOldOcpIndexRoute
|
||||||
'/old/rfid': typeof OldOldRfidIndexRoute
|
'/old/rfid': typeof OldOldRfidIndexRoute
|
||||||
|
'/admin/modules': typeof AppAdminLayoutAdminSystemModulesRoute
|
||||||
|
'/admin/settings': typeof AppAdminLayoutAdminSystemSettingsRoute
|
||||||
'/admin/prodUsers': typeof AppAdminLayoutAdminUsersProdUsersRoute
|
'/admin/prodUsers': typeof AppAdminLayoutAdminUsersProdUsersRoute
|
||||||
'/admin/users': typeof AppAdminLayoutAdminUsersUsersRoute
|
'/admin/users': typeof AppAdminLayoutAdminUsersUsersRoute
|
||||||
'/old/siloAdjustments/$hist': typeof OldOldlogisticsSiloAdjustmentsHistRoute
|
'/old/siloAdjustments/$hist': typeof OldOldlogisticsSiloAdjustmentsHistRoute
|
||||||
@@ -278,7 +292,6 @@ export interface FileRoutesByTo {
|
|||||||
'/user/signup': typeof AppauthUserSignupRoute
|
'/user/signup': typeof AppauthUserSignupRoute
|
||||||
'/logistics/deliverySchedule': typeof ApplogisticsLogisticsDeliveryScheduleRoute
|
'/logistics/deliverySchedule': typeof ApplogisticsLogisticsDeliveryScheduleRoute
|
||||||
'/admin/servers': typeof AppAdminLayoutAdminServersRoute
|
'/admin/servers': typeof AppAdminLayoutAdminServersRoute
|
||||||
'/admin/settings': typeof AppAdminLayoutAdminSettingsRoute
|
|
||||||
'/m/cyclecounts': typeof MobileMobileLayoutMCyclecountsRoute
|
'/m/cyclecounts': typeof MobileMobileLayoutMCyclecountsRoute
|
||||||
'/m/delivery': typeof MobileMobileLayoutMDeliveryRoute
|
'/m/delivery': typeof MobileMobileLayoutMDeliveryRoute
|
||||||
'/m/relocate': typeof MobileMobileLayoutMRelocateRoute
|
'/m/relocate': typeof MobileMobileLayoutMRelocateRoute
|
||||||
@@ -286,6 +299,8 @@ export interface FileRoutesByTo {
|
|||||||
'/m': typeof MobileMobileLayoutMIndexRoute
|
'/m': typeof MobileMobileLayoutMIndexRoute
|
||||||
'/old/ocp': typeof OldOldOcpIndexRoute
|
'/old/ocp': typeof OldOldOcpIndexRoute
|
||||||
'/old/rfid': typeof OldOldRfidIndexRoute
|
'/old/rfid': typeof OldOldRfidIndexRoute
|
||||||
|
'/admin/modules': typeof AppAdminLayoutAdminSystemModulesRoute
|
||||||
|
'/admin/settings': typeof AppAdminLayoutAdminSystemSettingsRoute
|
||||||
'/admin/prodUsers': typeof AppAdminLayoutAdminUsersProdUsersRoute
|
'/admin/prodUsers': typeof AppAdminLayoutAdminUsersProdUsersRoute
|
||||||
'/admin/users': typeof AppAdminLayoutAdminUsersUsersRoute
|
'/admin/users': typeof AppAdminLayoutAdminUsersUsersRoute
|
||||||
'/old/siloAdjustments/$hist': typeof OldOldlogisticsSiloAdjustmentsHistRoute
|
'/old/siloAdjustments/$hist': typeof OldOldlogisticsSiloAdjustmentsHistRoute
|
||||||
@@ -309,13 +324,13 @@ export interface FileRoutesById {
|
|||||||
'/_app/(auth)/login': typeof AppauthLoginRoute
|
'/_app/(auth)/login': typeof AppauthLoginRoute
|
||||||
'/_old/old/': typeof OldOldIndexRoute
|
'/_old/old/': typeof OldOldIndexRoute
|
||||||
'/_app/_adminLayout/admin': typeof AppAdminLayoutAdminRouteWithChildren
|
'/_app/_adminLayout/admin': typeof AppAdminLayoutAdminRouteWithChildren
|
||||||
|
'/_app/_adminLayout/admin/_system': typeof AppAdminLayoutAdminSystemRouteRouteWithChildren
|
||||||
'/_app/_adminLayout/admin/_users': typeof AppAdminLayoutAdminUsersRouteRouteWithChildren
|
'/_app/_adminLayout/admin/_users': typeof AppAdminLayoutAdminUsersRouteRouteWithChildren
|
||||||
'/_app/(auth)/user/profile': typeof AppauthUserProfileRoute
|
'/_app/(auth)/user/profile': typeof AppauthUserProfileRoute
|
||||||
'/_app/(auth)/user/resetpassword': typeof AppauthUserResetpasswordRoute
|
'/_app/(auth)/user/resetpassword': typeof AppauthUserResetpasswordRoute
|
||||||
'/_app/(auth)/user/signup': typeof AppauthUserSignupRoute
|
'/_app/(auth)/user/signup': typeof AppauthUserSignupRoute
|
||||||
'/_app/(logistics)/logistics/deliverySchedule': typeof ApplogisticsLogisticsDeliveryScheduleRoute
|
'/_app/(logistics)/logistics/deliverySchedule': typeof ApplogisticsLogisticsDeliveryScheduleRoute
|
||||||
'/_app/_adminLayout/admin/servers': typeof AppAdminLayoutAdminServersRoute
|
'/_app/_adminLayout/admin/servers': typeof AppAdminLayoutAdminServersRoute
|
||||||
'/_app/_adminLayout/admin/settings': typeof AppAdminLayoutAdminSettingsRoute
|
|
||||||
'/_mobile/_mobileLayout/m/cyclecounts': typeof MobileMobileLayoutMCyclecountsRoute
|
'/_mobile/_mobileLayout/m/cyclecounts': typeof MobileMobileLayoutMCyclecountsRoute
|
||||||
'/_mobile/_mobileLayout/m/delivery': typeof MobileMobileLayoutMDeliveryRoute
|
'/_mobile/_mobileLayout/m/delivery': typeof MobileMobileLayoutMDeliveryRoute
|
||||||
'/_mobile/_mobileLayout/m/relocate': typeof MobileMobileLayoutMRelocateRoute
|
'/_mobile/_mobileLayout/m/relocate': typeof MobileMobileLayoutMRelocateRoute
|
||||||
@@ -323,6 +338,8 @@ export interface FileRoutesById {
|
|||||||
'/_mobile/_mobileLayout/m/': typeof MobileMobileLayoutMIndexRoute
|
'/_mobile/_mobileLayout/m/': typeof MobileMobileLayoutMIndexRoute
|
||||||
'/_old/old/ocp/': typeof OldOldOcpIndexRoute
|
'/_old/old/ocp/': typeof OldOldOcpIndexRoute
|
||||||
'/_old/old/rfid/': typeof OldOldRfidIndexRoute
|
'/_old/old/rfid/': typeof OldOldRfidIndexRoute
|
||||||
|
'/_app/_adminLayout/admin/_system/modules': typeof AppAdminLayoutAdminSystemModulesRoute
|
||||||
|
'/_app/_adminLayout/admin/_system/settings': typeof AppAdminLayoutAdminSystemSettingsRoute
|
||||||
'/_app/_adminLayout/admin/_users/prodUsers': typeof AppAdminLayoutAdminUsersProdUsersRoute
|
'/_app/_adminLayout/admin/_users/prodUsers': typeof AppAdminLayoutAdminUsersProdUsersRoute
|
||||||
'/_app/_adminLayout/admin/_users/users': typeof AppAdminLayoutAdminUsersUsersRoute
|
'/_app/_adminLayout/admin/_users/users': typeof AppAdminLayoutAdminUsersUsersRoute
|
||||||
'/_old/old/(logistics)/siloAdjustments/$hist': typeof OldOldlogisticsSiloAdjustmentsHistRoute
|
'/_old/old/(logistics)/siloAdjustments/$hist': typeof OldOldlogisticsSiloAdjustmentsHistRoute
|
||||||
@@ -349,7 +366,6 @@ export interface FileRouteTypes {
|
|||||||
| '/user/signup'
|
| '/user/signup'
|
||||||
| '/logistics/deliverySchedule'
|
| '/logistics/deliverySchedule'
|
||||||
| '/admin/servers'
|
| '/admin/servers'
|
||||||
| '/admin/settings'
|
|
||||||
| '/m/cyclecounts'
|
| '/m/cyclecounts'
|
||||||
| '/m/delivery'
|
| '/m/delivery'
|
||||||
| '/m/relocate'
|
| '/m/relocate'
|
||||||
@@ -357,6 +373,8 @@ export interface FileRouteTypes {
|
|||||||
| '/m'
|
| '/m'
|
||||||
| '/old/ocp'
|
| '/old/ocp'
|
||||||
| '/old/rfid'
|
| '/old/rfid'
|
||||||
|
| '/admin/modules'
|
||||||
|
| '/admin/settings'
|
||||||
| '/admin/prodUsers'
|
| '/admin/prodUsers'
|
||||||
| '/admin/users'
|
| '/admin/users'
|
||||||
| '/old/siloAdjustments/$hist'
|
| '/old/siloAdjustments/$hist'
|
||||||
@@ -380,7 +398,6 @@ export interface FileRouteTypes {
|
|||||||
| '/user/signup'
|
| '/user/signup'
|
||||||
| '/logistics/deliverySchedule'
|
| '/logistics/deliverySchedule'
|
||||||
| '/admin/servers'
|
| '/admin/servers'
|
||||||
| '/admin/settings'
|
|
||||||
| '/m/cyclecounts'
|
| '/m/cyclecounts'
|
||||||
| '/m/delivery'
|
| '/m/delivery'
|
||||||
| '/m/relocate'
|
| '/m/relocate'
|
||||||
@@ -388,6 +405,8 @@ export interface FileRouteTypes {
|
|||||||
| '/m'
|
| '/m'
|
||||||
| '/old/ocp'
|
| '/old/ocp'
|
||||||
| '/old/rfid'
|
| '/old/rfid'
|
||||||
|
| '/admin/modules'
|
||||||
|
| '/admin/settings'
|
||||||
| '/admin/prodUsers'
|
| '/admin/prodUsers'
|
||||||
| '/admin/users'
|
| '/admin/users'
|
||||||
| '/old/siloAdjustments/$hist'
|
| '/old/siloAdjustments/$hist'
|
||||||
@@ -410,13 +429,13 @@ export interface FileRouteTypes {
|
|||||||
| '/_app/(auth)/login'
|
| '/_app/(auth)/login'
|
||||||
| '/_old/old/'
|
| '/_old/old/'
|
||||||
| '/_app/_adminLayout/admin'
|
| '/_app/_adminLayout/admin'
|
||||||
|
| '/_app/_adminLayout/admin/_system'
|
||||||
| '/_app/_adminLayout/admin/_users'
|
| '/_app/_adminLayout/admin/_users'
|
||||||
| '/_app/(auth)/user/profile'
|
| '/_app/(auth)/user/profile'
|
||||||
| '/_app/(auth)/user/resetpassword'
|
| '/_app/(auth)/user/resetpassword'
|
||||||
| '/_app/(auth)/user/signup'
|
| '/_app/(auth)/user/signup'
|
||||||
| '/_app/(logistics)/logistics/deliverySchedule'
|
| '/_app/(logistics)/logistics/deliverySchedule'
|
||||||
| '/_app/_adminLayout/admin/servers'
|
| '/_app/_adminLayout/admin/servers'
|
||||||
| '/_app/_adminLayout/admin/settings'
|
|
||||||
| '/_mobile/_mobileLayout/m/cyclecounts'
|
| '/_mobile/_mobileLayout/m/cyclecounts'
|
||||||
| '/_mobile/_mobileLayout/m/delivery'
|
| '/_mobile/_mobileLayout/m/delivery'
|
||||||
| '/_mobile/_mobileLayout/m/relocate'
|
| '/_mobile/_mobileLayout/m/relocate'
|
||||||
@@ -424,6 +443,8 @@ export interface FileRouteTypes {
|
|||||||
| '/_mobile/_mobileLayout/m/'
|
| '/_mobile/_mobileLayout/m/'
|
||||||
| '/_old/old/ocp/'
|
| '/_old/old/ocp/'
|
||||||
| '/_old/old/rfid/'
|
| '/_old/old/rfid/'
|
||||||
|
| '/_app/_adminLayout/admin/_system/modules'
|
||||||
|
| '/_app/_adminLayout/admin/_system/settings'
|
||||||
| '/_app/_adminLayout/admin/_users/prodUsers'
|
| '/_app/_adminLayout/admin/_users/prodUsers'
|
||||||
| '/_app/_adminLayout/admin/_users/users'
|
| '/_app/_adminLayout/admin/_users/users'
|
||||||
| '/_old/old/(logistics)/siloAdjustments/$hist'
|
| '/_old/old/(logistics)/siloAdjustments/$hist'
|
||||||
@@ -557,13 +578,6 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof MobileMobileLayoutMCyclecountsRouteImport
|
preLoaderRoute: typeof MobileMobileLayoutMCyclecountsRouteImport
|
||||||
parentRoute: typeof MobileMobileLayoutRouteRoute
|
parentRoute: typeof MobileMobileLayoutRouteRoute
|
||||||
}
|
}
|
||||||
'/_app/_adminLayout/admin/settings': {
|
|
||||||
id: '/_app/_adminLayout/admin/settings'
|
|
||||||
path: '/settings'
|
|
||||||
fullPath: '/admin/settings'
|
|
||||||
preLoaderRoute: typeof AppAdminLayoutAdminSettingsRouteImport
|
|
||||||
parentRoute: typeof AppAdminLayoutAdminRoute
|
|
||||||
}
|
|
||||||
'/_app/_adminLayout/admin/servers': {
|
'/_app/_adminLayout/admin/servers': {
|
||||||
id: '/_app/_adminLayout/admin/servers'
|
id: '/_app/_adminLayout/admin/servers'
|
||||||
path: '/servers'
|
path: '/servers'
|
||||||
@@ -601,11 +615,18 @@ declare module '@tanstack/react-router' {
|
|||||||
}
|
}
|
||||||
'/_app/_adminLayout/admin/_users': {
|
'/_app/_adminLayout/admin/_users': {
|
||||||
id: '/_app/_adminLayout/admin/_users'
|
id: '/_app/_adminLayout/admin/_users'
|
||||||
path: '/admin'
|
path: ''
|
||||||
fullPath: '/admin'
|
fullPath: '/admin'
|
||||||
preLoaderRoute: typeof AppAdminLayoutAdminUsersRouteRouteImport
|
preLoaderRoute: typeof AppAdminLayoutAdminUsersRouteRouteImport
|
||||||
parentRoute: typeof AppAdminLayoutAdminRoute
|
parentRoute: typeof AppAdminLayoutAdminRoute
|
||||||
}
|
}
|
||||||
|
'/_app/_adminLayout/admin/_system': {
|
||||||
|
id: '/_app/_adminLayout/admin/_system'
|
||||||
|
path: '/admin'
|
||||||
|
fullPath: '/admin'
|
||||||
|
preLoaderRoute: typeof AppAdminLayoutAdminSystemRouteRouteImport
|
||||||
|
parentRoute: typeof AppAdminLayoutAdminRoute
|
||||||
|
}
|
||||||
'/_old/old/(ocme)/cyclecount/': {
|
'/_old/old/(ocme)/cyclecount/': {
|
||||||
id: '/_old/old/(ocme)/cyclecount/'
|
id: '/_old/old/(ocme)/cyclecount/'
|
||||||
path: '/cyclecount'
|
path: '/cyclecount'
|
||||||
@@ -669,6 +690,20 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof AppAdminLayoutAdminUsersProdUsersRouteImport
|
preLoaderRoute: typeof AppAdminLayoutAdminUsersProdUsersRouteImport
|
||||||
parentRoute: typeof AppAdminLayoutAdminUsersRouteRoute
|
parentRoute: typeof AppAdminLayoutAdminUsersRouteRoute
|
||||||
}
|
}
|
||||||
|
'/_app/_adminLayout/admin/_system/settings': {
|
||||||
|
id: '/_app/_adminLayout/admin/_system/settings'
|
||||||
|
path: '/settings'
|
||||||
|
fullPath: '/admin/settings'
|
||||||
|
preLoaderRoute: typeof AppAdminLayoutAdminSystemSettingsRouteImport
|
||||||
|
parentRoute: typeof AppAdminLayoutAdminSystemRouteRoute
|
||||||
|
}
|
||||||
|
'/_app/_adminLayout/admin/_system/modules': {
|
||||||
|
id: '/_app/_adminLayout/admin/_system/modules'
|
||||||
|
path: '/modules'
|
||||||
|
fullPath: '/admin/modules'
|
||||||
|
preLoaderRoute: typeof AppAdminLayoutAdminSystemModulesRouteImport
|
||||||
|
parentRoute: typeof AppAdminLayoutAdminSystemRouteRoute
|
||||||
|
}
|
||||||
'/_old/old/(logistics)/materialHelper/consumption/': {
|
'/_old/old/(logistics)/materialHelper/consumption/': {
|
||||||
id: '/_old/old/(logistics)/materialHelper/consumption/'
|
id: '/_old/old/(logistics)/materialHelper/consumption/'
|
||||||
path: '/materialHelper/consumption'
|
path: '/materialHelper/consumption'
|
||||||
@@ -686,6 +721,24 @@ declare module '@tanstack/react-router' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface AppAdminLayoutAdminSystemRouteRouteChildren {
|
||||||
|
AppAdminLayoutAdminSystemModulesRoute: typeof AppAdminLayoutAdminSystemModulesRoute
|
||||||
|
AppAdminLayoutAdminSystemSettingsRoute: typeof AppAdminLayoutAdminSystemSettingsRoute
|
||||||
|
}
|
||||||
|
|
||||||
|
const AppAdminLayoutAdminSystemRouteRouteChildren: AppAdminLayoutAdminSystemRouteRouteChildren =
|
||||||
|
{
|
||||||
|
AppAdminLayoutAdminSystemModulesRoute:
|
||||||
|
AppAdminLayoutAdminSystemModulesRoute,
|
||||||
|
AppAdminLayoutAdminSystemSettingsRoute:
|
||||||
|
AppAdminLayoutAdminSystemSettingsRoute,
|
||||||
|
}
|
||||||
|
|
||||||
|
const AppAdminLayoutAdminSystemRouteRouteWithChildren =
|
||||||
|
AppAdminLayoutAdminSystemRouteRoute._addFileChildren(
|
||||||
|
AppAdminLayoutAdminSystemRouteRouteChildren,
|
||||||
|
)
|
||||||
|
|
||||||
interface AppAdminLayoutAdminUsersRouteRouteChildren {
|
interface AppAdminLayoutAdminUsersRouteRouteChildren {
|
||||||
AppAdminLayoutAdminUsersProdUsersRoute: typeof AppAdminLayoutAdminUsersProdUsersRoute
|
AppAdminLayoutAdminUsersProdUsersRoute: typeof AppAdminLayoutAdminUsersProdUsersRoute
|
||||||
AppAdminLayoutAdminUsersUsersRoute: typeof AppAdminLayoutAdminUsersUsersRoute
|
AppAdminLayoutAdminUsersUsersRoute: typeof AppAdminLayoutAdminUsersUsersRoute
|
||||||
@@ -704,16 +757,17 @@ const AppAdminLayoutAdminUsersRouteRouteWithChildren =
|
|||||||
)
|
)
|
||||||
|
|
||||||
interface AppAdminLayoutAdminRouteChildren {
|
interface AppAdminLayoutAdminRouteChildren {
|
||||||
|
AppAdminLayoutAdminSystemRouteRoute: typeof AppAdminLayoutAdminSystemRouteRouteWithChildren
|
||||||
AppAdminLayoutAdminUsersRouteRoute: typeof AppAdminLayoutAdminUsersRouteRouteWithChildren
|
AppAdminLayoutAdminUsersRouteRoute: typeof AppAdminLayoutAdminUsersRouteRouteWithChildren
|
||||||
AppAdminLayoutAdminServersRoute: typeof AppAdminLayoutAdminServersRoute
|
AppAdminLayoutAdminServersRoute: typeof AppAdminLayoutAdminServersRoute
|
||||||
AppAdminLayoutAdminSettingsRoute: typeof AppAdminLayoutAdminSettingsRoute
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AppAdminLayoutAdminRouteChildren: AppAdminLayoutAdminRouteChildren = {
|
const AppAdminLayoutAdminRouteChildren: AppAdminLayoutAdminRouteChildren = {
|
||||||
|
AppAdminLayoutAdminSystemRouteRoute:
|
||||||
|
AppAdminLayoutAdminSystemRouteRouteWithChildren,
|
||||||
AppAdminLayoutAdminUsersRouteRoute:
|
AppAdminLayoutAdminUsersRouteRoute:
|
||||||
AppAdminLayoutAdminUsersRouteRouteWithChildren,
|
AppAdminLayoutAdminUsersRouteRouteWithChildren,
|
||||||
AppAdminLayoutAdminServersRoute: AppAdminLayoutAdminServersRoute,
|
AppAdminLayoutAdminServersRoute: AppAdminLayoutAdminServersRoute,
|
||||||
AppAdminLayoutAdminSettingsRoute: AppAdminLayoutAdminSettingsRoute,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AppAdminLayoutAdminRouteWithChildren =
|
const AppAdminLayoutAdminRouteWithChildren =
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { Button } from "../../../../components/ui/button";
|
import { Button } from "../../../../../components/ui/button";
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "../../../../components/ui/select";
|
} from "../../../../../components/ui/select";
|
||||||
import { api } from "../../../../lib/axiosAPI";
|
import { api } from "../../../../../lib/axiosAPI";
|
||||||
|
|
||||||
const modules: string[] = [
|
const modules: string[] = [
|
||||||
"users",
|
"users",
|
||||||
297
frontend/src/routes/_app/_adminLayout/admin/_system/modules.tsx
Normal file
297
frontend/src/routes/_app/_adminLayout/admin/_system/modules.tsx
Normal file
@@ -0,0 +1,297 @@
|
|||||||
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import {
|
||||||
|
createColumnHelper,
|
||||||
|
flexRender,
|
||||||
|
getCoreRowModel,
|
||||||
|
getPaginationRowModel,
|
||||||
|
getSortedRowModel,
|
||||||
|
//type Row,
|
||||||
|
type SortingState,
|
||||||
|
useReactTable,
|
||||||
|
} from "@tanstack/react-table";
|
||||||
|
import axios from "axios";
|
||||||
|
import {
|
||||||
|
Activity,
|
||||||
|
ArrowDown,
|
||||||
|
ArrowUp,
|
||||||
|
BookOpenCheck,
|
||||||
|
FolderPen,
|
||||||
|
} from "lucide-react";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/components/ui/select";
|
||||||
|
import {
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableHead,
|
||||||
|
TableHeader,
|
||||||
|
TableRow,
|
||||||
|
} from "@/components/ui/table";
|
||||||
|
import { getModules } from "@/lib/querys/admin/getModules";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { useModuleStore } from "@/routes/_old/old/-lib/store/useModuleStore";
|
||||||
|
|
||||||
|
type Modules = {
|
||||||
|
category: string;
|
||||||
|
name: string;
|
||||||
|
active: boolean;
|
||||||
|
link: string;
|
||||||
|
roles: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateModuleActive = async (module: string, active: boolean) => {
|
||||||
|
return axios.patch(
|
||||||
|
`/lst/api/system/modules/update/${module}`,
|
||||||
|
{ active },
|
||||||
|
{ withCredentials: true },
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Route = createFileRoute(
|
||||||
|
"/_app/_adminLayout/admin/_system/modules",
|
||||||
|
)({
|
||||||
|
component: RouteComponent,
|
||||||
|
});
|
||||||
|
|
||||||
|
function RouteComponent() {
|
||||||
|
const { data, isLoading, refetch } = useQuery(getModules());
|
||||||
|
const [sorting, setSorting] = useState<SortingState>([]);
|
||||||
|
const columnHelper = createColumnHelper<Modules>();
|
||||||
|
const { fetchModules } = useModuleStore();
|
||||||
|
|
||||||
|
const updateActive = useMutation({
|
||||||
|
mutationFn: ({ module, active }: { module: string; active: boolean }) =>
|
||||||
|
updateModuleActive(module, active),
|
||||||
|
onSuccess: () => {
|
||||||
|
// refetch or update cache
|
||||||
|
fetchModules();
|
||||||
|
refetch();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const columns = [
|
||||||
|
columnHelper.accessor("category", {
|
||||||
|
cell: (i) => i.getValue(),
|
||||||
|
header: ({ column }) => {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||||
|
>
|
||||||
|
<span className="flex flex-row gap-2">
|
||||||
|
<BookOpenCheck />
|
||||||
|
Category
|
||||||
|
</span>
|
||||||
|
{column.getIsSorted() === "asc" ? (
|
||||||
|
<ArrowUp className="ml-2 h-4 w-4" />
|
||||||
|
) : (
|
||||||
|
<ArrowDown className="ml-2 h-4 w-4" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
columnHelper.accessor("name", {
|
||||||
|
cell: (i) => i.getValue(),
|
||||||
|
header: ({ column }) => {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||||
|
>
|
||||||
|
<span className="flex flex-row gap-2">
|
||||||
|
<FolderPen />
|
||||||
|
Name
|
||||||
|
</span>
|
||||||
|
{column.getIsSorted() === "asc" ? (
|
||||||
|
<ArrowUp className="ml-2 h-4 w-4" />
|
||||||
|
) : (
|
||||||
|
<ArrowDown className="ml-2 h-4 w-4" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
columnHelper.accessor("active", {
|
||||||
|
header: ({ column }) => {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||||
|
>
|
||||||
|
<span className="flex flex-row gap-2">
|
||||||
|
<Activity />
|
||||||
|
Active
|
||||||
|
</span>
|
||||||
|
{column.getIsSorted() === "asc" ? (
|
||||||
|
<ArrowUp className="ml-2 h-4 w-4" />
|
||||||
|
) : (
|
||||||
|
<ArrowDown className="ml-2 h-4 w-4" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
cell: ({ row, getValue }) => {
|
||||||
|
const active = getValue<boolean>();
|
||||||
|
const module = row.original.name;
|
||||||
|
const ignoreModules = ["admin", "system", "users"];
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{ignoreModules.includes(module) ? (
|
||||||
|
<></>
|
||||||
|
) : (
|
||||||
|
<Select
|
||||||
|
value={active ? "true" : "false"}
|
||||||
|
onValueChange={(value) => {
|
||||||
|
const newValue = value === "true";
|
||||||
|
updateActive.mutate({ module, active: newValue });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SelectTrigger
|
||||||
|
className={cn(
|
||||||
|
"w-[100px]",
|
||||||
|
active
|
||||||
|
? "border-green-500 text-green-600"
|
||||||
|
: "border-gray-400 text-gray-500",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="true">True</SelectItem>
|
||||||
|
<SelectItem value="false">False</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
columnHelper.accessor("link", {
|
||||||
|
cell: (i) => i.getValue(),
|
||||||
|
header: ({ column }) => {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||||
|
>
|
||||||
|
<span className="flex flex-row gap-2">
|
||||||
|
<FolderPen />
|
||||||
|
Name
|
||||||
|
</span>
|
||||||
|
{column.getIsSorted() === "asc" ? (
|
||||||
|
<ArrowUp className="ml-2 h-4 w-4" />
|
||||||
|
) : (
|
||||||
|
<ArrowDown className="ml-2 h-4 w-4" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
|
||||||
|
const table = useReactTable({
|
||||||
|
data,
|
||||||
|
columns,
|
||||||
|
getCoreRowModel: getCoreRowModel(),
|
||||||
|
getPaginationRowModel: getPaginationRowModel(),
|
||||||
|
onSortingChange: setSorting,
|
||||||
|
getSortedRowModel: getSortedRowModel(),
|
||||||
|
//renderSubComponent: ({ row }: { row: any }) => <ExpandedRow row={row} />,
|
||||||
|
//getRowCanExpand: () => true,
|
||||||
|
state: {
|
||||||
|
sorting,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return <div className="m-auto">Loading user data</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// function renderSubComponent( { row: Row<Modules> }): React.ReactNode {
|
||||||
|
// throw new Error("Function not implemented.");
|
||||||
|
// }
|
||||||
|
|
||||||
|
//console.log(data);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="p-4">
|
||||||
|
<div className="w-fit">
|
||||||
|
<Table>
|
||||||
|
<TableHeader>
|
||||||
|
{table.getHeaderGroups().map((headerGroup) => (
|
||||||
|
<TableRow key={headerGroup.id}>
|
||||||
|
{headerGroup.headers.map((header) => {
|
||||||
|
return (
|
||||||
|
<TableHead key={header.id}>
|
||||||
|
{header.isPlaceholder
|
||||||
|
? null
|
||||||
|
: flexRender(
|
||||||
|
header.column.columnDef.header,
|
||||||
|
header.getContext(),
|
||||||
|
)}
|
||||||
|
</TableHead>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
{table.getRowModel().rows.map((row) => (
|
||||||
|
<React.Fragment key={row.id}>
|
||||||
|
<TableRow
|
||||||
|
key={row.id}
|
||||||
|
data-state={row.getIsSelected() && "selected"}
|
||||||
|
>
|
||||||
|
{row.getVisibleCells().map((cell) => (
|
||||||
|
<TableCell key={cell.id}>
|
||||||
|
{flexRender(
|
||||||
|
cell.column.columnDef.cell,
|
||||||
|
cell.getContext(),
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
))}
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
{/* {row.getIsExpanded() && (
|
||||||
|
<TableRow>
|
||||||
|
<TableCell colSpan={row.getVisibleCells().length}>
|
||||||
|
{renderSubComponent({ row })}
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)} */}
|
||||||
|
</React.Fragment>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
<div className="flex items-center justify-end space-x-2 py-4">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => table.previousPage()}
|
||||||
|
disabled={!table.getCanPreviousPage()}
|
||||||
|
>
|
||||||
|
Previous
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => table.nextPage()}
|
||||||
|
disabled={!table.getCanNextPage()}
|
||||||
|
>
|
||||||
|
Next
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { createFileRoute, Link, Outlet } from "@tanstack/react-router";
|
||||||
|
|
||||||
|
export const Route = createFileRoute("/_app/_adminLayout/admin/_system")({
|
||||||
|
component: RouteComponent,
|
||||||
|
});
|
||||||
|
|
||||||
|
function RouteComponent() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<nav className="flex justify-center gap-3">
|
||||||
|
<Link
|
||||||
|
to="/admin/settings"
|
||||||
|
className="[&.active]:font-bold [&.active]:underline"
|
||||||
|
activeOptions={{
|
||||||
|
exact: true,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Settings
|
||||||
|
</Link>
|
||||||
|
<Link
|
||||||
|
to="/admin/modules"
|
||||||
|
className="[&.active]:font-bold [&.active]:underline"
|
||||||
|
activeOptions={{
|
||||||
|
exact: true,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Modules
|
||||||
|
</Link>
|
||||||
|
</nav>
|
||||||
|
<Outlet />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { createFileRoute } from '@tanstack/react-router'
|
||||||
|
|
||||||
|
export const Route = createFileRoute(
|
||||||
|
'/_app/_adminLayout/admin/_system/settings',
|
||||||
|
)({
|
||||||
|
component: RouteComponent,
|
||||||
|
})
|
||||||
|
|
||||||
|
function RouteComponent() {
|
||||||
|
return <div>Hello "/_app/_adminLayout/admin/_system/settings"!</div>
|
||||||
|
}
|
||||||
@@ -30,7 +30,7 @@ import {
|
|||||||
TableRow,
|
TableRow,
|
||||||
} from "../../../../../components/ui/table";
|
} from "../../../../../components/ui/table";
|
||||||
import { getUsers } from "../../../../../lib/querys/admin/getUsers";
|
import { getUsers } from "../../../../../lib/querys/admin/getUsers";
|
||||||
import ExpandedRow from "../../-components/ExpandedRow";
|
import ExpandedRow from "../../-components/users/ExpandedRow";
|
||||||
|
|
||||||
type User = {
|
type User = {
|
||||||
username: string;
|
username: string;
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import { createFileRoute } from '@tanstack/react-router'
|
|
||||||
|
|
||||||
export const Route = createFileRoute('/_app/_adminLayout/admin/settings')({
|
|
||||||
component: RouteComponent,
|
|
||||||
})
|
|
||||||
|
|
||||||
function RouteComponent() {
|
|
||||||
return <div>Hello "/_adminLayout/admin/settings"!</div>
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,6 @@ import { hasPageAccess } from "../../../-utils/userAccess";
|
|||||||
const iconMap: any = {
|
const iconMap: any = {
|
||||||
Printer: Printer,
|
Printer: Printer,
|
||||||
Tag: Tag,
|
Tag: Tag,
|
||||||
|
|
||||||
Cat: Cat,
|
Cat: Cat,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -29,9 +28,8 @@ export function ProductionSideBar({
|
|||||||
//const url: string = window.location.host.split(":")[0];
|
//const url: string = window.location.host.split(":")[0];
|
||||||
const { modules } = useModuleStore();
|
const { modules } = useModuleStore();
|
||||||
|
|
||||||
const items = modules?.filter((m) => m.category === "production");
|
const items = modules?.filter((m) => m.category === "production" && m.active);
|
||||||
const userUpdate = { ...user, roles: userRoles };
|
const userUpdate = { ...user, roles: userRoles };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarGroup>
|
<SidebarGroup>
|
||||||
<SidebarGroupLabel>Production</SidebarGroupLabel>
|
<SidebarGroupLabel>Production</SidebarGroupLabel>
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
|
import { format, formatDuration, intervalToDuration } from "date-fns";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
|
import { success } from "zod/v4";
|
||||||
import { db } from "../../../../../database/dbclient.js";
|
import { db } from "../../../../../database/dbclient.js";
|
||||||
import { printerData } from "../../../../../database/schema/printers.js";
|
import { printerData } from "../../../../../database/schema/printers.js";
|
||||||
import { runProdApi } from "../../../../globalUtils/runProdApi.js";
|
import { runProdApi } from "../../../../globalUtils/runProdApi.js";
|
||||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||||
import { createLog } from "../../../logger/logger.js";
|
import { createLog } from "../../../logger/logger.js";
|
||||||
import { query } from "../../../sqlServer/prodSqlServer.js";
|
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||||
import { labelInfo } from "../../../sqlServer/querys/warehouse/labelInfo.js";
|
|
||||||
import { format, formatDuration, intervalToDuration } from "date-fns";
|
|
||||||
import { shiftChange } from "../../../sqlServer/querys/misc/shiftChange.js";
|
import { shiftChange } from "../../../sqlServer/querys/misc/shiftChange.js";
|
||||||
import { success } from "zod/v4";
|
import { labelInfo } from "../../../sqlServer/querys/warehouse/labelInfo.js";
|
||||||
|
|
||||||
type NewLotData = {
|
type NewLotData = {
|
||||||
runningNumber: number;
|
runningNumber: number;
|
||||||
lotNumber: number;
|
lotNumber: number;
|
||||||
originalAmount: number;
|
originalAmount: number;
|
||||||
level: number;
|
level: number;
|
||||||
amount: number;
|
amount: number;
|
||||||
type: "lot" | "eom";
|
type: "lot" | "eom";
|
||||||
};
|
};
|
||||||
|
|
||||||
interface PendingJob {
|
interface PendingJob {
|
||||||
timeoutId: NodeJS.Timeout;
|
timeoutId: NodeJS.Timeout;
|
||||||
runningNumber: string | number;
|
runningNumber: string | number;
|
||||||
data: any;
|
data: any;
|
||||||
consumeLot: any;
|
consumeLot: any;
|
||||||
newQty: any;
|
newQty: any;
|
||||||
scheduledFor: Date;
|
scheduledFor: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const pendingJobs = new Map<string | number, PendingJob>();
|
export const pendingJobs = new Map<string | number, PendingJob>();
|
||||||
@@ -42,385 +42,383 @@ export const pendingJobs = new Map<string | number, PendingJob>();
|
|||||||
* type what way are we lots
|
* type what way are we lots
|
||||||
*/
|
*/
|
||||||
export const lotMaterialTransfer = async (data: NewLotData) => {
|
export const lotMaterialTransfer = async (data: NewLotData) => {
|
||||||
// check if we already have this running number scheduled
|
// check if we already have this running number scheduled
|
||||||
if (pendingJobs.has(data.runningNumber)) {
|
if (pendingJobs.has(data.runningNumber)) {
|
||||||
const job = pendingJobs.get(data.runningNumber) as PendingJob;
|
const job = pendingJobs.get(data.runningNumber) as PendingJob;
|
||||||
|
|
||||||
const duration = intervalToDuration({
|
const duration = intervalToDuration({
|
||||||
start: new Date(),
|
start: new Date(),
|
||||||
end: job.scheduledFor,
|
end: job.scheduledFor,
|
||||||
});
|
});
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
`${
|
`${
|
||||||
data.runningNumber
|
data.runningNumber
|
||||||
} is pending to be transfered already, remaining time ${formatDuration(
|
} is pending to be transfered already, remaining time ${formatDuration(
|
||||||
duration,
|
duration,
|
||||||
{ format: ["hours", "minutes", "seconds"] }
|
{ format: ["hours", "minutes", "seconds"] },
|
||||||
)}`
|
)}`,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: `${
|
message: `${
|
||||||
data.runningNumber
|
data.runningNumber
|
||||||
} is pending to be transfered already, remaining time ${formatDuration(
|
} is pending to be transfered already, remaining time ${formatDuration(
|
||||||
duration,
|
duration,
|
||||||
{ format: ["hours", "minutes", "seconds"] }
|
{ format: ["hours", "minutes", "seconds"] },
|
||||||
)}`,
|
)}`,
|
||||||
data: [],
|
data: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// get the shift time
|
// get the shift time
|
||||||
const { data: shift, error: shiftError } = (await tryCatch(
|
const { data: shift, error: shiftError } = (await tryCatch(
|
||||||
query(shiftChange, "shift change from material.")
|
query(shiftChange, "shift change from material."),
|
||||||
)) as any;
|
)) as any;
|
||||||
|
|
||||||
if (shiftError) {
|
if (shiftError) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
"There was an error getting the shift times will use fallback times"
|
"There was an error getting the shift times will use fallback times",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// shift split
|
// shift split
|
||||||
const shiftTimeSplit = shift?.data[0]?.shiftChange.split(":");
|
const shiftTimeSplit = shift?.data[0]?.shiftChange.split(":");
|
||||||
console.log(parseInt(shiftTimeSplit[0]) - 1);
|
console.log(parseInt(shiftTimeSplit[0]) - 1);
|
||||||
// Current time
|
// Current time
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
// Target time: today at 06:35
|
// Target time: today at 06:35
|
||||||
const target = new Date(
|
const target = new Date(
|
||||||
now.getFullYear(),
|
now.getFullYear(),
|
||||||
now.getMonth(),
|
now.getMonth(),
|
||||||
1, //now.getDate(),
|
1, //now.getDate(),
|
||||||
shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[0]) : 5, // this will parse the hour to remove teh zero
|
shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[0]) : 5, // this will parse the hour to remove teh zero
|
||||||
shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[1]) : 3,
|
shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[1]) : 3,
|
||||||
0,
|
0,
|
||||||
0
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("target", target.toLocaleString(), "Now", now.toLocaleString());
|
console.log("target", target.toLocaleString(), "Now", now.toLocaleString());
|
||||||
|
|
||||||
// to early time
|
// to early time
|
||||||
const early = new Date(
|
const early = new Date(
|
||||||
now.getFullYear(),
|
now.getFullYear(),
|
||||||
now.getMonth(),
|
now.getMonth(),
|
||||||
1, //now.getDate(),
|
1, //now.getDate(),
|
||||||
shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[0]) - 1 : 5, // this will parse the hour to remove teh zero
|
shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[0]) - 1 : 5, // this will parse the hour to remove teh zero
|
||||||
shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[1]) : 0,
|
shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[1]) : 0,
|
||||||
0,
|
0,
|
||||||
0
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("early", early.toLocaleString(), "Now", now.toLocaleString());
|
console.log("early", early.toLocaleString(), "Now", now.toLocaleString());
|
||||||
|
|
||||||
// next month just to be here
|
// next month just to be here
|
||||||
const nextMonth = new Date(
|
const nextMonth = new Date(
|
||||||
now.getFullYear(),
|
now.getFullYear(),
|
||||||
now.getMonth() + 1,
|
now.getMonth() + 1,
|
||||||
1, //now.getDate(),
|
1, //now.getDate(),
|
||||||
shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[0]) - 1 : 5, // this will parse the hour to remove teh zero
|
shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[0]) - 1 : 5, // this will parse the hour to remove teh zero
|
||||||
shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[1]) : 0,
|
shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[1]) : 0,
|
||||||
0,
|
0,
|
||||||
0
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
"nextMonth",
|
"nextMonth",
|
||||||
nextMonth.toLocaleString(),
|
nextMonth.toLocaleString(),
|
||||||
"Now",
|
"Now",
|
||||||
now.toLocaleString()
|
now.toLocaleString(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// console.log(early, target);
|
// console.log(early, target);
|
||||||
// if we are to early return early only if we are sending over eom
|
// if we are to early return early only if we are sending over eom
|
||||||
if (data.type === "eom" && (early > now || target < now)) {
|
if (data.type === "eom" && (early > now || target < now)) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
`Eom transfers is not allowed right now please try again at ${format(
|
`Eom transfers is not allowed right now please try again at ${format(
|
||||||
nextMonth,
|
nextMonth,
|
||||||
"M/d/yyyy hh:mm"
|
"M/d/yyyy hh:mm",
|
||||||
)} `
|
)} `,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: `Eom transfers is not allowed right now please try again at ${format(
|
message: `Eom transfers is not allowed right now please try again at ${format(
|
||||||
nextMonth,
|
nextMonth,
|
||||||
"M/d/yyyy hh:mm"
|
"M/d/yyyy hh:mm",
|
||||||
)} `,
|
)} `,
|
||||||
data: [],
|
data: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let timeoutTrans: number = data.type === "lot" ? 30 : 10;
|
let timeoutTrans: number = data.type === "lot" ? 30 : 10;
|
||||||
// get the barcode, and layoutID from the running number
|
// get the barcode, and layoutID from the running number
|
||||||
const { data: label, error: labelError } = (await tryCatch(
|
const { data: label, error: labelError } = (await tryCatch(
|
||||||
query(
|
query(
|
||||||
labelInfo.replace("[runningNr]", `${data.runningNumber}`),
|
labelInfo.replace("[runningNr]", `${data.runningNumber}`),
|
||||||
"Get label info"
|
"Get label info",
|
||||||
)
|
),
|
||||||
)) as any;
|
)) as any;
|
||||||
|
|
||||||
if (labelError) {
|
if (labelError) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
"There was an error getting the label info"
|
"There was an error getting the label info",
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "There was an error getting the label info",
|
message: "There was an error getting the label info",
|
||||||
data: labelError,
|
data: labelError,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (label.data.length === 0) {
|
if (label.data.length === 0) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
`${data.runningNumber}: dose not exist or no longer in stock.`
|
`${data.runningNumber}: dose not exist or no longer in stock.`,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: `${data.runningNumber}: dose not exist or no longer in stock.`,
|
message: `${data.runningNumber}: dose not exist or no longer in stock.`,
|
||||||
data: [],
|
data: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.log(label);
|
//console.log(label);
|
||||||
|
|
||||||
if (label.data[0]?.stockStatus === "onStock") {
|
if (label.data[0]?.stockStatus === "onStock") {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
`${data.runningNumber}: currently in stock and not consumed to a lot.`
|
`${data.runningNumber}: currently in stock and not consumed to a lot.`,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: `${data.runningNumber}: currently in stock and not consumed to a lot.`,
|
message: `${data.runningNumber}: currently in stock and not consumed to a lot.`,
|
||||||
data: [],
|
data: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the pdf24 printer id
|
// get the pdf24 printer id
|
||||||
const { data: printer, error: printerError } = (await tryCatch(
|
const { data: printer, error: printerError } = (await tryCatch(
|
||||||
db.select().from(printerData).where(eq(printerData.name, "PDF24"))
|
db.select().from(printerData).where(eq(printerData.name, "PDF24")),
|
||||||
)) as any;
|
)) as any;
|
||||||
|
|
||||||
if (printerError) {
|
if (printerError) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
"There was an error the printer info"
|
"There was an error the printer info",
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "There was an error the printer info",
|
message: "There was an error the printer info",
|
||||||
data: printerError,
|
data: printerError,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// calculate the remaining amount bascially it will be orignal number * level sent over
|
// calculate the remaining amount bascially it will be orignal number * level sent over
|
||||||
// level should be sent in a decimal .25 .5 .75 .95 the 95 will allow basically the what looks to be a full gaylord but we always want to consume something
|
// level should be sent in a decimal .25 .5 .75 .95 the 95 will allow basically the what looks to be a full gaylord but we always want to consume something
|
||||||
const newQty =
|
const newQty =
|
||||||
data.amount > 0
|
data.amount > 0
|
||||||
? data.amount
|
? data.amount
|
||||||
: (data.originalAmount * data.level).toFixed(0);
|
: (data.originalAmount * data.level).toFixed(0);
|
||||||
|
|
||||||
//console.log(data.amount);
|
//console.log(data.amount);
|
||||||
|
|
||||||
// reprint the label and send it to pdf24
|
// reprint the label and send it to pdf24
|
||||||
const reprintData = {
|
const reprintData = {
|
||||||
clientId: 999,
|
clientId: 999,
|
||||||
runningNo: label?.data[0].runnungNumber,
|
runningNo: label?.data[0].runnungNumber,
|
||||||
printerId: printer[0].humanReadableId,
|
printerId: printer[0].humanReadableId,
|
||||||
layoutId: label?.data[0].labelLayout,
|
layoutId: label?.data[0].labelLayout,
|
||||||
noOfCopies: 0,
|
noOfCopies: 0,
|
||||||
quantity: newQty,
|
quantity: newQty,
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
//console.log(reprintData);
|
//console.log(reprintData);
|
||||||
|
|
||||||
const { data: reprint, error: reprintError } = (await tryCatch(
|
const { data: reprint, error: reprintError } = (await tryCatch(
|
||||||
runProdApi({
|
runProdApi({
|
||||||
endpoint: "/public/v1.0/ProductionLabelling/ReprintLabel",
|
endpoint: "/public/v1.0/ProductionLabelling/ReprintLabel",
|
||||||
data: [reprintData],
|
data: [reprintData],
|
||||||
})
|
}),
|
||||||
)) as any;
|
)) as any;
|
||||||
|
|
||||||
if (!reprint.success) {
|
if (!reprint.success) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
`RN:${data.runningNumber}, Reprinting Error: ${reprint.data.data.message}`
|
`RN:${data.runningNumber}, Reprinting Error: ${reprint.data.data.message}`,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: `RN:${data.runningNumber}, Reprinting Error: ${reprint.data.data.message}`,
|
message: `RN:${data.runningNumber}, Reprinting Error: ${reprint.data.data.message}`,
|
||||||
data: reprint,
|
data: reprint,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// return the label back to fm1 lane id 10001
|
// return the label back to fm1 lane id 10001
|
||||||
|
|
||||||
const matReturnData = {
|
const matReturnData = {
|
||||||
barcode: label?.data[0].Barcode,
|
barcode: label?.data[0].Barcode,
|
||||||
laneId: 10001,
|
laneId: 10001,
|
||||||
};
|
};
|
||||||
|
|
||||||
//console.log(matReturnData);
|
//console.log(matReturnData);
|
||||||
const { data: matReturn, error: matReturError } = (await tryCatch(
|
const { data: matReturn, error: matReturError } = (await tryCatch(
|
||||||
runProdApi({
|
runProdApi({
|
||||||
endpoint:
|
endpoint:
|
||||||
"/public/v1.0/IssueMaterial/ReturnPartiallyConsumedManualMaterial",
|
"/public/v1.0/IssueMaterial/ReturnPartiallyConsumedManualMaterial",
|
||||||
data: [matReturnData],
|
data: [matReturnData],
|
||||||
})
|
}),
|
||||||
)) as any;
|
)) as any;
|
||||||
|
|
||||||
if (!matReturn.success) {
|
if (!matReturn.success) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
`RN:${data.runningNumber}, Return Error ${matReturn.data.data.errors[0].message}`
|
`RN:${data.runningNumber}, Return Error ${matReturn.data.data.errors[0].message}`,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: `RN:${data.runningNumber}, Return Error ${matReturn.data.data.errors[0].message}`,
|
message: `RN:${data.runningNumber}, Return Error ${matReturn.data.data.errors[0].message}`,
|
||||||
data: matReturn,
|
data: matReturn,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// consume to the lot provided.
|
// consume to the lot provided.
|
||||||
const consumeLot = {
|
const consumeLot = {
|
||||||
productionLot: data.lotNumber,
|
productionLot: data.lotNumber,
|
||||||
barcode: label?.data[0].Barcode,
|
barcode: label?.data[0].Barcode,
|
||||||
};
|
};
|
||||||
|
|
||||||
const delay =
|
const delay =
|
||||||
data.type === "lot"
|
data.type === "lot"
|
||||||
? timeoutTrans * 1000
|
? timeoutTrans * 1000
|
||||||
: target.getTime() - now.getTime();
|
: target.getTime() - now.getTime();
|
||||||
|
|
||||||
const transfer = await transferMaterial(delay, data, consumeLot, newQty);
|
const transfer = await transferMaterial(delay, data, consumeLot, newQty);
|
||||||
|
|
||||||
if (!transfer.success) {
|
if (!transfer.success) {
|
||||||
return {
|
return {
|
||||||
success: transfer.success,
|
success: transfer.success,
|
||||||
message: transfer.message,
|
message: transfer.message,
|
||||||
data: transfer.data,
|
data: transfer.data,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const duration = intervalToDuration({ start: now, end: target });
|
const duration = intervalToDuration({ start: now, end: target });
|
||||||
const pretty = formatDuration(duration, {
|
const pretty = formatDuration(duration, {
|
||||||
format: ["hours", "minutes", "seconds"],
|
format: ["hours", "minutes", "seconds"],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data.type === "eom") {
|
if (data.type === "eom") {
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: `RN:${data.runningNumber}: qty: ${newQty}, will be transfered to lot: ${data.lotNumber}, in ${pretty} `,
|
message: `RN:${data.runningNumber}: qty: ${newQty}, will be transfered to lot: ${data.lotNumber}, in ${pretty} `,
|
||||||
data: [],
|
data: [],
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: `RN:${data.runningNumber}: qty: ${newQty}, was transfered to lot: ${data.lotNumber}`,
|
message: `RN:${data.runningNumber}: qty: ${newQty}, was transfered to lot: ${data.lotNumber}`,
|
||||||
data: [],
|
data: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const transferMaterial = async (
|
const transferMaterial = async (
|
||||||
delay: number,
|
delay: number,
|
||||||
data: any,
|
data: any,
|
||||||
consumeLot: any,
|
consumeLot: any,
|
||||||
newQty: any
|
newQty: any,
|
||||||
) => {
|
) => {
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
if (pendingJobs.has(data.runningNumber)) {
|
if (pendingJobs.has(data.runningNumber)) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
`${data.runningNumber} is pending to be transfered already`
|
`${data.runningNumber} is pending to be transfered already`,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: `${data.runningNumber} is pending to be transfered already`,
|
message: `${data.runningNumber} is pending to be transfered already`,
|
||||||
data: [],
|
data: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const scheduledFor = new Date(Date.now() + delay);
|
const scheduledFor = new Date(Date.now() + delay);
|
||||||
// sets the time out based on the type of transfer sent over.
|
// sets the time out based on the type of transfer sent over.
|
||||||
const timeoutId = setTimeout(async () => {
|
const timeoutId = setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
const { data: matConsume, error: matConsumeError } =
|
const { data: matConsume, error: matConsumeError } = (await tryCatch(
|
||||||
(await tryCatch(
|
runProdApi({
|
||||||
runProdApi({
|
endpoint:
|
||||||
endpoint:
|
"/public/v1.0/IssueMaterial/ConsumeNonPreparedManualMaterial",
|
||||||
"/public/v1.0/IssueMaterial/ConsumeNonPreparedManualMaterial",
|
data: [consumeLot],
|
||||||
data: [consumeLot],
|
}),
|
||||||
})
|
)) as any;
|
||||||
)) as any;
|
|
||||||
|
|
||||||
if (!matConsume?.success) {
|
if (!matConsume?.success) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
`RN:${data.runningNumber}, Consume Error ${
|
`RN:${data.runningNumber}, Consume Error ${
|
||||||
matConsume?.data?.data?.errors?.[0]?.message ??
|
matConsume?.data?.data?.errors?.[0]?.message ?? "Unknown"
|
||||||
"Unknown"
|
}`,
|
||||||
}`
|
);
|
||||||
);
|
return; // still hits finally
|
||||||
return; // still hits finally
|
}
|
||||||
}
|
|
||||||
|
|
||||||
createLog(
|
createLog(
|
||||||
"info",
|
"info",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
`RN:${data.runningNumber}: qty: ${newQty}, was transferred to lot:${data.lotNumber}`
|
`RN:${data.runningNumber}: qty: ${newQty}, was transferred to lot:${data.lotNumber}`,
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
createLog(
|
createLog(
|
||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
`RN:${data.runningNumber}, ${err}`
|
`RN:${data.runningNumber}, ${err}`,
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
// Always clear the pending entry, even if error
|
// Always clear the pending entry, even if error
|
||||||
pendingJobs.delete(data.runningNumber);
|
pendingJobs.delete(data.runningNumber);
|
||||||
}
|
}
|
||||||
}, delay);
|
}, delay);
|
||||||
|
|
||||||
pendingJobs.set(data.runningNumber, {
|
pendingJobs.set(data.runningNumber, {
|
||||||
timeoutId,
|
timeoutId,
|
||||||
runningNumber: data.runningNumber,
|
runningNumber: data.runningNumber,
|
||||||
data,
|
data,
|
||||||
consumeLot,
|
consumeLot,
|
||||||
newQty,
|
newQty,
|
||||||
scheduledFor,
|
scheduledFor,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Immediately say we scheduled it
|
// Immediately say we scheduled it
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: `Transfer for ${data.runningNumber} scheduled`,
|
message: `Transfer for ${data.runningNumber} scheduled`,
|
||||||
data: [],
|
data: [],
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// setInterval(() => {
|
// setInterval(() => {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ dbo.V_LadePlanungenLadeAuftragAbruf.AdressBez AS CustName,
|
|||||||
dbo.T_EAIJournal.IdJournalStatus as bolStatus,
|
dbo.T_EAIJournal.IdJournalStatus as bolStatus,
|
||||||
V_TrackerAuftragsAbrufe.IdAuftragsAbruf as releaseNum,
|
V_TrackerAuftragsAbrufe.IdAuftragsAbruf as releaseNum,
|
||||||
V_LadePlanungenLadeAuftragAbruf.IdLadeAuftrag as truckPostion
|
V_LadePlanungenLadeAuftragAbruf.IdLadeAuftrag as truckPostion
|
||||||
|
,dbo.V_TrackerAuftragsAbrufe.IdArtikelvarianten as av
|
||||||
|
,dbo.V_TrackerAuftragsAbrufe.ArtikelVariantenAlias as alias
|
||||||
,'Base Plant' as plantType
|
,'Base Plant' as plantType
|
||||||
from dbo.V_TrackerAuftragsAbrufe (nolock)
|
from dbo.V_TrackerAuftragsAbrufe (nolock)
|
||||||
|
|
||||||
@@ -59,6 +61,8 @@ select top (50) (select wert from dbo.T_SystemParameter where Bezeichnung = 'Wer
|
|||||||
,null as bolStatus
|
,null as bolStatus
|
||||||
,null as releaseNum
|
,null as releaseNum
|
||||||
,null as truckPostion
|
,null as truckPostion
|
||||||
|
,i.IdArtikelVariante as av
|
||||||
|
,null as alias
|
||||||
,'In-House' as plantType
|
,'In-House' as plantType
|
||||||
--,*
|
--,*
|
||||||
|
|
||||||
|
|||||||
3
migrations/0024_uneven_the_fury.sql
Normal file
3
migrations/0024_uneven_the_fury.sql
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ALTER TABLE "modules" RENAME COLUMN "name" TO "module_name";--> statement-breakpoint
|
||||||
|
DROP INDEX "module_name";--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "module_name" ON "modules" USING btree ("module_name");
|
||||||
3
migrations/0025_foamy_mattie_franklin.sql
Normal file
3
migrations/0025_foamy_mattie_franklin.sql
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ALTER TABLE "modules" RENAME COLUMN "module_name" TO "name";--> statement-breakpoint
|
||||||
|
DROP INDEX "module_name";--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "module_name" ON "modules" USING btree ("name");
|
||||||
1739
migrations/meta/0024_snapshot.json
Normal file
1739
migrations/meta/0024_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1739
migrations/meta/0025_snapshot.json
Normal file
1739
migrations/meta/0025_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -169,6 +169,20 @@
|
|||||||
"when": 1761781568161,
|
"when": 1761781568161,
|
||||||
"tag": "0023_minor_marvel_zombies",
|
"tag": "0023_minor_marvel_zombies",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 24,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1761829793348,
|
||||||
|
"tag": "0024_uneven_the_fury",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 25,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1761830426770,
|
||||||
|
"tag": "0025_foamy_mattie_franklin",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user