diff --git a/web/src/App.tsx b/web/src/App.tsx index 1783441..2be28ec 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -22,6 +22,7 @@ import type { ActivityId } from './types/activity'; const sortModes = ['default', 'best', 'temperature', 'rain', 'wind'] as const; type SortMode = (typeof sortModes)[number]; +type CityFilter = 'all' | CityId; const cityIds = new Set(cities.map(({ id }) => id)); const activitySchema = z.enum(['walking', 'cycling', 'running', 'skiing']); const sortModeSchema = z.enum(sortModes); @@ -30,6 +31,8 @@ const cityIdSchema = z .refine((id): id is CityId => cityIds.has(id as CityId)); const favoriteIdsSchema = z.array(cityIdSchema); +const cityFilterSchema = z.union([z.literal('all'), cityIdSchema]); + function Header({ selectedCityId, activity, @@ -38,10 +41,10 @@ function Header({ onActivityChange, onSortChange, }: { - selectedCityId: CityId; + selectedCityId: CityFilter; activity: ActivityId; sortMode: SortMode; - onCityChange: (cityId: CityId) => void; + onCityChange: (cityId: CityFilter) => void; onActivityChange: (activity: ActivityId) => void; onSortChange: (sortMode: SortMode) => void; }) { @@ -61,8 +64,12 @@ function Header({ By onActivityChange(event.target.value as ActivityId) } @@ -89,6 +103,7 @@ function Header({ Sorter etter