18 lines
668 B
TypeScript
18 lines
668 B
TypeScript
import type { AlertSeverity, Condition } from "./types";
|
|
|
|
/** Fallback wording for providers that only give us a numeric code. */
|
|
export const CONDITION_LABELS: Record<Condition, string> = {
|
|
clear: "clear skies",
|
|
clouds: "cloudy",
|
|
rain: "rain",
|
|
storm: "thunderstorm",
|
|
snow: "snow",
|
|
fog: "fog",
|
|
};
|
|
|
|
/** Maps any provider's severity word ("Severe", "severe", "Moderate"…) onto ours. */
|
|
export function toSeverity(word: string | null | undefined): AlertSeverity {
|
|
const normalized = (word ?? "").toLowerCase();
|
|
const known: AlertSeverity[] = ["extreme", "severe", "moderate", "minor"];
|
|
return known.find((s) => normalized.includes(s)) ?? "unknown";
|
|
}
|