-
Notifications
You must be signed in to change notification settings - Fork 256
Expand file tree
/
Copy pathuseModules.tsx
More file actions
126 lines (123 loc) · 2.47 KB
/
useModules.tsx
File metadata and controls
126 lines (123 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import {
LuBox,
LuCrown,
LuFactory,
LuFiles,
LuFolderCheck,
LuLandmark,
LuPrinter,
LuSettings,
LuShield,
LuShoppingCart,
LuSquareStack,
LuTvMinimalPlay,
LuUsers,
LuWrench
} from "react-icons/lu";
import type { Authenticated, NavItem } from "~/types";
import { path } from "~/utils/path";
import { usePermissions } from "./usePermissions";
export function useModules() {
const permissions = usePermissions();
const modules: Authenticated<NavItem>[] = [
{
name: "Shop Floor",
to: path.to.external.mes,
icon: LuTvMinimalPlay,
role: "employee"
},
{
permission: "sales",
name: "Sales",
to: path.to.sales,
icon: LuCrown
},
{
permission: "production",
name: "Production",
to: path.to.production,
icon: LuFactory
},
{
permission: "parts",
name: "Items",
to: path.to.parts,
icon: LuSquareStack
},
{
permission: "inventory",
name: "Inventory",
to: path.to.inventory,
icon: LuBox
},
{
permission: "purchasing",
name: "Purchasing",
to: path.to.purchasing,
icon: LuShoppingCart
},
{
permission: "quality",
name: "Quality",
to: path.to.quality,
icon: LuFolderCheck
},
{
permission: "accounting",
name: "Finance",
to: path.to.currencies,
icon: LuLandmark
},
// {
// permission: "invoicing",
// name: "Invoicing",
// to: path.to.purchaseInvoices,
// icon: LuCreditCard,
// },
{
permission: "people",
name: "People",
to: path.to.people,
icon: LuUsers
},
{
permission: "resources",
name: "Resources",
to: path.to.resources,
icon: LuWrench
},
{
permission: "documents",
name: "Documents",
to: path.to.documents,
icon: LuFiles
},
{
permission: "printing",
name: "Print Manager",
to: path.to.printManager,
icon: LuPrinter
},
{
permission: "users",
name: "Users",
to: path.to.employeeAccounts,
icon: LuShield
},
{
permission: "settings",
name: "Settings",
to: path.to.company,
icon: LuSettings
}
];
return modules.filter((item) => {
if (item.permission) {
return permissions.can("view", item.permission);
} else if (item.role) {
return permissions.is(item.role);
} else {
return true;
}
});
}