@visns-studio/visns-components 3.3.1 → 3.3.3
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.
|
@@ -26,6 +26,7 @@ const Profile = ({ userProfile, setUserProfile }) => {
|
|
|
26
26
|
]);
|
|
27
27
|
|
|
28
28
|
useEffect(() => {
|
|
29
|
+
console.info(userProfile);
|
|
29
30
|
setProfile({
|
|
30
31
|
name: userProfile.name,
|
|
31
32
|
email: userProfile.email,
|
|
@@ -41,28 +42,43 @@ const Profile = ({ userProfile, setUserProfile }) => {
|
|
|
41
42
|
}));
|
|
42
43
|
};
|
|
43
44
|
|
|
44
|
-
const handleSubmitProfile = (e) => {
|
|
45
|
-
|
|
45
|
+
const handleSubmitProfile = async (e) => {
|
|
46
|
+
try {
|
|
47
|
+
if (e) {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
}
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
// Validate required fields
|
|
52
|
+
if (profile.name.trim() === '' || profile.email.trim() === '') {
|
|
53
|
+
setInputClasses({
|
|
54
|
+
name: profile.name.trim() === '' ? 'inputError' : '',
|
|
55
|
+
email: profile.email.trim() === '' ? 'inputError' : '',
|
|
56
|
+
});
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
toast.error('Please fill in all the required fields.');
|
|
59
|
+
} else {
|
|
60
|
+
// Create a new payload object
|
|
61
|
+
let payload = {
|
|
62
|
+
name: profile.name,
|
|
63
|
+
email: profile.email,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Conditionally add password to payload if it has a value
|
|
67
|
+
if (profile.password.trim() !== '') {
|
|
68
|
+
payload.password = profile.password;
|
|
64
69
|
}
|
|
65
|
-
|
|
70
|
+
|
|
71
|
+
const res = await CustomFetch(
|
|
72
|
+
`/ajax/users/${userProfile.id}`,
|
|
73
|
+
'PUT',
|
|
74
|
+
payload
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
setUserProfile(res.data.data);
|
|
78
|
+
toast.success('Your profile has been successfully updated.');
|
|
79
|
+
}
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.log(err);
|
|
66
82
|
}
|
|
67
83
|
};
|
|
68
84
|
|
|
@@ -19,7 +19,7 @@ import Reset from '../auth/Reset';
|
|
|
19
19
|
import Verify from '../auth/Verify';
|
|
20
20
|
|
|
21
21
|
const ProtectedRoute = ({ user, loading, redirectPath = '/login' }) => {
|
|
22
|
-
return loading ? null : !user.id ? (
|
|
22
|
+
return loading ? null : !user || !user.id ? (
|
|
23
23
|
<Navigate to={redirectPath} replace />
|
|
24
24
|
) : (
|
|
25
25
|
<Outlet />
|
|
@@ -20,7 +20,7 @@ import Table from '../DataGrid';
|
|
|
20
20
|
import TableFilter from '../TableFilter';
|
|
21
21
|
import { toast } from 'react-toastify';
|
|
22
22
|
|
|
23
|
-
function GenericDetail({ setting, urlParam, userProfile }) {
|
|
23
|
+
function GenericDetail({ extraUrlParam, setting, urlParam, userProfile }) {
|
|
24
24
|
const routeParams = useParams();
|
|
25
25
|
|
|
26
26
|
const { filters, page, stages, tabs } = setting;
|
|
@@ -15,18 +15,37 @@ const GenericMain = ({
|
|
|
15
15
|
}) => {
|
|
16
16
|
const [incomingCallData, setIncomingCallData] = useState({});
|
|
17
17
|
|
|
18
|
+
// Function to extract route parameters
|
|
19
|
+
const extractRouteParams = (path) => {
|
|
20
|
+
const params = path.match(/:\w+/g) || [];
|
|
21
|
+
return params.map((param) => param.substring(1));
|
|
22
|
+
};
|
|
23
|
+
|
|
18
24
|
// Recursive function to render routes
|
|
19
25
|
const renderRoutes = (routes) => {
|
|
20
26
|
return routes.map((route, index) => {
|
|
21
|
-
let
|
|
27
|
+
let elementProps = {
|
|
28
|
+
userProfile: userProfile,
|
|
29
|
+
setUserProfile: setUserProfile,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const routeParams = extractRouteParams(route.path);
|
|
33
|
+
const extraParams = routeParams.filter(
|
|
34
|
+
(param) => param !== 'dataId'
|
|
35
|
+
);
|
|
22
36
|
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
userProfile: userProfile,
|
|
26
|
-
setUserProfile: setUserProfile,
|
|
27
|
-
});
|
|
37
|
+
if (routeParams.includes('dataId')) {
|
|
38
|
+
elementProps.urlParam = 'dataId';
|
|
28
39
|
}
|
|
29
40
|
|
|
41
|
+
if (extraParams.length > 0) {
|
|
42
|
+
elementProps.extraUrlParam = extraParams;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let element = route.element
|
|
46
|
+
? React.cloneElement(route.element, elementProps)
|
|
47
|
+
: null;
|
|
48
|
+
|
|
30
49
|
if (route.children && route.children.length > 0) {
|
|
31
50
|
// If the route has children, render them recursively
|
|
32
51
|
return (
|
package/package.json
CHANGED