Files
mybabyguess/apps/web/src/features/predictions/domain/prediction-theme.ts
T
2026-05-03 21:58:59 +02:00

27 lines
552 B
TypeScript

export type PredictionTheme = "boy" | "girl";
function normalizeText(value: string) {
return value
.trim()
.toLowerCase()
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "");
}
export function getThemeFromSexValue(value: string | null | undefined): PredictionTheme | null {
if (!value) {
return null;
}
const normalized = normalizeText(value);
if (normalized === "fille" || normalized === "girl") {
return "girl";
}
if (normalized === "garcon" || normalized === "boy") {
return "boy";
}
return null;
}