Fix: milestone routes use milestone_code, config check via backend
- Milestone navigation now uses milestone_code instead of numeric id - MilestoneDetailPage uses milestone.id (numeric) for project-scoped API calls - App.tsx checks /config/status on backend first, falls back to wizard - Added milestone_code to Milestone type - Fixed MilestoneDetailPage to use fetched milestone.id for sub-queries
This commit is contained in:
22
src/App.tsx
22
src/App.tsx
@@ -24,6 +24,10 @@ import axios from 'axios'
|
||||
const WIZARD_PORT = Number(import.meta.env.VITE_WIZARD_PORT) || 18080
|
||||
const WIZARD_BASE = `http://127.0.0.1:${WIZARD_PORT}`
|
||||
|
||||
const getApiBase = () => {
|
||||
return localStorage.getItem('HF_BACKEND_BASE_URL') || import.meta.env.VITE_API_BASE || 'http://127.0.0.1:8000'
|
||||
}
|
||||
|
||||
type AppState = 'checking' | 'setup' | 'ready'
|
||||
|
||||
export default function App() {
|
||||
@@ -35,6 +39,22 @@ export default function App() {
|
||||
}, [])
|
||||
|
||||
const checkInitialized = async () => {
|
||||
// First try the backend /config/status endpoint (reads from config volume directly)
|
||||
try {
|
||||
const res = await axios.get(`${getApiBase()}/config/status`, { timeout: 5000 })
|
||||
const cfg = res.data || {}
|
||||
if (cfg.backend_url) {
|
||||
localStorage.setItem('HF_BACKEND_BASE_URL', cfg.backend_url)
|
||||
}
|
||||
if (cfg.initialized === true) {
|
||||
setAppState('ready')
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
// Backend unreachable — fall through to wizard check
|
||||
}
|
||||
|
||||
// Fallback: try the wizard directly (needed during initial setup before backend starts)
|
||||
try {
|
||||
const res = await axios.get(`${WIZARD_BASE}/api/v1/config/harborforge.json`, {
|
||||
timeout: 5000,
|
||||
@@ -49,7 +69,7 @@ export default function App() {
|
||||
setAppState('setup')
|
||||
}
|
||||
} catch {
|
||||
// Wizard unreachable or config doesn't exist → setup needed
|
||||
// Neither backend nor wizard reachable → setup needed
|
||||
setAppState('setup')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user