@visns-studio/visns-components 3.2.6 → 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,12 +13,12 @@ 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';
|
|
19
20
|
|
|
20
|
-
import Main from '../../../../../../resources/js/main';
|
|
21
|
-
import logo from '../../../../../../resources/images/logo.svg';
|
|
21
|
+
// import Main from '../../../../../../resources/js/main';
|
|
22
22
|
|
|
23
23
|
const ProtectedRoute = ({ user, loading, redirectPath = '/login' }) => {
|
|
24
24
|
return loading ? null : !user.id ? (
|
|
@@ -28,7 +28,7 @@ const ProtectedRoute = ({ user, loading, redirectPath = '/login' }) => {
|
|
|
28
28
|
);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
const
|
|
31
|
+
const GenericAuth = ({ logo, navigation, routeConfig }) => {
|
|
32
32
|
const navigate = useNavigate();
|
|
33
33
|
const location = useLocation();
|
|
34
34
|
const [userProfile, setUserProfile] = useState({});
|
|
@@ -65,6 +65,7 @@ const Auth = () => {
|
|
|
65
65
|
path="login"
|
|
66
66
|
element={
|
|
67
67
|
<LoginComponent
|
|
68
|
+
logo={logo}
|
|
68
69
|
setIsAuthenticated={setIsAuthenticated}
|
|
69
70
|
setUserProfile={setUserProfile}
|
|
70
71
|
/>
|
|
@@ -74,6 +75,7 @@ const Auth = () => {
|
|
|
74
75
|
path="reset"
|
|
75
76
|
element={
|
|
76
77
|
<ResetComponent
|
|
78
|
+
logo={logo}
|
|
77
79
|
setIsAuthenticated={setIsAuthenticated}
|
|
78
80
|
/>
|
|
79
81
|
}
|
|
@@ -82,6 +84,7 @@ const Auth = () => {
|
|
|
82
84
|
path="verify/:code"
|
|
83
85
|
element={
|
|
84
86
|
<VerifyComponent
|
|
87
|
+
logo={logo}
|
|
85
88
|
setIsAuthenticated={setIsAuthenticated}
|
|
86
89
|
/>
|
|
87
90
|
}
|
|
@@ -97,11 +100,13 @@ const Auth = () => {
|
|
|
97
100
|
<Route
|
|
98
101
|
path="/*"
|
|
99
102
|
element={
|
|
100
|
-
<
|
|
101
|
-
|
|
103
|
+
<GenericMain
|
|
104
|
+
logo={logo}
|
|
105
|
+
navigation={navigation}
|
|
106
|
+
routeConfig={routeConfig}
|
|
102
107
|
setUserProfile={setUserProfile}
|
|
103
|
-
userProfile={userProfile}
|
|
104
108
|
setSystemAuth={setIsAuthenticated}
|
|
109
|
+
userProfile={userProfile}
|
|
105
110
|
/>
|
|
106
111
|
}
|
|
107
112
|
/>
|
|
@@ -112,39 +117,28 @@ const Auth = () => {
|
|
|
112
117
|
position="bottom-center"
|
|
113
118
|
style={{ width: '600px' }}
|
|
114
119
|
/>
|
|
120
|
+
<Tooltip id="system-tooltip" />
|
|
115
121
|
</>
|
|
116
122
|
);
|
|
117
123
|
};
|
|
118
124
|
|
|
119
|
-
const LoginComponent = React.memo(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
const LoginComponent = React.memo(
|
|
126
|
+
({ logo, setIsAuthenticated, setUserProfile }) => (
|
|
127
|
+
<Login
|
|
128
|
+
logo={logo}
|
|
129
|
+
providers={['azure']}
|
|
130
|
+
setSystemAuth={setIsAuthenticated}
|
|
131
|
+
setUserProfile={setUserProfile}
|
|
132
|
+
/>
|
|
133
|
+
)
|
|
134
|
+
);
|
|
127
135
|
|
|
128
|
-
const ResetComponent = React.memo(({ setIsAuthenticated }) => (
|
|
136
|
+
const ResetComponent = React.memo(({ logo, setIsAuthenticated }) => (
|
|
129
137
|
<Reset logo={logo} setSystemAuth={setIsAuthenticated} />
|
|
130
138
|
));
|
|
131
139
|
|
|
132
|
-
const VerifyComponent = React.memo(({ setIsAuthenticated }) => (
|
|
140
|
+
const VerifyComponent = React.memo(({ logo, setIsAuthenticated }) => (
|
|
133
141
|
<Verify logo={logo} setSystemAuth={setIsAuthenticated} />
|
|
134
142
|
));
|
|
135
143
|
|
|
136
|
-
|
|
137
|
-
({ checkAuthStatus, setUserProfile, userProfile, setSystemAuth }) => (
|
|
138
|
-
<>
|
|
139
|
-
<Main
|
|
140
|
-
checkAuthStatus={checkAuthStatus}
|
|
141
|
-
setSystemAuth={setSystemAuth}
|
|
142
|
-
userProfile={userProfile}
|
|
143
|
-
setUserProfile={setUserProfile}
|
|
144
|
-
/>
|
|
145
|
-
<Tooltip id="system-tooltip" />
|
|
146
|
-
</>
|
|
147
|
-
)
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
export default Auth;
|
|
144
|
+
export default GenericAuth;
|
|
@@ -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