@visns-studio/visns-components 1.5.2 → 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.
|
@@ -65,7 +65,15 @@ const VisnsAutocomplete = (props) => {
|
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
const handleItemClicked = (place) => {
|
|
68
|
-
|
|
68
|
+
const address =
|
|
69
|
+
place.address !== undefined && place.address !== null
|
|
70
|
+
? place.address
|
|
71
|
+
: "";
|
|
72
|
+
const text =
|
|
73
|
+
place.text !== undefined && place.text !== null ? place.text : "";
|
|
74
|
+
|
|
75
|
+
const search = address && text ? `${address} ${text}` : text;
|
|
76
|
+
setSearch(search);
|
|
69
77
|
setResults([]);
|
|
70
78
|
onSelect(place, field);
|
|
71
79
|
};
|
|
@@ -269,22 +269,18 @@ function Form(props) {
|
|
|
269
269
|
|
|
270
270
|
const autocompleteSelect = (place, id) => {
|
|
271
271
|
const { address, text, context } = place;
|
|
272
|
-
const address1 =
|
|
273
|
-
address !== undefined && address ? address + " " + text : text;
|
|
274
|
-
let address2 = "";
|
|
275
|
-
let suburb = "";
|
|
276
|
-
let postcode = "";
|
|
277
|
-
let state = "";
|
|
278
|
-
let country = "";
|
|
279
|
-
|
|
280
|
-
if (context[1]) {
|
|
281
|
-
suburb = context[1].text;
|
|
282
|
-
}
|
|
283
272
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
273
|
+
const address1 = address
|
|
274
|
+
? text
|
|
275
|
+
? `${address} ${text}`
|
|
276
|
+
: address
|
|
277
|
+
: text;
|
|
278
|
+
const address2 = "";
|
|
279
|
+
const suburb = context[1]?.text || "";
|
|
280
|
+
const postcode = context[0]?.text || "";
|
|
287
281
|
|
|
282
|
+
let state = "";
|
|
283
|
+
let country = "";
|
|
288
284
|
if (context.length === 5) {
|
|
289
285
|
[state, country] = [context[3]?.text, context[4]?.text];
|
|
290
286
|
} else {
|
|
@@ -300,34 +296,19 @@ function Form(props) {
|
|
|
300
296
|
country,
|
|
301
297
|
};
|
|
302
298
|
|
|
303
|
-
if (formData.same_address === true) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
postal_postcode: postcode,
|
|
311
|
-
postal_state: state,
|
|
312
|
-
postal_country: country,
|
|
313
|
-
}));
|
|
314
|
-
} else if (id === "address1") {
|
|
315
|
-
setFormData((prevState) => ({
|
|
316
|
-
...prevState,
|
|
317
|
-
...formDataUpdate,
|
|
318
|
-
}));
|
|
319
|
-
} else {
|
|
320
|
-
setFormData((prevState) => ({
|
|
321
|
-
...prevState,
|
|
322
|
-
...formDataUpdate,
|
|
323
|
-
postal_address1: address1,
|
|
324
|
-
postal_address2: address2,
|
|
325
|
-
postal_suburb: suburb,
|
|
326
|
-
postal_postcode: postcode,
|
|
327
|
-
postal_state: state,
|
|
328
|
-
postal_country: country,
|
|
329
|
-
}));
|
|
299
|
+
if (formData.same_address === true || id !== "address1") {
|
|
300
|
+
formDataUpdate.postal_address1 = address1;
|
|
301
|
+
formDataUpdate.postal_address2 = address2;
|
|
302
|
+
formDataUpdate.postal_suburb = suburb;
|
|
303
|
+
formDataUpdate.postal_postcode = postcode;
|
|
304
|
+
formDataUpdate.postal_state = state;
|
|
305
|
+
formDataUpdate.postal_country = country;
|
|
330
306
|
}
|
|
307
|
+
|
|
308
|
+
setFormData((prevState) => ({
|
|
309
|
+
...prevState,
|
|
310
|
+
...formDataUpdate,
|
|
311
|
+
}));
|
|
331
312
|
};
|
|
332
313
|
|
|
333
314
|
const handleSubmit = (e) => {
|
|
@@ -1,218 +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
|
-
|
|
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,
|
|
14
19
|
} from "akar-icons";
|
|
15
20
|
|
|
16
21
|
import CustomFetch from "./visns-fetch";
|
|
17
22
|
import Notification from "./visns-notification";
|
|
18
23
|
|
|
19
24
|
function Navigation({ logo, logout, navConfig, setSystemAuth, userProfile }) {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
);
|
|
216
229
|
}
|
|
217
230
|
|
|
218
231
|
export default Navigation;
|
package/package.json
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"react-dom": "^17.0.1"
|
|
36
36
|
},
|
|
37
37
|
"name": "@visns-studio/visns-components",
|
|
38
|
-
"version": "1.5.
|
|
38
|
+
"version": "1.5.4",
|
|
39
39
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
40
40
|
"main": "index.js",
|
|
41
41
|
"devDependencies": {},
|