eletrotupi / tcc/ commit / d133c5d

frontend/constants: also generate labels for mood components from the backend

Pedro Lucas Porcellis porcellis@eletrotupi.com · 5 months ago d133c5dc25eb543666edec663c5f91ca583f8b32 Browse files
Parents 02738dc
Changed files
1
Additions
+10
Deletions
-4
frontend/constants/mood-components.ts
1 1
export interface MoodComponentDefinition {
2 2
  id: string;
3 3
  label: string;
4 4
  color: string;
5 5
}
18 18
// Lookup helper
19 19
export const getMoodComponent = (id: string) =>
20 20
  MOOD_COMPONENTS.find((c) => c.id === id);
21 21

22 22
// Intensity label buckets
23 -
export const intensityLabel = (value: number): string => {
24 -
  if (value == 1) return 'Suave';
25 -
  if (value <= 2) return 'Moderada';
26 -
  if (value <= 3) return 'Intensa';
23 +
export const intensityLabel = (value: number | string): string => {
24 +
  if (typeof value == 'number') {
25 +
    if (value == 1) return 'Suave';
26 +
    if (value <= 2) return 'Moderada';
27 +
    if (value <= 3) return 'Intensa';
28 +
  } else {
29 +
    if (value === 'LIGHT') return 'Suave';
30 +
    if (value === 'MODERATE') return 'Moderada';
31 +
    if (value === 'HIGH') return 'Intensa';
32 +
  }
27 33
};
28 34

29 35
export const intensityToValue = (value: number): string => {
30 36
  if (value == 1) return 'LIGHT';
31 37
  if (value <= 2) return 'MODERATE';
32 38
  if (value <= 3) return 'HIGH';
33 39
}