Files
TREK/client/src/components/Journey/journeyWeather.ts
T
Maurice 8e95b4c7b6 refactor(journey): share the entry editor logic between desktop and phone
useJourneyEntryForm holds the fields, the photo queue that only goes out on
save, the gallery links, the location search and "use my location", the
verdict rows, quick capture and the save for both the editor dialog and the
entry sheet. journeyWeatherCategory moves to components/Journey/journeyWeather
so the dialog no longer reaches into mobile/. Where the two differed they still
do: the dialog starts with a blank verdict row, counts a moved point as a
change, toasts a failed save or location and fills the weather from the
forecast; the sheet edits tags and shows a refused location under the field.
2026-10-09 15:19:49 +02:00

16 lines
755 B
TypeScript

/**
* The journey weather icon id for a weather service answer: its main condition, with
* the description telling a partly cloudy sky from a cloudy one. 'cold' is the stored
* id for snow.
*/
export function journeyWeatherCategory(main: string, description: string): string {
const normalizedMain = main.toLowerCase();
const normalizedDescription = description.toLowerCase();
if (normalizedMain === 'clear') return 'sunny';
if (normalizedMain === 'thunderstorm') return 'stormy';
if (normalizedMain === 'snow') return 'cold';
if (normalizedMain === 'rain' || normalizedMain === 'drizzle') return 'rainy';
if (normalizedDescription.includes('partly') || normalizedDescription.includes('teilweise')) return 'partly';
return 'cloudy';
}