@visns-studio/visns-components 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/crm/visns-navigation.jsx +220 -219
- package/package.json +53 -53
|
@@ -1,230 +1,231 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
|
-
import { Link, useLocation } from "react-router-dom";
|
|
2
|
+
import { Link, useLocation, useNavigate } from "react-router-dom";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
ArrowCycle,
|
|
5
|
+
BookClose,
|
|
6
|
+
Bug,
|
|
7
|
+
Calendar,
|
|
8
|
+
Clipboard,
|
|
9
|
+
DoubleSword,
|
|
10
|
+
Draft,
|
|
11
|
+
Grid,
|
|
12
|
+
LightBulb,
|
|
13
|
+
PeopleGroup,
|
|
14
|
+
Person,
|
|
15
|
+
SettingsVertical,
|
|
16
|
+
SignOut,
|
|
17
|
+
Shield,
|
|
18
|
+
Ticket,
|
|
19
19
|
} from "akar-icons";
|
|
20
20
|
|
|
21
21
|
import CustomFetch from "./visns-fetch";
|
|
22
22
|
import Notification from "./visns-notification";
|
|
23
23
|
|
|
24
24
|
function Navigation({ logo, logout, navConfig, setSystemAuth, userProfile }) {
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
25
|
+
const location = useLocation();
|
|
26
|
+
const navigate = useNavigate();
|
|
27
|
+
const currentPage = location.pathname.substr(1) || "dashboard";
|
|
28
|
+
const [navData, setNavData] = useState(navConfig);
|
|
29
|
+
const [isScrolled, setIsScrolled] = useState(false);
|
|
30
|
+
const appNavClasses = `app-nav ${isScrolled ? "navscrolled" : ""}`;
|
|
31
|
+
|
|
32
|
+
const handleLogout = () => {
|
|
33
|
+
CustomFetch("/logout", "GET", {}, () => {
|
|
34
|
+
setSystemAuth(false);
|
|
35
|
+
navigate("/login");
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const renderSetting = (n) => {
|
|
40
|
+
const iconComponents = {
|
|
41
|
+
bug: Bug,
|
|
42
|
+
calendar: Calendar,
|
|
43
|
+
person: Person,
|
|
44
|
+
shield: Shield,
|
|
45
|
+
signOut: SignOut,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (n.id === "notifications") {
|
|
49
|
+
return (
|
|
50
|
+
<li>
|
|
51
|
+
<Notification setSystemAuth={setSystemAuth} />
|
|
52
|
+
</li>
|
|
53
|
+
);
|
|
54
|
+
} else if (n.id === "logout") {
|
|
55
|
+
const IconComponent = iconComponents[n.icon];
|
|
56
|
+
return (
|
|
57
|
+
<li>
|
|
58
|
+
<button
|
|
59
|
+
title={n.label}
|
|
60
|
+
data-tooltip-id="system-tooltip"
|
|
61
|
+
data-tooltip-content={n.label}
|
|
62
|
+
onClick={handleLogout}
|
|
63
|
+
>
|
|
64
|
+
<IconComponent size={19} strokeWidth={2} />
|
|
65
|
+
</button>
|
|
66
|
+
</li>
|
|
67
|
+
);
|
|
68
|
+
} else {
|
|
69
|
+
const IconComponent = iconComponents[n.icon];
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<li>
|
|
73
|
+
<Link
|
|
74
|
+
to={n.url}
|
|
75
|
+
data-tooltip-id="system-tooltip"
|
|
76
|
+
data-tooltip-content={n.label}
|
|
77
|
+
className="tooltip"
|
|
78
|
+
target={n.target ? n.target : "_self"}
|
|
79
|
+
>
|
|
80
|
+
<IconComponent size={19} strokeWidth={2} />
|
|
81
|
+
</Link>
|
|
82
|
+
</li>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const renderNav = (n) => {
|
|
88
|
+
const iconComponents = {
|
|
89
|
+
arrowCycle: ArrowCycle,
|
|
90
|
+
bookClose: BookClose,
|
|
91
|
+
calendar: Calendar,
|
|
92
|
+
clipboard: Clipboard,
|
|
93
|
+
doubleSword: DoubleSword,
|
|
94
|
+
draft: Draft,
|
|
95
|
+
grid: Grid,
|
|
96
|
+
lightBulb: LightBulb,
|
|
97
|
+
peopleGroup: PeopleGroup,
|
|
98
|
+
settingsVertical: SettingsVertical,
|
|
99
|
+
ticket: Ticket,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const IconComponent = iconComponents[n.icon];
|
|
103
|
+
|
|
104
|
+
const renderChildren = () => {
|
|
105
|
+
if (n.children && n.children.length > 0) {
|
|
106
|
+
return (
|
|
107
|
+
<ul>
|
|
108
|
+
{n.children.map((child, childKey) => (
|
|
109
|
+
<li
|
|
110
|
+
className="sub-nav-item"
|
|
111
|
+
key={`nav-child-${childKey}`}
|
|
112
|
+
>
|
|
113
|
+
<Link to={child.url} title={child.label}>
|
|
114
|
+
{child.label}
|
|
115
|
+
</Link>
|
|
116
|
+
</li>
|
|
117
|
+
))}
|
|
118
|
+
</ul>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<li className={n.class}>
|
|
126
|
+
{n.url ? (
|
|
127
|
+
<Link to={n.url}>
|
|
128
|
+
<IconComponent strokeWidth={2} size={18} />
|
|
129
|
+
{n.label}
|
|
130
|
+
</Link>
|
|
131
|
+
) : (
|
|
132
|
+
<span title={n.label}>
|
|
133
|
+
<IconComponent strokeWidth={2} size={18} />
|
|
134
|
+
{n.label}
|
|
135
|
+
</span>
|
|
136
|
+
)}
|
|
137
|
+
{renderChildren()}
|
|
138
|
+
</li>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
const permissions = userProfile.roles[0].permissions;
|
|
144
|
+
|
|
145
|
+
setNavData((prevNavData) => {
|
|
146
|
+
const updatePermissions = (nav) => {
|
|
147
|
+
const matchingPermission = permissions.find(
|
|
148
|
+
(permission) => permission.name === nav.permissionKey
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
if (matchingPermission) {
|
|
152
|
+
return {
|
|
153
|
+
...nav,
|
|
154
|
+
permission: true,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return nav;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const updatedNavigations =
|
|
162
|
+
prevNavData.navigations.map(updatePermissions);
|
|
163
|
+
const updatedSettings = prevNavData.settings.map(updatePermissions);
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
...prevNavData,
|
|
167
|
+
navigations: updatedNavigations,
|
|
168
|
+
settings: updatedSettings,
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
}, [userProfile]);
|
|
172
|
+
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
setNavData((prevNavData) => ({
|
|
175
|
+
...prevNavData,
|
|
176
|
+
navigations: prevNavData.navigations.map((nav) =>
|
|
177
|
+
nav.id === currentPage
|
|
178
|
+
? { ...nav, class: "nav-item active" }
|
|
179
|
+
: { ...nav, class: "nav-item" }
|
|
180
|
+
),
|
|
181
|
+
}));
|
|
182
|
+
}, [currentPage]);
|
|
183
|
+
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
function handleScroll() {
|
|
186
|
+
setIsScrolled(window.scrollY > 0);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
window.addEventListener("scroll", handleScroll);
|
|
190
|
+
return () => {
|
|
191
|
+
window.removeEventListener("scroll", handleScroll);
|
|
192
|
+
};
|
|
193
|
+
}, []);
|
|
194
|
+
|
|
195
|
+
return (
|
|
196
|
+
<header className="header">
|
|
197
|
+
<div className="hwrap">
|
|
198
|
+
<div className="logo">
|
|
199
|
+
<Link to="/">
|
|
200
|
+
<img src={logo} alt="Visns Studio CRM" />
|
|
201
|
+
</Link>
|
|
202
|
+
</div>
|
|
203
|
+
<div className="navwrap">
|
|
204
|
+
<ul className={appNavClasses}>
|
|
205
|
+
{navData.navigations.map((nav, navKey) =>
|
|
206
|
+
nav.permission === true ||
|
|
207
|
+
nav.permissionKey === "" ? (
|
|
208
|
+
<React.Fragment key={`nav-item-${navKey}`}>
|
|
209
|
+
{renderNav(nav)}
|
|
210
|
+
</React.Fragment>
|
|
211
|
+
) : null
|
|
212
|
+
)}
|
|
213
|
+
</ul>
|
|
214
|
+
</div>
|
|
215
|
+
<div className="hactions">
|
|
216
|
+
<ul>
|
|
217
|
+
{navData.settings.map((setting, settingKey) =>
|
|
218
|
+
setting.permission === true ? (
|
|
219
|
+
<React.Fragment key={`setting-${settingKey}`}>
|
|
220
|
+
{renderSetting(setting)}
|
|
221
|
+
</React.Fragment>
|
|
222
|
+
) : null
|
|
223
|
+
)}
|
|
224
|
+
</ul>
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
</header>
|
|
228
|
+
);
|
|
228
229
|
}
|
|
229
230
|
|
|
230
231
|
export default Navigation;
|
package/package.json
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
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
|
-
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@inovua/reactdatagrid-community": "^5.9.4",
|
|
4
|
+
"@inovua/reactdatagrid-enterprise": "^5.9.4",
|
|
5
|
+
"akar-icons": "^1.9.28",
|
|
6
|
+
"awesome-debounce-promise": "^2.1.0",
|
|
7
|
+
"axios": "^1.4.0",
|
|
8
|
+
"framer-motion": "^10.12.16",
|
|
9
|
+
"html-react-parser": "^4.0.0",
|
|
10
|
+
"lodash": "^4.17.21",
|
|
11
|
+
"moment": "^2.29.4",
|
|
12
|
+
"numeral": "^2.0.6",
|
|
13
|
+
"quill-image-uploader": "^1.3.0",
|
|
14
|
+
"react-confirm-alert": "^3.0.6",
|
|
15
|
+
"react-datepicker": "^4.14.0",
|
|
16
|
+
"react-dropzone": "^14.2.3",
|
|
17
|
+
"react-number-format": "^5.2.2",
|
|
18
|
+
"react-promise-tracker": "^2.1.1",
|
|
19
|
+
"react-quill": "^2.0.0",
|
|
20
|
+
"react-select": "^5.7.3",
|
|
21
|
+
"react-slugify": "^3.0.2",
|
|
22
|
+
"react-sortable-hoc": "^2.0.0",
|
|
23
|
+
"react-toastify": "^9.1.3",
|
|
24
|
+
"react-toggle": "^4.1.3",
|
|
25
|
+
"react-tooltip": "^5.14.0",
|
|
26
|
+
"react-window": "^1.8.9",
|
|
27
|
+
"reactjs-popup": "^2.0.5"
|
|
28
|
+
},
|
|
29
|
+
"devDependecies": {
|
|
30
|
+
"react": "^18.2.0",
|
|
31
|
+
"react-dom": "^18.2.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": "^17.0.1",
|
|
35
|
+
"react-dom": "^17.0.1"
|
|
36
|
+
},
|
|
37
|
+
"name": "@visns-studio/visns-components",
|
|
38
|
+
"version": "1.5.4",
|
|
39
|
+
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
40
|
+
"main": "index.js",
|
|
41
|
+
"devDependencies": {},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
44
|
+
},
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/visnsstudio/visns-components.git"
|
|
48
|
+
},
|
|
49
|
+
"author": "Visns Studio",
|
|
50
|
+
"license": "ISC",
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/visnsstudio/visns-components/issues"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/visnsstudio/visns-components#readme"
|
|
55
55
|
}
|