@visns-studio/visns-components 3.2.7 → 3.2.8
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.
|
@@ -13,6 +13,7 @@ import 'react-tooltip/dist/react-tooltip.css';
|
|
|
13
13
|
import 'react-toastify/dist/ReactToastify.css';
|
|
14
14
|
|
|
15
15
|
import CustomFetch from '../Fetch';
|
|
16
|
+
import GenericMain from './GenericMain';
|
|
16
17
|
import Login from '../auth/Login';
|
|
17
18
|
import Reset from '../auth/Reset';
|
|
18
19
|
import Verify from '../auth/Verify';
|
|
@@ -27,7 +28,7 @@ const ProtectedRoute = ({ user, loading, redirectPath = '/login' }) => {
|
|
|
27
28
|
);
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
const GenericAuth = ({ logo,
|
|
31
|
+
const GenericAuth = ({ logo, navigation, routeConfig }) => {
|
|
31
32
|
const navigate = useNavigate();
|
|
32
33
|
const location = useLocation();
|
|
33
34
|
const [userProfile, setUserProfile] = useState({});
|
|
@@ -99,11 +100,13 @@ const GenericAuth = ({ logo, Main }) => {
|
|
|
99
100
|
<Route
|
|
100
101
|
path="/*"
|
|
101
102
|
element={
|
|
102
|
-
<
|
|
103
|
-
|
|
103
|
+
<GenericMain
|
|
104
|
+
logo={logo}
|
|
105
|
+
navigation={navigation}
|
|
106
|
+
routeConfig={routeConfig}
|
|
104
107
|
setUserProfile={setUserProfile}
|
|
105
|
-
userProfile={userProfile}
|
|
106
108
|
setSystemAuth={setIsAuthenticated}
|
|
109
|
+
userProfile={userProfile}
|
|
107
110
|
/>
|
|
108
111
|
}
|
|
109
112
|
/>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Routes, Route } from 'react-router-dom';
|
|
3
|
+
import { Call, Loader, Navigation } from '@visns-studio/visns-components';
|
|
4
|
+
|
|
5
|
+
const GenericMain = ({
|
|
6
|
+
logo,
|
|
7
|
+
navigation,
|
|
8
|
+
routeConfig,
|
|
9
|
+
setSystemAuth,
|
|
10
|
+
setUserProfile,
|
|
11
|
+
userProfile,
|
|
12
|
+
}) => {
|
|
13
|
+
const [incomingCallData, setIncomingCallData] = useState({});
|
|
14
|
+
|
|
15
|
+
// Recursive function to render routes
|
|
16
|
+
const renderRoutes = (routes) => {
|
|
17
|
+
return routes.map((route, index) => {
|
|
18
|
+
let element;
|
|
19
|
+
|
|
20
|
+
if (route.element) {
|
|
21
|
+
element = React.cloneElement(route.element, {
|
|
22
|
+
userProfile: userProfile,
|
|
23
|
+
setUserProfile: setUserProfile,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (route.children && route.children.length > 0) {
|
|
28
|
+
// If the route has children, render them recursively
|
|
29
|
+
return (
|
|
30
|
+
<Route key={index} path={route.path}>
|
|
31
|
+
{renderRoutes(route.children)}
|
|
32
|
+
</Route>
|
|
33
|
+
);
|
|
34
|
+
} else {
|
|
35
|
+
return (
|
|
36
|
+
<Route key={index} path={route.path} element={element} />
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div>
|
|
44
|
+
<header className="header">
|
|
45
|
+
<Navigation
|
|
46
|
+
logo={logo}
|
|
47
|
+
navConfig={navigation}
|
|
48
|
+
setSystemAuth={setSystemAuth}
|
|
49
|
+
userProfile={userProfile}
|
|
50
|
+
/>
|
|
51
|
+
</header>
|
|
52
|
+
<main className="content">
|
|
53
|
+
<div className="content-main" id="app">
|
|
54
|
+
<div className="padding">
|
|
55
|
+
<Routes>{renderRoutes(routeConfig)}</Routes>
|
|
56
|
+
</div>
|
|
57
|
+
<Call incomingCallData={incomingCallData} />
|
|
58
|
+
<Loader />
|
|
59
|
+
</div>
|
|
60
|
+
</main>
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default GenericMain;
|
package/index.js
CHANGED
|
@@ -37,6 +37,7 @@ import CmsSort from './components/cms/generic/CmsSort';
|
|
|
37
37
|
import GenericAuth from './components/crm/generic/GenericAuth';
|
|
38
38
|
import GenericDetail from './components/crm/generic/GenericDetail';
|
|
39
39
|
import GenericIndex from './components/crm/generic/GenericIndex';
|
|
40
|
+
import GenericMain from './components/crm/generic/GenericMain';
|
|
40
41
|
import GenericSort from './components/crm/generic/GenericSort';
|
|
41
42
|
import NotificationList from './components/crm/generic/NotificationList';
|
|
42
43
|
|
|
@@ -58,6 +59,7 @@ export {
|
|
|
58
59
|
GenericAuth,
|
|
59
60
|
GenericDetail,
|
|
60
61
|
GenericIndex,
|
|
62
|
+
GenericMain,
|
|
61
63
|
GenericSort,
|
|
62
64
|
Loader,
|
|
63
65
|
Login,
|
package/package.json
CHANGED