@visns-studio/visns-components 3.2.7 → 3.3.0
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,13 @@ const ProtectedRoute = ({ user, loading, redirectPath = '/login' }) => {
|
|
|
27
28
|
);
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
const GenericAuth = ({
|
|
31
|
+
const GenericAuth = ({
|
|
32
|
+
logo,
|
|
33
|
+
headerLogo,
|
|
34
|
+
providers,
|
|
35
|
+
navigation,
|
|
36
|
+
routeConfig,
|
|
37
|
+
}) => {
|
|
31
38
|
const navigate = useNavigate();
|
|
32
39
|
const location = useLocation();
|
|
33
40
|
const [userProfile, setUserProfile] = useState({});
|
|
@@ -65,6 +72,7 @@ const GenericAuth = ({ logo, Main }) => {
|
|
|
65
72
|
element={
|
|
66
73
|
<LoginComponent
|
|
67
74
|
logo={logo}
|
|
75
|
+
providers={providers}
|
|
68
76
|
setIsAuthenticated={setIsAuthenticated}
|
|
69
77
|
setUserProfile={setUserProfile}
|
|
70
78
|
/>
|
|
@@ -99,11 +107,13 @@ const GenericAuth = ({ logo, Main }) => {
|
|
|
99
107
|
<Route
|
|
100
108
|
path="/*"
|
|
101
109
|
element={
|
|
102
|
-
<
|
|
103
|
-
|
|
110
|
+
<GenericMain
|
|
111
|
+
logo={headerLogo}
|
|
112
|
+
navigation={navigation}
|
|
113
|
+
routeConfig={routeConfig}
|
|
104
114
|
setUserProfile={setUserProfile}
|
|
105
|
-
userProfile={userProfile}
|
|
106
115
|
setSystemAuth={setIsAuthenticated}
|
|
116
|
+
userProfile={userProfile}
|
|
107
117
|
/>
|
|
108
118
|
}
|
|
109
119
|
/>
|
|
@@ -120,10 +130,10 @@ const GenericAuth = ({ logo, Main }) => {
|
|
|
120
130
|
};
|
|
121
131
|
|
|
122
132
|
const LoginComponent = React.memo(
|
|
123
|
-
({ logo, setIsAuthenticated, setUserProfile }) => (
|
|
133
|
+
({ logo, providers, setIsAuthenticated, setUserProfile }) => (
|
|
124
134
|
<Login
|
|
125
135
|
logo={logo}
|
|
126
|
-
providers={
|
|
136
|
+
providers={providers}
|
|
127
137
|
setSystemAuth={setIsAuthenticated}
|
|
128
138
|
setUserProfile={setUserProfile}
|
|
129
139
|
/>
|
|
@@ -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