eletrotupi / tcc/ commit / 4ead651

frontend: rename variables to match api fields

Pedro Lucas Porcellis porcellis@eletrotupi.com · 5 months ago 4ead651accffd9854b38af6281c55a97628292b6 Browse files
Parents a07da01
Changed files
1
Additions
+12
Deletions
-12
frontend/app/sleep/new.tsx
1 1
import {
2 2
  View,
3 3
  Text,
4 4
  StyleSheet,
5 5
  ScrollView
13 13
import { Ionicons } from '@expo/vector-icons';
14 14
import DatePickerField from '@/components/ui/DatePickerField';
15 15
import { ScaleSlider } from '@/components/ui/ScaleSlider';
16 16

17 17
export default function NewSleepRecord() {
18 -
  const [day, setDay] = useState(new Date())
19 -
  const [annotation, setAnnotation] = useState();
20 -
  const [duration, setDuration] = useState(7.5);
18 +
  const [date, setDate] = useState(new Date())
19 +
  const [annotations, setAnnotations] = useState();
20 +
  const [average, setAverage] = useState(7.5);
21 21

22 22
  const formatValue = (value: number): string => {
23 23
    return String(value).replaceAll('.', ',');
24 24
  };
25 25

26 26
  const save = async () => {
27 27
    const data = {
28 -
      day,
29 -
      annotation,
30 -
      duration
28 +
      date,
29 +
      annotations,
30 +
      average
31 31
    };
32 32

33 33
    console.log("Sleep record:", data)
34 34
    //await createSleepRecord.mutateAsync(data)
35 35
    //router.replace("/")
58 58
          </View>
59 59

60 60
          <Card style={styles.mainCard}>
61 61
            <DatePickerField
62 62
              label="Data do Registro"
63 -
              initialDate={day}
63 +
              initialDate={date}
64 64
              maximumDate={new Date()}
65 -
              onChange={setDay}
65 +
              onChange={setDate}
66 66
            />
67 67

68 68
            <View style={{ marginVertical: 15 }}>
69 69
              <ScaleSlider
70 70
                label="Duração"
71 -
                value={duration}
72 -
                onValueChange={setDuration}
71 +
                value={average}
72 +
                onValueChange={setAverage}
73 73
                onValueFormat={formatValue}
74 74
                step={0.5}
75 75
                min={0.0}
76 76
                max={15.0}
77 77
                minLabel="0h"
80 80

81 81
            <TextArea
82 82
              label="Notas sobre a qualidade"
83 83
              type="text"
84 84
              variant="darkGhost"
85 -
              onChangeText={(val) => setAnnotation(val)}
86 -
              value={annotation}
85 +
              onChangeText={(val) => setAnnotations(val)}
86 +
              value={annotations}
87 87
              minRows={5}
88 88
              maxRows={10}
89 89
              placeholder="Como você se sentiu ao acordar? Teve sonhos marcantes?"
90 90
              style={styles.notes}
91 91
            />
135 135
    ...Typography.bodyMd,
136 136
    color: Colors.light.textSecondary,
137 137
    marginTop: 20
138 138
  }
139 139
})