test(ocme): cycle count intital improvements

This commit is contained in:
2025-03-19 21:45:10 -05:00
parent e17b8e7bbe
commit 7a22b52c91
19 changed files with 709 additions and 33 deletions

View File

@@ -51,6 +51,14 @@ const items = [
module: "logistics",
active: true,
},
{
title: "Ocme Cyclecount",
url: "/cyclecount",
icon: Package,
role: ["technician", "supervisor", "manager", "admin", "systemAdmin"],
module: "logistics",
active: true,
},
];
export function LogisticsSideBar({user, moduleID}: {user: User | null; moduleID: string}) {

View File

@@ -15,7 +15,7 @@ const items = [
title: "One Click Print",
url: "/ocp",
icon: Printer,
role: [],
role: ["viewer"],
module: "ocp",
active: true,
},

View File

@@ -0,0 +1,22 @@
import {LstCard} from "../extendedUI/LstCard";
import {CardContent, CardHeader} from "../ui/card";
import {Skeleton} from "../ui/skeleton";
export default function CycleCountLog() {
return (
<LstCard className="w-48">
<CardHeader className="flex justify-center">
<span>Cycle Count logs</span>
</CardHeader>
<CardContent>
{Array(10)
.fill(0)
.map((_, i) => (
<div key={i}>
<Skeleton className="m-2 h-4" />
</div>
))}
</CardContent>
</LstCard>
);
}

View File

@@ -0,0 +1,81 @@
import {toast} from "sonner";
import {LstCard} from "../extendedUI/LstCard";
import {Button} from "../ui/button";
import {Input} from "../ui/input";
import {Table, TableBody, TableCell, TableHead, TableHeader, TableRow} from "../ui/table";
import {Skeleton} from "../ui/skeleton";
import CycleCountLog from "./CycleCountLog";
export default function OcmeCycleCount() {
return (
<div className="flex flex-row w-fill">
<div className="m-2 w-5/6">
<LstCard>
<div>
<form>
<div className="flex justify-between">
<div className="m-2">
<Input placeholder="enter lane: L064" />
</div>
<Button className="m-2" onClick={() => toast.success("Cycle Count completed")}>
CycleCount
</Button>
</div>
</form>
</div>
<div>
<Table>
<TableHeader>
<TableRow>
<TableHead>LaneID</TableHead>
<TableHead>Lane</TableHead>
<TableHead>AV</TableHead>
<TableHead>Description</TableHead>
<TableHead>Running Number</TableHead>
<TableHead>In Ocme</TableHead>
<TableHead>In Stock</TableHead>
<TableHead>Result</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{Array(10)
.fill(0)
.map((_, i) => (
<TableRow key={i}>
<TableCell className="font-medium">
<Skeleton className="h-4" />
</TableCell>
<TableCell>
<Skeleton className="h-4" />
</TableCell>
<TableCell>
<Skeleton className="h-4" />
</TableCell>
<TableCell>
<Skeleton className="h-4" />
</TableCell>
<TableCell>
<Skeleton className="h-4" />
</TableCell>
<TableCell>
<Skeleton className="h-4" />
</TableCell>
<TableCell>
<Skeleton className="h-4" />
</TableCell>
<TableCell>
<Skeleton className="h-4" />
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
</LstCard>
</div>
<div className="m-2">
<CycleCountLog />
</div>
</div>
);
}

View File

@@ -23,6 +23,7 @@ import { Route as AuthProfileImport } from './routes/_auth/profile'
import { Route as AdminSettingsImport } from './routes/_admin/settings'
import { Route as AdminServersImport } from './routes/_admin/servers'
import { Route as AdminModulesImport } from './routes/_admin/modules'
import { Route as ocmeCyclecountIndexImport } from './routes/(ocme)/cyclecount/index'
import { Route as logisticsMaterialHelperIndexImport } from './routes/(logistics)/materialHelper/index'
import { Route as EomArticleAvImport } from './routes/_eom/article/$av'
import { Route as logisticsMaterialHelperSiloLinkIndexImport } from './routes/(logistics)/materialHelper/siloLink/index'
@@ -99,6 +100,12 @@ const AdminModulesRoute = AdminModulesImport.update({
getParentRoute: () => AdminRoute,
} as any)
const ocmeCyclecountIndexRoute = ocmeCyclecountIndexImport.update({
id: '/(ocme)/cyclecount/',
path: '/cyclecount/',
getParentRoute: () => rootRoute,
} as any)
const logisticsMaterialHelperIndexRoute =
logisticsMaterialHelperIndexImport.update({
id: '/(logistics)/materialHelper/',
@@ -228,6 +235,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof logisticsMaterialHelperIndexImport
parentRoute: typeof rootRoute
}
'/(ocme)/cyclecount/': {
id: '/(ocme)/cyclecount/'
path: '/cyclecount'
fullPath: '/cyclecount'
preLoaderRoute: typeof ocmeCyclecountIndexImport
parentRoute: typeof rootRoute
}
'/(logistics)/materialHelper/consumption/': {
id: '/(logistics)/materialHelper/consumption/'
path: '/materialHelper/consumption'
@@ -296,6 +310,7 @@ export interface FileRoutesByFullPath {
'/ocp': typeof OcpIndexRoute
'/article/$av': typeof EomArticleAvRoute
'/materialHelper': typeof logisticsMaterialHelperIndexRoute
'/cyclecount': typeof ocmeCyclecountIndexRoute
'/materialHelper/consumption': typeof logisticsMaterialHelperConsumptionIndexRoute
'/materialHelper/siloLink': typeof logisticsMaterialHelperSiloLinkIndexRoute
}
@@ -313,6 +328,7 @@ export interface FileRoutesByTo {
'/ocp': typeof OcpIndexRoute
'/article/$av': typeof EomArticleAvRoute
'/materialHelper': typeof logisticsMaterialHelperIndexRoute
'/cyclecount': typeof ocmeCyclecountIndexRoute
'/materialHelper/consumption': typeof logisticsMaterialHelperConsumptionIndexRoute
'/materialHelper/siloLink': typeof logisticsMaterialHelperSiloLinkIndexRoute
}
@@ -333,6 +349,7 @@ export interface FileRoutesById {
'/ocp/': typeof OcpIndexRoute
'/_eom/article/$av': typeof EomArticleAvRoute
'/(logistics)/materialHelper/': typeof logisticsMaterialHelperIndexRoute
'/(ocme)/cyclecount/': typeof ocmeCyclecountIndexRoute
'/(logistics)/materialHelper/consumption/': typeof logisticsMaterialHelperConsumptionIndexRoute
'/(logistics)/materialHelper/siloLink/': typeof logisticsMaterialHelperSiloLinkIndexRoute
}
@@ -352,6 +369,7 @@ export interface FileRouteTypes {
| '/ocp'
| '/article/$av'
| '/materialHelper'
| '/cyclecount'
| '/materialHelper/consumption'
| '/materialHelper/siloLink'
fileRoutesByTo: FileRoutesByTo
@@ -368,6 +386,7 @@ export interface FileRouteTypes {
| '/ocp'
| '/article/$av'
| '/materialHelper'
| '/cyclecount'
| '/materialHelper/consumption'
| '/materialHelper/siloLink'
id:
@@ -386,6 +405,7 @@ export interface FileRouteTypes {
| '/ocp/'
| '/_eom/article/$av'
| '/(logistics)/materialHelper/'
| '/(ocme)/cyclecount/'
| '/(logistics)/materialHelper/consumption/'
| '/(logistics)/materialHelper/siloLink/'
fileRoutesById: FileRoutesById
@@ -400,6 +420,7 @@ export interface RootRouteChildren {
LoginRoute: typeof LoginRoute
OcpIndexRoute: typeof OcpIndexRoute
logisticsMaterialHelperIndexRoute: typeof logisticsMaterialHelperIndexRoute
ocmeCyclecountIndexRoute: typeof ocmeCyclecountIndexRoute
logisticsMaterialHelperConsumptionIndexRoute: typeof logisticsMaterialHelperConsumptionIndexRoute
logisticsMaterialHelperSiloLinkIndexRoute: typeof logisticsMaterialHelperSiloLinkIndexRoute
}
@@ -413,6 +434,7 @@ const rootRouteChildren: RootRouteChildren = {
LoginRoute: LoginRoute,
OcpIndexRoute: OcpIndexRoute,
logisticsMaterialHelperIndexRoute: logisticsMaterialHelperIndexRoute,
ocmeCyclecountIndexRoute: ocmeCyclecountIndexRoute,
logisticsMaterialHelperConsumptionIndexRoute:
logisticsMaterialHelperConsumptionIndexRoute,
logisticsMaterialHelperSiloLinkIndexRoute:
@@ -437,6 +459,7 @@ export const routeTree = rootRoute
"/login",
"/ocp/",
"/(logistics)/materialHelper/",
"/(ocme)/cyclecount/",
"/(logistics)/materialHelper/consumption/",
"/(logistics)/materialHelper/siloLink/"
]
@@ -501,6 +524,9 @@ export const routeTree = rootRoute
"/(logistics)/materialHelper/": {
"filePath": "(logistics)/materialHelper/index.tsx"
},
"/(ocme)/cyclecount/": {
"filePath": "(ocme)/cyclecount/index.tsx"
},
"/(logistics)/materialHelper/consumption/": {
"filePath": "(logistics)/materialHelper/consumption/index.tsx"
},

View File

@@ -0,0 +1,14 @@
import OcmeCycleCount from "@/components/ocme/ocmeCycleCount";
import {createFileRoute} from "@tanstack/react-router";
export const Route = createFileRoute("/(ocme)/cyclecount/")({
component: RouteComponent,
});
function RouteComponent() {
return (
<div className="m-2">
<OcmeCycleCount />
</div>
);
}

View File

@@ -7,7 +7,7 @@ export function getlabels(hours: string) {
queryFn: () => fetchSettings(hours),
staleTime: 1000,
refetchInterval: 2500,
//refetchInterval: 2500,
refetchOnWindowFocus: true,
});
}
@@ -16,5 +16,5 @@ const fetchSettings = async (hours: string) => {
const {data} = await axios.get(`/api/v1/ocp/labels?hours=${hours}`);
// if we are not localhost ignore the devDir setting.
//const url: string = window.location.host.split(":")[0];
return data.data;
return data.data ?? [];
};

View File

@@ -7,7 +7,7 @@ export function getlots() {
queryFn: () => fetchSettings(),
staleTime: 10 * 1000,
refetchInterval: 10 * 1000,
//refetchInterval: 10 * 1000,
refetchOnWindowFocus: true,
});
}
@@ -17,5 +17,5 @@ const fetchSettings = async () => {
// if we are not localhost ignore the devDir setting.
//const url: string = window.location.host.split(":")[0];
let lotData = data.data;
return lotData;
return lotData ?? [];
};

View File

@@ -13,15 +13,13 @@ export function hasAccess(user: User | null, moduleName: string | null, modules:
}
export function hasPageAccess(user: User | null, role: any, module_id: string): boolean {
if (role.length === 0) return true;
if (role.includes("viewer")) return true;
if (!user) return false;
// get only the module in the user profile
const userRole = user?.roles.filter((role) => role.module_id === module_id);
if (role.includes(userRole[0]?.role)) {
return true;
}
if (role.includes(userRole[0]?.role)) return true;
return false;
}