fix(removed roles): changes to remove the roles and use userRoles instead

This commit is contained in:
2025-06-11 20:47:43 -05:00
parent aadf255e34
commit 826c44c996
2 changed files with 41 additions and 27 deletions

View File

@@ -2,15 +2,15 @@ import { LstCard } from "@/components/extendedUI/LstCard";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
// import {
// Select,
// SelectContent,
// SelectGroup,
// SelectItem,
// SelectLabel,
// SelectTrigger,
// SelectValue,
// } from "@/components/ui/select";
import { DebugButton } from "@/utils/formStuff/debugButton";
import { userFormOptions } from "@/utils/formStuff/options/userformOptions";
@@ -142,7 +142,7 @@ export default function UserCard(data: any) {
);
}}
/>
<form.Field
{/* <form.Field
name="role"
//listeners={{onChange: ({value})=>{}}}
children={(field) => {
@@ -184,7 +184,7 @@ export default function UserCard(data: any) {
</div>
);
}}
/>
/> */}
<form.Field
name="password"
validators={{

View File

@@ -17,6 +17,8 @@ import { useQuery } from "@tanstack/react-query";
import ManualPrint from "./ManualPrinting/ManualPrint";
import ManualPrintForm from "./ManualPrinting/ManualPrintForm";
import { ScrollArea } from "@/components/ui/scroll-area";
import { useGetUserRoles } from "@/lib/store/useGetRoles";
import { useModuleStore } from "@/lib/store/useModuleStore";
let lotColumns = [
{
@@ -68,12 +70,21 @@ export default function Lots() {
const { data, isError, isLoading } = useQuery(getlots());
const { user } = useSessionStore();
const { settings } = useSettingStore();
const { userRoles } = useGetUserRoles();
const { modules } = useModuleStore();
const server = settings.filter((n) => n.name === "server")[0]?.value || "";
const roles = ["technician", "admin", "manager", "operator"];
const roles = ["systemAdmin", "technician", "admin", "manager", "operator"];
const lotdata = data ? data : [];
if (user && roles.includes(user.role)) {
const module = modules.filter((n) => n.name === "logistics");
const accessRoles = userRoles.filter(
(n) => n.module_id === module[0]?.module_id
) as any;
if (user && roles.includes(accessRoles[0]?.role)) {
//width = 1280;
const checkCol = lotColumns.some((l) => l.key === "printLabel");
if (!checkCol) {
@@ -230,22 +241,25 @@ export default function Lots() {
<TableCell className="font-medium">
{lot.overPrinting}
</TableCell>
{user && roles.includes(user.role) && (
<>
{server === "usday1vms006" ||
server === "localhost" ? (
<>
{user &&
roles.includes(accessRoles[0].role) && (
<>
{server === "usday1vms006" ||
server === "localhost" ? (
<>
<TableCell className="flex justify-center">
<ManualPrintForm />
</TableCell>
</>
) : (
<TableCell className="flex justify-center">
<ManualPrintForm />
<ManualPrint
lot={lot}
/>
</TableCell>
</>
) : (
<TableCell className="flex justify-center">
<ManualPrint lot={lot} />
</TableCell>
)}
</>
)}
)}
</>
)}
</TableRow>
))}
</TableBody>