Fix routing, data fetching, and rendering issues in CRDC demo app:
Deploy to git-pages / deploy (push) Successful in 10s
Deploy to git-pages / deploy (push) Successful in 10s
- App.jsx: Fix 'search another district' button href to use /crdc-demo/ instead of / (root)
- LoadingAnimation.jsx: Replace broken inline fetch helper with centralized api client from useApi.js — was bypassing envelope unwrapping ({status:'success',data:[...]}), causing all 43 API calls to fail silently
- ChartPanel.jsx: Same fix — replace raw fetch() calls with api.fetchDistrictEstimates(), fix national_rates.json path (remove hardcoded /crdc-demo/ prefix that breaks in dev), parallelize wave/model fetches with Promise.all for faster loading
Root causes fixed:
1. Navigation button linked to site root instead of app subdirectory → users lost their way after selecting a district
2. Dual API client implementations — inline fetch helpers didn't unwrap the JSON envelope structure, causing data parsing failures that made the page appear stuck on 'Organizing data...'
3. Sequential fetches in ChartPanel caused slow loading; parallelized for better UX
This commit is contained in:
+4
-3
@@ -20,7 +20,8 @@ export default function App() {
|
||||
const leaid = params.get('leaid')
|
||||
const stateParam = params.get('state')
|
||||
if (leaid && stateParam) {
|
||||
// Deep link: skip straight to loading → results
|
||||
// Deep link: skip straight to loading → results.
|
||||
// We need to fetch the district name since we only have LEAID from URL.
|
||||
setSelectedState(stateParam)
|
||||
setDistrict({ leaid, lea_name: 'Loading…', state: stateParam })
|
||||
setStep('loading')
|
||||
@@ -44,7 +45,7 @@ export default function App() {
|
||||
<div className="cv-app">
|
||||
{/* Header */}
|
||||
<header className="cv-header cv-wrap">
|
||||
<a href="/" aria-label="Civilytics" style={{ display: 'block' }}>
|
||||
<a href="/crdc-demo" aria-label="Civilytics" style={{ display: 'block' }}>
|
||||
<img
|
||||
src="/civilytics-logo.svg"
|
||||
alt="Civilytics — social science for the public good"
|
||||
@@ -81,7 +82,7 @@ export default function App() {
|
||||
<button
|
||||
className="btn-outline"
|
||||
style={{ margin: 'var(--space-3) 0', display: 'block' }}
|
||||
onClick={() => { window.location.href = '/' }}
|
||||
onClick={() => { window.location.href = '/crdc-demo/' }}
|
||||
>
|
||||
← Search another district
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user