diff options
| author | kboz <kutayboz@gmail.com> | 2026-09-27 22:36:36 +0200 |
|---|---|---|
| committer | kboz <kutayboz@gmail.com> | 2026-09-27 22:36:36 +0200 |
| commit | 526c8ec005d03b17950e9f5e7fe74208b491dd68 (patch) | |
| tree | b6a5ea59040bf48ffd0953a5682a43648a03ca51 /frontend/src/App.js | |
| parent | 1b59961ce2385252e3346ea6107b15a2c1feafe6 (diff) | |
| download | haul-go-backend.tar.gz | |
feat(frontend): add guided setup flow for backend bootstrapgo-backend
Poll the backend /api/setup/status and show a Setup screen until data,
auth, and backend readiness are confirmed. Remove the manual
setup_auth.py and setup_eve_data.py scripts superseded by the automated
setup endpoints.
Diffstat (limited to 'frontend/src/App.js')
| -rw-r--r-- | frontend/src/App.js | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/frontend/src/App.js b/frontend/src/App.js index 569ff74..af95c63 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -1,18 +1,52 @@ +import React, { useState, useEffect } from 'react'; import './App.css'; import Path from './Path'; import Log from './Log'; import Options from './Options'; import Info from './Info'; +import Setup from './Setup'; function App() { + const [setupStatus, setSetupStatus] = useState(null); + + useEffect(() => { + const checkStatus = async () => { + try { + const resp = await fetch('http://localhost:8000/api/setup/status'); + const rootResp = await fetch('http://localhost:8000/'); + if (resp.ok && rootResp.ok) { + const data = await resp.json(); + const rootData = await rootResp.json(); + data.backend_ready = rootData.ready; + setSetupStatus(data); + if (!rootData.ready) { + setTimeout(checkStatus, 2000); + } + } else { + setTimeout(checkStatus, 2000); + } + } catch (e) { + console.error("Could not reach backend API, retrying in 2s..."); + setTimeout(checkStatus, 2000); + } + }; + checkStatus(); + }, []); + + if (!setupStatus) { + return <div className="loading">Initializing Backend Connection...</div>; + } + + if (!setupStatus.data_ready || !setupStatus.auth_ready || !setupStatus.backend_ready) { + return <Setup status={setupStatus} onComplete={() => window.location.reload()} />; + } + return ( <div className="App flex flex-wrap h-screen"> - {/* Main component for Path */} <div className="w-2/3 h-full overflow-auto hide-scrollbar"> <Path /> </div> - {/* Sidebar for route info, controls, and log output */} <div className="w-1/3 h-full flex flex-col"> <div className="h-1/4 overflow-auto"> <Info /> |
