frontend: return a label from every mood-component intensity bucket
Pedro Lucas Porcellis porcellis@eletrotupi.com · 12 days ago
d9717b316a8c7ad13ff9c659e8507cc1f9528e12 Browse filesParents
62df323Changed files
1
Additions
+8
Deletions
-9
frontend/constants/mood-components.ts
1 1
export interface MoodComponentDefinition {
2 2
id: string;
3 3
label: string;
4 4
color: string;
5 5
}
26 26
export const getMoodComponent = (id: string) =>
27 27
MOOD_COMPONENTS.find((c) => c.id === id);
28 28
29 29
// Intensity label buckets
30 30
export const intensityLabel = (value: number | string): string => {
31 -
if (typeof value == "number") {
32 -
if (value == 1) return "Suave";
31 +
if (typeof value === "number") {
32 +
if (value <= 1) return "Suave";
33 33
if (value <= 2) return "Moderada";
34 -
if (value <= 3) return "Intensa";
35 -
} else {
36 -
if (value === "LIGHT") return "Suave";
37 -
if (value === "MODERATE") return "Moderada";
38 -
if (value === "HIGH") return "Intensa";
34 +
return "Intensa";
39 35
}
36 +
if (value === "LIGHT") return "Suave";
37 +
if (value === "MODERATE") return "Moderada";
38 +
return "Intensa";
40 39
};
41 40
42 41
export const intensityToValue = (value: number): string => {
43 -
if (value == 1) return "LIGHT";
42 +
if (value <= 1) return "LIGHT";
44 43
if (value <= 2) return "MODERATE";
45 -
if (value <= 3) return "HIGH";
44 +
return "HIGH";
46 45
};