fix(removed roles): changes to remove the roles and use userRoles instead
This commit is contained in:
@@ -2,15 +2,15 @@ import { LstCard } from "@/components/extendedUI/LstCard";
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import {
|
// import {
|
||||||
Select,
|
// Select,
|
||||||
SelectContent,
|
// SelectContent,
|
||||||
SelectGroup,
|
// SelectGroup,
|
||||||
SelectItem,
|
// SelectItem,
|
||||||
SelectLabel,
|
// SelectLabel,
|
||||||
SelectTrigger,
|
// SelectTrigger,
|
||||||
SelectValue,
|
// SelectValue,
|
||||||
} from "@/components/ui/select";
|
// } from "@/components/ui/select";
|
||||||
|
|
||||||
import { DebugButton } from "@/utils/formStuff/debugButton";
|
import { DebugButton } from "@/utils/formStuff/debugButton";
|
||||||
import { userFormOptions } from "@/utils/formStuff/options/userformOptions";
|
import { userFormOptions } from "@/utils/formStuff/options/userformOptions";
|
||||||
@@ -142,7 +142,7 @@ export default function UserCard(data: any) {
|
|||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<form.Field
|
{/* <form.Field
|
||||||
name="role"
|
name="role"
|
||||||
//listeners={{onChange: ({value})=>{}}}
|
//listeners={{onChange: ({value})=>{}}}
|
||||||
children={(field) => {
|
children={(field) => {
|
||||||
@@ -184,7 +184,7 @@ export default function UserCard(data: any) {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/> */}
|
||||||
<form.Field
|
<form.Field
|
||||||
name="password"
|
name="password"
|
||||||
validators={{
|
validators={{
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import { useQuery } from "@tanstack/react-query";
|
|||||||
import ManualPrint from "./ManualPrinting/ManualPrint";
|
import ManualPrint from "./ManualPrinting/ManualPrint";
|
||||||
import ManualPrintForm from "./ManualPrinting/ManualPrintForm";
|
import ManualPrintForm from "./ManualPrinting/ManualPrintForm";
|
||||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||||
|
import { useGetUserRoles } from "@/lib/store/useGetRoles";
|
||||||
|
import { useModuleStore } from "@/lib/store/useModuleStore";
|
||||||
|
|
||||||
let lotColumns = [
|
let lotColumns = [
|
||||||
{
|
{
|
||||||
@@ -68,12 +70,21 @@ export default function Lots() {
|
|||||||
const { data, isError, isLoading } = useQuery(getlots());
|
const { data, isError, isLoading } = useQuery(getlots());
|
||||||
const { user } = useSessionStore();
|
const { user } = useSessionStore();
|
||||||
const { settings } = useSettingStore();
|
const { settings } = useSettingStore();
|
||||||
|
const { userRoles } = useGetUserRoles();
|
||||||
|
const { modules } = useModuleStore();
|
||||||
|
|
||||||
const server = settings.filter((n) => n.name === "server")[0]?.value || "";
|
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 : [];
|
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;
|
//width = 1280;
|
||||||
const checkCol = lotColumns.some((l) => l.key === "printLabel");
|
const checkCol = lotColumns.some((l) => l.key === "printLabel");
|
||||||
if (!checkCol) {
|
if (!checkCol) {
|
||||||
@@ -230,22 +241,25 @@ export default function Lots() {
|
|||||||
<TableCell className="font-medium">
|
<TableCell className="font-medium">
|
||||||
{lot.overPrinting}
|
{lot.overPrinting}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
{user && roles.includes(user.role) && (
|
{user &&
|
||||||
<>
|
roles.includes(accessRoles[0].role) && (
|
||||||
{server === "usday1vms006" ||
|
<>
|
||||||
server === "localhost" ? (
|
{server === "usday1vms006" ||
|
||||||
<>
|
server === "localhost" ? (
|
||||||
|
<>
|
||||||
|
<TableCell className="flex justify-center">
|
||||||
|
<ManualPrintForm />
|
||||||
|
</TableCell>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
<TableCell className="flex justify-center">
|
<TableCell className="flex justify-center">
|
||||||
<ManualPrintForm />
|
<ManualPrint
|
||||||
|
lot={lot}
|
||||||
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</>
|
)}
|
||||||
) : (
|
</>
|
||||||
<TableCell className="flex justify-center">
|
)}
|
||||||
<ManualPrint lot={lot} />
|
|
||||||
</TableCell>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
))}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
|
|||||||
Reference in New Issue
Block a user