eletrotupi / tcc/ commit / 8866389

frontend: fine tuning mood components intensity

First to match the API, secondly, because it doesn't really make sense
that all things you can be super specific, most of the time you don't
even can rationale that much about
Pedro Lucas Porcellis porcellis@eletrotupi.com · 5 months ago 8866389e004d6c249288b8edb4e951f434a0b460 Browse files
Parents 168d224
Changed files
3
Additions
+5
Deletions
-7
frontend/app/entry/mood-components.tsx
1 1
import React from 'react';
2 2
import {
3 3
  View,
4 4
  Text,
5 5
  ScrollView,
102 102
                    variant="compact"
103 103
                    label="Intensidade"
104 104
                    value={comp.intensity}
105 105
                    onValueChange={(v) => setComponentIntensity(comp.id, v)}
106 106
                    min={1}
107 -
                    max={10}
107 +
                    max={3}
108 108
                    step={1}
109 109
                    minLabel="Suave"
110 110
                    maxLabel="Intensa"
111 111
                    style={styles.slider}
112 112
                  />
241 241
    fontSize: Theme.typography.bodyMd.fontSize,
242 242
    fontWeight: '500',
243 243
    color: Theme.colors.light.text,
244 244
  }
245 245
});
frontend/constants/mood-components.ts
1 1
export interface MoodComponentDefinition {
2 2
  id: string;
3 3
  label: string;
4 4
  color: string;
5 5
}
19 19
export const getMoodComponent = (id: string) =>
20 20
  MOOD_COMPONENTS.find((c) => c.id === id);
21 21

22 22
// Intensity label buckets
23 23
export const intensityLabel = (value: number): string => {
24 -
  if (value <= 2) return 'Muito Baixa';
25 -
  if (value <= 4) return 'Baixa';
26 -
  if (value <= 6) return 'Moderada';
27 -
  if (value <= 8) return 'Alta';
28 -
  return 'Muito Alta';
24 +
  if (value == 1) return 'Suave';
25 +
  if (value <= 2) return 'Moderada';
26 +
  if (value <= 3) return 'Intensa';
29 27
};
frontend/stores/moodEntry.ts
1 1
import { create } from 'zustand';
2 2

3 3
export interface ActiveMoodComponent {
4 4
  i: string;         // matches MoodComponentDefinition.id
5 5
  intensity: number; // 1–10
31 31
  setComponents: (components) => set({ components }),
32 32

33 33
  addComponent: (id) =>
34 34
    set((state) => {
35 35
      if (state.components.find((c) => c.id === id)) return state;
36 -
      return { components: [...state.components, { id, intensity: 5 }] };
36 +
      return { components: [...state.components, { id, intensity: 1 }] };
37 37
    }),
38 38

39 39
  removeComponent: (id) =>
40 40
    set((state) => ({
41 41
      components: state.components.filter((c) => c.id !== id),
48 48
      ),
49 49
    })),
50 50

51 51
  reset: () => set({ selectedMood: null, components: [] }),
52 52
}));