feat(modules): modules added to frontend
This commit is contained in:
@@ -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 { 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 = {
|
||||
title: string;
|
||||
url: string;
|
||||
icon: LucideIcon;
|
||||
role: UserRoles["role"][];
|
||||
module: string;
|
||||
active: boolean;
|
||||
title: string;
|
||||
url: string;
|
||||
icon: LucideIcon;
|
||||
role: UserRoles["role"][];
|
||||
module: string;
|
||||
active: boolean;
|
||||
};
|
||||
export default function Admin() {
|
||||
const items: Items[] = [
|
||||
{
|
||||
title: "Users",
|
||||
url: "/lst/app/admin/users",
|
||||
icon: User,
|
||||
role: ["systemAdmin", "admin"],
|
||||
module: "admin",
|
||||
active: true,
|
||||
},
|
||||
{
|
||||
title: "Settings",
|
||||
url: "/lst/app/admin/settings",
|
||||
icon: Settings,
|
||||
role: ["systemAdmin", "admin"],
|
||||
module: "admin",
|
||||
active: true,
|
||||
},
|
||||
{
|
||||
title: "Servers",
|
||||
url: "/lst/app/admin/servers",
|
||||
icon: Server,
|
||||
role: ["systemAdmin", "admin"],
|
||||
module: "admin",
|
||||
active: true,
|
||||
},
|
||||
];
|
||||
return (
|
||||
<SidebarGroup>
|
||||
<SidebarGroupLabel>Admin</SidebarGroupLabel>
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu>
|
||||
{items.map((item) => (
|
||||
<SidebarMenuItem key={item.title}>
|
||||
<>
|
||||
{userAccess(item.module, item.role) &&
|
||||
item.active && (
|
||||
<SidebarMenuButton asChild>
|
||||
<Link to={item.url}>
|
||||
<item.icon />
|
||||
<span>{item.title}</span>
|
||||
</Link>
|
||||
</SidebarMenuButton>
|
||||
)}
|
||||
</>
|
||||
</SidebarMenuItem>
|
||||
))}
|
||||
</SidebarMenu>
|
||||
</SidebarGroupContent>
|
||||
</SidebarGroup>
|
||||
);
|
||||
const items: Items[] = [
|
||||
{
|
||||
title: "Users",
|
||||
url: "/lst/app/admin/users",
|
||||
icon: User,
|
||||
role: ["systemAdmin", "admin"],
|
||||
module: "admin",
|
||||
active: true,
|
||||
},
|
||||
{
|
||||
title: "System",
|
||||
url: "/lst/app/admin/settings",
|
||||
icon: Settings,
|
||||
role: ["systemAdmin", "admin"],
|
||||
module: "admin",
|
||||
active: true,
|
||||
},
|
||||
{
|
||||
title: "Modules",
|
||||
url: "/lst/app/admin/modules",
|
||||
icon: Settings,
|
||||
role: ["systemAdmin", "admin"],
|
||||
module: "admin",
|
||||
active: true,
|
||||
},
|
||||
{
|
||||
title: "Servers",
|
||||
url: "/lst/app/admin/servers",
|
||||
icon: Server,
|
||||
role: ["systemAdmin", "admin"],
|
||||
module: "admin",
|
||||
active: true,
|
||||
},
|
||||
];
|
||||
return (
|
||||
<SidebarGroup>
|
||||
<SidebarGroupLabel>Admin</SidebarGroupLabel>
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu>
|
||||
{items.map((item) => (
|
||||
<SidebarMenuItem key={item.title}>
|
||||
<>
|
||||
{userAccess(item.module, item.role) && item.active && (
|
||||
<SidebarMenuButton asChild>
|
||||
<Link to={item.url}>
|
||||
<item.icon />
|
||||
<span>{item.title}</span>
|
||||
</Link>
|
||||
</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 MobileMobileLayoutMDeliveryRouteImport } from './routes/_mobile/_mobileLayout/m/delivery'
|
||||
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 ApplogisticsLogisticsDeliveryScheduleRouteImport } from './routes/_app/(logistics)/logistics/deliverySchedule'
|
||||
import { Route as AppauthUserSignupRouteImport } from './routes/_app/(auth)/user/signup'
|
||||
import { Route as AppauthUserResetpasswordRouteImport } from './routes/_app/(auth)/user/resetpassword'
|
||||
import { Route as AppauthUserProfileRouteImport } from './routes/_app/(auth)/user/profile'
|
||||
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 OldOldlogisticsSiloAdjustmentsIndexRouteImport } from './routes/_old/old/(logistics)/siloAdjustments/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 AppAdminLayoutAdminUsersUsersRouteImport } from './routes/_app/_adminLayout/admin/_users/users'
|
||||
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 OldOldlogisticsSiloAdjustmentsCommentCommentRouteImport } from './routes/_old/old/(logistics)/siloAdjustments/comment/$comment'
|
||||
|
||||
@@ -130,12 +132,6 @@ const MobileMobileLayoutMCyclecountsRoute =
|
||||
path: '/m/cyclecounts',
|
||||
getParentRoute: () => MobileMobileLayoutRouteRoute,
|
||||
} as any)
|
||||
const AppAdminLayoutAdminSettingsRoute =
|
||||
AppAdminLayoutAdminSettingsRouteImport.update({
|
||||
id: '/settings',
|
||||
path: '/settings',
|
||||
getParentRoute: () => AppAdminLayoutAdminRoute,
|
||||
} as any)
|
||||
const AppAdminLayoutAdminServersRoute =
|
||||
AppAdminLayoutAdminServersRouteImport.update({
|
||||
id: '/servers',
|
||||
@@ -169,6 +165,11 @@ const AppAdminLayoutAdminUsersRouteRoute =
|
||||
id: '/_users',
|
||||
getParentRoute: () => AppAdminLayoutAdminRoute,
|
||||
} as any)
|
||||
const AppAdminLayoutAdminSystemRouteRoute =
|
||||
AppAdminLayoutAdminSystemRouteRouteImport.update({
|
||||
id: '/_system',
|
||||
getParentRoute: () => AppAdminLayoutAdminRoute,
|
||||
} as any)
|
||||
const OldOldocmeCyclecountIndexRoute =
|
||||
OldOldocmeCyclecountIndexRouteImport.update({
|
||||
id: '/(ocme)/cyclecount/',
|
||||
@@ -222,6 +223,18 @@ const AppAdminLayoutAdminUsersProdUsersRoute =
|
||||
path: '/prodUsers',
|
||||
getParentRoute: () => AppAdminLayoutAdminUsersRouteRoute,
|
||||
} 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 =
|
||||
OldOldlogisticsMaterialHelperConsumptionIndexRouteImport.update({
|
||||
id: '/(logistics)/materialHelper/consumption/',
|
||||
@@ -247,7 +260,6 @@ export interface FileRoutesByFullPath {
|
||||
'/user/signup': typeof AppauthUserSignupRoute
|
||||
'/logistics/deliverySchedule': typeof ApplogisticsLogisticsDeliveryScheduleRoute
|
||||
'/admin/servers': typeof AppAdminLayoutAdminServersRoute
|
||||
'/admin/settings': typeof AppAdminLayoutAdminSettingsRoute
|
||||
'/m/cyclecounts': typeof MobileMobileLayoutMCyclecountsRoute
|
||||
'/m/delivery': typeof MobileMobileLayoutMDeliveryRoute
|
||||
'/m/relocate': typeof MobileMobileLayoutMRelocateRoute
|
||||
@@ -255,6 +267,8 @@ export interface FileRoutesByFullPath {
|
||||
'/m': typeof MobileMobileLayoutMIndexRoute
|
||||
'/old/ocp': typeof OldOldOcpIndexRoute
|
||||
'/old/rfid': typeof OldOldRfidIndexRoute
|
||||
'/admin/modules': typeof AppAdminLayoutAdminSystemModulesRoute
|
||||
'/admin/settings': typeof AppAdminLayoutAdminSystemSettingsRoute
|
||||
'/admin/prodUsers': typeof AppAdminLayoutAdminUsersProdUsersRoute
|
||||
'/admin/users': typeof AppAdminLayoutAdminUsersUsersRoute
|
||||
'/old/siloAdjustments/$hist': typeof OldOldlogisticsSiloAdjustmentsHistRoute
|
||||
@@ -278,7 +292,6 @@ export interface FileRoutesByTo {
|
||||
'/user/signup': typeof AppauthUserSignupRoute
|
||||
'/logistics/deliverySchedule': typeof ApplogisticsLogisticsDeliveryScheduleRoute
|
||||
'/admin/servers': typeof AppAdminLayoutAdminServersRoute
|
||||
'/admin/settings': typeof AppAdminLayoutAdminSettingsRoute
|
||||
'/m/cyclecounts': typeof MobileMobileLayoutMCyclecountsRoute
|
||||
'/m/delivery': typeof MobileMobileLayoutMDeliveryRoute
|
||||
'/m/relocate': typeof MobileMobileLayoutMRelocateRoute
|
||||
@@ -286,6 +299,8 @@ export interface FileRoutesByTo {
|
||||
'/m': typeof MobileMobileLayoutMIndexRoute
|
||||
'/old/ocp': typeof OldOldOcpIndexRoute
|
||||
'/old/rfid': typeof OldOldRfidIndexRoute
|
||||
'/admin/modules': typeof AppAdminLayoutAdminSystemModulesRoute
|
||||
'/admin/settings': typeof AppAdminLayoutAdminSystemSettingsRoute
|
||||
'/admin/prodUsers': typeof AppAdminLayoutAdminUsersProdUsersRoute
|
||||
'/admin/users': typeof AppAdminLayoutAdminUsersUsersRoute
|
||||
'/old/siloAdjustments/$hist': typeof OldOldlogisticsSiloAdjustmentsHistRoute
|
||||
@@ -309,13 +324,13 @@ export interface FileRoutesById {
|
||||
'/_app/(auth)/login': typeof AppauthLoginRoute
|
||||
'/_old/old/': typeof OldOldIndexRoute
|
||||
'/_app/_adminLayout/admin': typeof AppAdminLayoutAdminRouteWithChildren
|
||||
'/_app/_adminLayout/admin/_system': typeof AppAdminLayoutAdminSystemRouteRouteWithChildren
|
||||
'/_app/_adminLayout/admin/_users': typeof AppAdminLayoutAdminUsersRouteRouteWithChildren
|
||||
'/_app/(auth)/user/profile': typeof AppauthUserProfileRoute
|
||||
'/_app/(auth)/user/resetpassword': typeof AppauthUserResetpasswordRoute
|
||||
'/_app/(auth)/user/signup': typeof AppauthUserSignupRoute
|
||||
'/_app/(logistics)/logistics/deliverySchedule': typeof ApplogisticsLogisticsDeliveryScheduleRoute
|
||||
'/_app/_adminLayout/admin/servers': typeof AppAdminLayoutAdminServersRoute
|
||||
'/_app/_adminLayout/admin/settings': typeof AppAdminLayoutAdminSettingsRoute
|
||||
'/_mobile/_mobileLayout/m/cyclecounts': typeof MobileMobileLayoutMCyclecountsRoute
|
||||
'/_mobile/_mobileLayout/m/delivery': typeof MobileMobileLayoutMDeliveryRoute
|
||||
'/_mobile/_mobileLayout/m/relocate': typeof MobileMobileLayoutMRelocateRoute
|
||||
@@ -323,6 +338,8 @@ export interface FileRoutesById {
|
||||
'/_mobile/_mobileLayout/m/': typeof MobileMobileLayoutMIndexRoute
|
||||
'/_old/old/ocp/': typeof OldOldOcpIndexRoute
|
||||
'/_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/users': typeof AppAdminLayoutAdminUsersUsersRoute
|
||||
'/_old/old/(logistics)/siloAdjustments/$hist': typeof OldOldlogisticsSiloAdjustmentsHistRoute
|
||||
@@ -349,7 +366,6 @@ export interface FileRouteTypes {
|
||||
| '/user/signup'
|
||||
| '/logistics/deliverySchedule'
|
||||
| '/admin/servers'
|
||||
| '/admin/settings'
|
||||
| '/m/cyclecounts'
|
||||
| '/m/delivery'
|
||||
| '/m/relocate'
|
||||
@@ -357,6 +373,8 @@ export interface FileRouteTypes {
|
||||
| '/m'
|
||||
| '/old/ocp'
|
||||
| '/old/rfid'
|
||||
| '/admin/modules'
|
||||
| '/admin/settings'
|
||||
| '/admin/prodUsers'
|
||||
| '/admin/users'
|
||||
| '/old/siloAdjustments/$hist'
|
||||
@@ -380,7 +398,6 @@ export interface FileRouteTypes {
|
||||
| '/user/signup'
|
||||
| '/logistics/deliverySchedule'
|
||||
| '/admin/servers'
|
||||
| '/admin/settings'
|
||||
| '/m/cyclecounts'
|
||||
| '/m/delivery'
|
||||
| '/m/relocate'
|
||||
@@ -388,6 +405,8 @@ export interface FileRouteTypes {
|
||||
| '/m'
|
||||
| '/old/ocp'
|
||||
| '/old/rfid'
|
||||
| '/admin/modules'
|
||||
| '/admin/settings'
|
||||
| '/admin/prodUsers'
|
||||
| '/admin/users'
|
||||
| '/old/siloAdjustments/$hist'
|
||||
@@ -410,13 +429,13 @@ export interface FileRouteTypes {
|
||||
| '/_app/(auth)/login'
|
||||
| '/_old/old/'
|
||||
| '/_app/_adminLayout/admin'
|
||||
| '/_app/_adminLayout/admin/_system'
|
||||
| '/_app/_adminLayout/admin/_users'
|
||||
| '/_app/(auth)/user/profile'
|
||||
| '/_app/(auth)/user/resetpassword'
|
||||
| '/_app/(auth)/user/signup'
|
||||
| '/_app/(logistics)/logistics/deliverySchedule'
|
||||
| '/_app/_adminLayout/admin/servers'
|
||||
| '/_app/_adminLayout/admin/settings'
|
||||
| '/_mobile/_mobileLayout/m/cyclecounts'
|
||||
| '/_mobile/_mobileLayout/m/delivery'
|
||||
| '/_mobile/_mobileLayout/m/relocate'
|
||||
@@ -424,6 +443,8 @@ export interface FileRouteTypes {
|
||||
| '/_mobile/_mobileLayout/m/'
|
||||
| '/_old/old/ocp/'
|
||||
| '/_old/old/rfid/'
|
||||
| '/_app/_adminLayout/admin/_system/modules'
|
||||
| '/_app/_adminLayout/admin/_system/settings'
|
||||
| '/_app/_adminLayout/admin/_users/prodUsers'
|
||||
| '/_app/_adminLayout/admin/_users/users'
|
||||
| '/_old/old/(logistics)/siloAdjustments/$hist'
|
||||
@@ -557,13 +578,6 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof MobileMobileLayoutMCyclecountsRouteImport
|
||||
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': {
|
||||
id: '/_app/_adminLayout/admin/servers'
|
||||
path: '/servers'
|
||||
@@ -601,11 +615,18 @@ declare module '@tanstack/react-router' {
|
||||
}
|
||||
'/_app/_adminLayout/admin/_users': {
|
||||
id: '/_app/_adminLayout/admin/_users'
|
||||
path: '/admin'
|
||||
path: ''
|
||||
fullPath: '/admin'
|
||||
preLoaderRoute: typeof AppAdminLayoutAdminUsersRouteRouteImport
|
||||
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/': {
|
||||
id: '/_old/old/(ocme)/cyclecount/'
|
||||
path: '/cyclecount'
|
||||
@@ -669,6 +690,20 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof AppAdminLayoutAdminUsersProdUsersRouteImport
|
||||
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/': {
|
||||
id: '/_old/old/(logistics)/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 {
|
||||
AppAdminLayoutAdminUsersProdUsersRoute: typeof AppAdminLayoutAdminUsersProdUsersRoute
|
||||
AppAdminLayoutAdminUsersUsersRoute: typeof AppAdminLayoutAdminUsersUsersRoute
|
||||
@@ -704,16 +757,17 @@ const AppAdminLayoutAdminUsersRouteRouteWithChildren =
|
||||
)
|
||||
|
||||
interface AppAdminLayoutAdminRouteChildren {
|
||||
AppAdminLayoutAdminSystemRouteRoute: typeof AppAdminLayoutAdminSystemRouteRouteWithChildren
|
||||
AppAdminLayoutAdminUsersRouteRoute: typeof AppAdminLayoutAdminUsersRouteRouteWithChildren
|
||||
AppAdminLayoutAdminServersRoute: typeof AppAdminLayoutAdminServersRoute
|
||||
AppAdminLayoutAdminSettingsRoute: typeof AppAdminLayoutAdminSettingsRoute
|
||||
}
|
||||
|
||||
const AppAdminLayoutAdminRouteChildren: AppAdminLayoutAdminRouteChildren = {
|
||||
AppAdminLayoutAdminSystemRouteRoute:
|
||||
AppAdminLayoutAdminSystemRouteRouteWithChildren,
|
||||
AppAdminLayoutAdminUsersRouteRoute:
|
||||
AppAdminLayoutAdminUsersRouteRouteWithChildren,
|
||||
AppAdminLayoutAdminServersRoute: AppAdminLayoutAdminServersRoute,
|
||||
AppAdminLayoutAdminSettingsRoute: AppAdminLayoutAdminSettingsRoute,
|
||||
}
|
||||
|
||||
const AppAdminLayoutAdminRouteWithChildren =
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { Button } from "../../../../components/ui/button";
|
||||
import { Button } from "../../../../../components/ui/button";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "../../../../components/ui/select";
|
||||
import { api } from "../../../../lib/axiosAPI";
|
||||
} from "../../../../../components/ui/select";
|
||||
import { api } from "../../../../../lib/axiosAPI";
|
||||
|
||||
const modules: string[] = [
|
||||
"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,
|
||||
} from "../../../../../components/ui/table";
|
||||
import { getUsers } from "../../../../../lib/querys/admin/getUsers";
|
||||
import ExpandedRow from "../../-components/ExpandedRow";
|
||||
import ExpandedRow from "../../-components/users/ExpandedRow";
|
||||
|
||||
type User = {
|
||||
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 = {
|
||||
Printer: Printer,
|
||||
Tag: Tag,
|
||||
|
||||
Cat: Cat,
|
||||
};
|
||||
|
||||
@@ -29,9 +28,8 @@ export function ProductionSideBar({
|
||||
//const url: string = window.location.host.split(":")[0];
|
||||
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 };
|
||||
|
||||
return (
|
||||
<SidebarGroup>
|
||||
<SidebarGroupLabel>Production</SidebarGroupLabel>
|
||||
|
||||
Reference in New Issue
Block a user