my-fleetbo-react-v1 1.0.7 → 1.0.10
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.
package/package.json
CHANGED
|
@@ -61,7 +61,6 @@ export const useStartupEffect = () => {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
-
|
|
65
64
|
if (window.Fleetbo && typeof window.Fleetbo.fleetboLog === 'function') {
|
|
66
65
|
if (window.Fleetbo) onFleetboReady();
|
|
67
66
|
else requester = setInterval(() => { if (window.Fleetbo) onFleetboReady(); }, 100);
|
|
@@ -79,17 +78,13 @@ export const useStartupEffect = () => {
|
|
|
79
78
|
if (!isReadyRef.current) setError("Running outside of Fleetbo Environment.");
|
|
80
79
|
}, 2000);
|
|
81
80
|
}
|
|
82
|
-
|
|
83
81
|
timer = setTimeout(() => {
|
|
84
82
|
if (!isReadyRef.current) {
|
|
85
83
|
setError("Connection Timeout.");
|
|
86
84
|
cleanup();
|
|
87
85
|
}
|
|
88
86
|
}, 15000);
|
|
89
|
-
|
|
90
|
-
window.navigateToTab = (route) => navigate(route);
|
|
91
|
-
|
|
92
|
-
// Listener logout
|
|
87
|
+
window.navigateToTab = (route) => navigate(route);
|
|
93
88
|
const handleLogout = (event) => {
|
|
94
89
|
if (event.data?.type === 'FLEETBO_FORCE_LOGOUT') {
|
|
95
90
|
setIsAuthenticated(false);
|
|
@@ -102,7 +97,6 @@ export const useStartupEffect = () => {
|
|
|
102
97
|
|
|
103
98
|
return () => {
|
|
104
99
|
cleanup();
|
|
105
|
-
// Clear listener
|
|
106
100
|
window.removeEventListener('message', handleLogout);
|
|
107
101
|
};
|
|
108
102
|
}, [navigate]);
|
package/src/App.jsx
CHANGED
|
@@ -115,9 +115,9 @@ function App() {
|
|
|
115
115
|
<Route path="/tab3" element={<Tab3 />} />
|
|
116
116
|
|
|
117
117
|
{/* FLEETBO_ROUTES */}
|
|
118
|
-
<Route path="/
|
|
119
|
-
<Route path="/
|
|
120
|
-
<Route path="/
|
|
118
|
+
<Route path="/sampletab1" element={<SampleTab1 />} />
|
|
119
|
+
<Route path="/sampletab2" element={<SampleTab2 />} />
|
|
120
|
+
<Route path="/sampletab3" element={<SampleTab3 />} />
|
|
121
121
|
{/* FLEETBO_DYNAMIC ROUTES */}
|
|
122
122
|
|
|
123
123
|
<Route path="*" element={<NotFound />} />
|
|
@@ -12,17 +12,33 @@ import { PageConfig } from '@fleetbo';
|
|
|
12
12
|
|
|
13
13
|
const DEFAULT_TAB = 'tab1';
|
|
14
14
|
|
|
15
|
-
const Login = (
|
|
16
|
-
const
|
|
17
|
-
try {
|
|
18
|
-
const s = localStorage.getItem('fleetbo_session');
|
|
19
|
-
return s ? JSON.parse(s) : null;
|
|
20
|
-
} catch (e) { return null; }
|
|
21
|
-
})();
|
|
22
|
-
|
|
15
|
+
const Login = () => {
|
|
16
|
+
const [appInfo, setAppInfo] = useState(null);
|
|
23
17
|
const [phoneNumber, setPhoneNumber] = useState('');
|
|
24
18
|
const [loadingLog, setLoadingLog] = useState(false);
|
|
25
19
|
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const checkStatus = async () => {
|
|
22
|
+
if (window.Fleetbo && typeof window.Fleetbo.checkAuthStatusAndRedirect === 'function') {
|
|
23
|
+
try {
|
|
24
|
+
const res = await window.Fleetbo.checkAuthStatusAndRedirect();
|
|
25
|
+
if (res && res.success) {
|
|
26
|
+
setAppInfo({
|
|
27
|
+
name: res.appName || 'Fleetbo App',
|
|
28
|
+
description: res.description || 'DevTool Workspace'
|
|
29
|
+
});
|
|
30
|
+
if (res.isLoggedIn) {
|
|
31
|
+
window.Fleetbo.openView('Tab1', true);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
console.error("Infrastructure connection error:", err);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
checkStatus();
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
26
42
|
const handleVerifyPhoneNumber = async () => {
|
|
27
43
|
if (!phoneNumber.trim()) return;
|
|
28
44
|
setLoadingLog(true);
|
|
@@ -46,14 +62,14 @@ const Login = ({ sessionData: sessionDataProp }) => {
|
|
|
46
62
|
|
|
47
63
|
<div className="login-passerelle-container" style={{ animation: 'fadeIn 0.5s ease-in-out' }}>
|
|
48
64
|
<div className="login-passerelle-box">
|
|
49
|
-
{
|
|
65
|
+
{appInfo ? (
|
|
50
66
|
<div className="w-100 d-flex flex-column align-items-center text-center" style={{ maxWidth: '340px' }}>
|
|
51
67
|
<img className="mb-3" src={logo} alt="logo" style={{ width: '50px', height: '50px' }} />
|
|
52
68
|
<h3 className="fw-bold mb-1" style={{ fontSize: '19px', color: '#4c8a69' }}>
|
|
53
|
-
{
|
|
69
|
+
{appInfo.name || "Fleetbo"}
|
|
54
70
|
</h3>
|
|
55
71
|
<p className="text-muted mb-4" style={{ fontSize: '13px' }}>
|
|
56
|
-
{
|
|
72
|
+
{appInfo.description || "Mobile Cloud OS"}
|
|
57
73
|
</p>
|
|
58
74
|
|
|
59
75
|
<input
|
|
@@ -54,7 +54,7 @@ export default function SampleTab3() {
|
|
|
54
54
|
onTouchEnd={(e) => e.currentTarget.style.transform = 'scale(1)'}
|
|
55
55
|
onMouseDown={(e) => e.currentTarget.style.transform = 'scale(0.96)'}
|
|
56
56
|
onMouseUp={(e) => e.currentTarget.style.transform = 'scale(1)'}
|
|
57
|
-
onClick={() => Fleetbo.emit('
|
|
57
|
+
onClick={() => Fleetbo.emit('CONFIRM_LOGOUT', {})}
|
|
58
58
|
>
|
|
59
59
|
Log Out
|
|
60
60
|
</div>
|
|
@@ -8,7 +8,7 @@ export default function Tab3() {
|
|
|
8
8
|
emit: async (action, payload) => {
|
|
9
9
|
if (action === 'HIDE_NAVBAR') setNavMode("none");
|
|
10
10
|
if (action === 'SHOW_NAVBAR') setNavMode("show");
|
|
11
|
-
if (action === '
|
|
11
|
+
if (action === 'CONFIRM_LOGOUT') { Fleetbo.logout(); }
|
|
12
12
|
//if (action === 'OPEN_EDIT_PROFILE') {
|
|
13
13
|
// Example: Fleetbo.exec('EditProfileModule', 'open', {});
|
|
14
14
|
//}
|