refactor(rfid): ratio resets implemeneted
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Printer } from "lucide-react";
|
||||
import { Printer, Tag } from "lucide-react";
|
||||
import {
|
||||
SidebarGroup,
|
||||
SidebarGroupContent,
|
||||
@@ -10,34 +10,6 @@ import {
|
||||
import { hasPageAccess } from "@/utils/userAccess";
|
||||
import { User } from "@/types/users";
|
||||
|
||||
const items = [
|
||||
{
|
||||
title: "One Click Print",
|
||||
url: "/ocp",
|
||||
icon: Printer,
|
||||
role: ["viewer"],
|
||||
module: "ocp",
|
||||
active: true,
|
||||
},
|
||||
{
|
||||
title: "RFID",
|
||||
moduleName: "prodcution",
|
||||
description: "RFID stuff",
|
||||
url: "/rfid",
|
||||
icon: "Tags",
|
||||
active: true,
|
||||
roles: [
|
||||
"viewer",
|
||||
"technician",
|
||||
"supervisor",
|
||||
"manager",
|
||||
"admin",
|
||||
"systemAdmin",
|
||||
],
|
||||
subSubModule: [],
|
||||
},
|
||||
];
|
||||
|
||||
export function ProductionSideBar({
|
||||
user,
|
||||
moduleID,
|
||||
@@ -45,6 +17,26 @@ export function ProductionSideBar({
|
||||
user: User | null;
|
||||
moduleID: string;
|
||||
}) {
|
||||
const url: string = window.location.host.split(":")[0];
|
||||
const items = [
|
||||
{
|
||||
title: "One Click Print",
|
||||
url: "/ocp",
|
||||
icon: Printer,
|
||||
role: ["viewer"],
|
||||
module: "ocp",
|
||||
active: true,
|
||||
},
|
||||
{
|
||||
title: "Rfid Readers",
|
||||
url: "/rfid",
|
||||
icon: Tag,
|
||||
role: ["viewer"],
|
||||
module: "production",
|
||||
active:
|
||||
url === "usday1vms006" || url === "localhost" ? true : false,
|
||||
},
|
||||
];
|
||||
return (
|
||||
<SidebarGroup>
|
||||
<SidebarGroupLabel>Production</SidebarGroupLabel>
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
//import { fixTime } from "@/utils/fixTime";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { getReaders } from "@/utils/querys/rfid/getReaders";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { ColumnDef } from "@tanstack/react-table";
|
||||
import axios from "axios";
|
||||
import { format } from "date-fns-tz";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
// This type is used to define the shape of our data.
|
||||
// You can use a Zod schema here if you want.
|
||||
@@ -94,4 +100,49 @@ export const readerColumns: ColumnDef<Readers>[] = [
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "reset",
|
||||
header: "Reset Reads",
|
||||
cell: ({ row }) => {
|
||||
const { refetch } = useQuery(getReaders());
|
||||
const [readerReset, setReaderReset] = useState(false);
|
||||
// const goodRatio =
|
||||
// (parseInt(row.getValue("goodReads")) /
|
||||
// (parseInt(row.getValue("goodReads")) +
|
||||
// parseInt(row.getValue("badReads")))) *
|
||||
// 100;
|
||||
const name = row.getValue("reader");
|
||||
const resetReads = async () => {
|
||||
setReaderReset(true);
|
||||
try {
|
||||
const res = await axios.post("/api/rfid/resetRatio", {
|
||||
reader: name,
|
||||
});
|
||||
|
||||
if (res.status === 200) {
|
||||
toast.success(res.data.message);
|
||||
setReaderReset(false);
|
||||
} else {
|
||||
toast.error(res.data.message);
|
||||
setReaderReset(false);
|
||||
}
|
||||
} catch (error: any) {
|
||||
toast.error(error.data.message);
|
||||
setReaderReset(false);
|
||||
}
|
||||
refetch();
|
||||
};
|
||||
return (
|
||||
<div className="text-left font-medium">
|
||||
<Button
|
||||
className="h-4"
|
||||
onClick={resetReads}
|
||||
disabled={readerReset}
|
||||
>
|
||||
Reset Reads
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user