frontend: rig frontend with sleep record queries
Parents:
c00102e1 file(s) changed
- frontend/app/sleep/new.tsx +14 -5
frontend/app/sleep/new.tsx
@@ -2,9 +2,11 @@ import {
2 2 View,
3 3 Text,
4 4 StyleSheet,
5 + KeyboardAvoidingView,
5 6 ScrollView
6 7 } from 'react-native';
7 8 import { useEffect, useState } from 'react';
9 + import { router } from 'expo-router';
8 10
9 11 import { Card } from '@/components/ui/Cards';
10 12 import { Input, TextArea } from '@/components/ui/Input';
@@ -13,11 +15,13 @@ import { Spacing, Typography, Colors, BorderRadius } from '@/constants/theme';
13 15 import { Ionicons } from '@expo/vector-icons';
14 16 import DatePickerField from '@/components/ui/DatePickerField';
15 17 import { ScaleSlider } from '@/components/ui/ScaleSlider';
18 + import { useCreateSleepRecord } from '@/hooks';
16 19
17 20 export default function NewSleepRecord() {
18 21 const [date, setDate] = useState(new Date())
19 22 const [annotations, setAnnotations] = useState();
20 23 const [average, setAverage] = useState(7.5);
24 + const createSleepRecord = useCreateSleepRecord();
21 25
22 26 const formatValue = (value: number): string => {
23 27 return String(value).replaceAll('.', ',');
@@ -31,12 +35,14 @@ average
31 35 };
32 36
33 37 console.log("Sleep record:", data)
34 - //await createSleepRecord.mutateAsync(data)
35 - //router.replace("/")
38 + await createSleepRecord.mutateAsync(data)
39 + router.replace("/")
36 40 };
37 41
38 42 return (
39 - <View>
43 + <KeyboardAvoidingView
44 + behavior='height'
45 + style={styles.keyboardView}>
40 46 <ScrollView scrollEventThrottle={16}>
41 47 <View style={styles.container}>
42 48 <View style={styles.header}>
@@ -94,7 +100,7 @@
94 100 <Button title="Salvar Registro" onPress={save} />
95 101 </View>
96 102 </ScrollView>
97 - </View>
103 + </KeyboardAvoidingView>
98 104 );
99 105 }
100 106
@@ -135,5 +141,8 @@ description: {
135 141 ...Typography.bodyMd,
136 142 color: Colors.light.textSecondary,
137 143 marginTop: 20
138 - }
144 + },
145 + keyboardView: {
146 + flex: 1,
147 + },
139 148 })