Fix: Improve UX with empty state, miles, and metric labels
1. Show empty state by default on home page
- Don't fetch or display schools until user searches
- Show helpful message prompting users to search
- Only fetch schools when search params are present
2. Change distance search to miles
- Display 0.5, 1, and 2 mile options instead of km
- Convert miles to km when sending to API (backend expects km)
- Convert km back to miles for display in location banner
- Maintains backend compatibility while improving UX
3. Fix metric labels in rankings dropdown
- Backend returns 'name' and 'type' fields
- Frontend expects 'label' and 'format' fields
- Added transformation in fetchMetrics to map fields
- Dropdown now shows proper labels like "RWM Combined %"
instead of technical codes like "rwm_expected_pct"
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -46,7 +46,7 @@ export function HomeView({ initialSchools, filters }: HomeViewProps) {
|
||||
<div className={styles.locationBanner}>
|
||||
<span className={styles.locationIcon}>📍</span>
|
||||
<span>
|
||||
Showing schools within {initialSchools.location_info.radius}km of{' '}
|
||||
Showing schools within {(initialSchools.location_info.radius / 1.60934).toFixed(1)} miles of{' '}
|
||||
<strong>{initialSchools.location_info.postcode}</strong>
|
||||
</span>
|
||||
</div>
|
||||
@@ -74,14 +74,22 @@ export function HomeView({ initialSchools, filters }: HomeViewProps) {
|
||||
|
||||
{initialSchools.schools.length === 0 ? (
|
||||
<EmptyState
|
||||
title="No schools found"
|
||||
message="Try adjusting your search criteria or filters to find schools."
|
||||
action={{
|
||||
label: 'Clear Filters',
|
||||
onClick: () => {
|
||||
window.location.href = '/';
|
||||
},
|
||||
}}
|
||||
title={hasSearch ? "No schools found" : "Search for Schools"}
|
||||
message={
|
||||
hasSearch
|
||||
? "Try adjusting your search criteria or filters to find schools."
|
||||
: "Use the search above to find schools by name or search by location to discover schools near a postcode."
|
||||
}
|
||||
action={
|
||||
hasSearch
|
||||
? {
|
||||
label: 'Clear Filters',
|
||||
onClick: () => {
|
||||
window.location.href = '/';
|
||||
},
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user