eletrotupi / tcc/ commit / ebb9f22

frontend: map new mood components

Pedro Lucas Porcellis porcellis@eletrotupi.com 1 month ago ebb9f22f58004bd59460381e60090d37c17329fb
Parents: 24d1428
2 file(s) changed
  • frontend/app/entry/[id].tsx +2 -1
  • frontend/constants/mood-components.ts +26 -19
frontend/app/entry/[id].tsx
1 -
import { useState, useEffect } from "react";
1 +
import { useState, useEffect, use } from "react";
2 2
import {
3 3
  StyleSheet,
4 4
  Text,
5 5
  View,
6 6
  ScrollView,
▸ 107 unchanged lines
114 114
                  {moodDef?.label ?? entry.selectedMood}
115 115
                </Text>
116 116
                <Text style={styles.moodTime}>{formatMoment(moment)}</Text>
117 117
              </Col>
118 118
            </Row>
119 +
            {/* If this is the latest mood entry, show the active badge */}
119 120
            <Badge
120 121
              label="Registro Ativo"
121 122
              backgroundColor={Theme.colors.activeBackground}
122 123
              color={Theme.colors.tint}
123 124
            />
▸ 189 unchanged lines
313 314
    color: Colors.light.textSecondary,
314 315
    fontStyle: "italic",
315 316
    padding: 4,
316 317
  },
317 318
});
frontend/constants/mood-components.ts
1 1
export interface MoodComponentDefinition {
2 2
  id: string;
3 3
  label: string;
4 4
  color: string;
5 5
}
6 6

7 7
export const MOOD_COMPONENTS: MoodComponentDefinition[] = [
8 -
  { id: 'joy',       label: 'Alegria',       color: '#FBBF24' }, // amber
9 -
  { id: 'neutral',   label: 'Tranquilidade', color: '#60A5FA' }, // blue
10 -
  { id: 'anger',     label: 'Raiva',         color: '#F87171' }, // red
11 -
  { id: 'sadness',   label: 'Tristeza',      color: '#818CF8' }, // indigo
12 -
  { id: 'anxiety',   label: 'Ansiedade',     color: '#FB923C' }, // orange
13 -
  { id: 'gratitude', label: 'Gratidão',      color: '#C084FC' }, // purple
14 -
  { id: 'focus',     label: 'Foco',          color: '#34D399' }, // teal
15 -
  { id: 'tiredness', label: 'Cansaço',       color: '#94A3B8' }, // slate
8 +
  { id: "joy", label: "Alegria", color: "#FBBF24" }, // amber
9 +
  { id: "anger", label: "Raiva", color: "#F87171" }, // red
10 +
  { id: "sadness", label: "Tristeza", color: "#818CF8" }, // indigo
11 +
  { id: "fear", label: "Medo", color: "#F9A8D4" }, // pink
12 +
  { id: "guilt", label: "Culpa", color: "#FF6347" }, // tomato
13 +
  { id: "frustration", label: "Frustração", color: "#CD853F" }, // terracota
14 +
  // States
15 +
  { id: "calm", label: "Calmo", color: "#60A5FA" }, // blue
16 +
  { id: "motivated", label: "Motivado", color: "#FB923C" }, // orange
17 +
  { id: "tiredness", label: "Cansaço", color: "#94A3B8" }, // slate
18 +
  { id: "gratitude", label: "Gratidão", color: "#C084FC" }, // purple
19 +
  { id: "focus", label: "Foco", color: "#34D399" }, // teal
20 +
  { id: "restless", label: "Inquieto", color: "#9FCBAD" }, // light-green
21 +
  { id: "relaxed", label: "Relaxado", color: "#995F2F" }, // light-brown
22 +
  { id: "overwhelmed", label: "Sobrecarga", color: "#744577" }, // pastel purple
16 23
];
17 24

18 25
// Lookup helper
19 26
export const getMoodComponent = (id: string) =>
20 27
  MOOD_COMPONENTS.find((c) => c.id === id);
21 28

22 29
// Intensity label buckets
23 30
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';
31 +
  if (typeof value == "number") {
32 +
    if (value == 1) return "Suave";
33 +
    if (value <= 2) return "Moderada";
34 +
    if (value <= 3) return "Intensa";
28 35
  } else {
29 -
    if (value === 'LIGHT') return 'Suave';
30 -
    if (value === 'MODERATE') return 'Moderada';
31 -
    if (value === 'HIGH') return 'Intensa';
36 +
    if (value === "LIGHT") return "Suave";
37 +
    if (value === "MODERATE") return "Moderada";
38 +
    if (value === "HIGH") return "Intensa";
32 39
  }
33 40
};
34 41

35 42
export const intensityToValue = (value: number): string => {
36 -
  if (value == 1) return 'LIGHT';
37 -
  if (value <= 2) return 'MODERATE';
38 -
  if (value <= 3) return 'HIGH';
39 -
}
43 +
  if (value == 1) return "LIGHT";
44 +
  if (value <= 2) return "MODERATE";
45 +
  if (value <= 3) return "HIGH";
46 +
};