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

Pedro Lucas Porcellis porcellis@eletrotupi.com 1 month ago d133c5dc25eb543666edec663c5f91ca583f8b32
Parents: 02738dc
1 file(s) changed
  • frontend/constants/mood-components.ts +10 -4
frontend/constants/mood-components.ts
@@ -20,10 +20,16 @@ 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 => {