feat: add MeasurementForm and NewMeasurementScreen
This commit is contained in:
parent
3842e8af63
commit
212bc700c3
2 changed files with 108 additions and 0 deletions
21
src/screens/NewMeasurementScreen.tsx
Normal file
21
src/screens/NewMeasurementScreen.tsx
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import React from 'react'
|
||||
import { Alert } from 'react-native'
|
||||
import MeasurementForm from '../components/MeasurementForm'
|
||||
import { Measurement } from '../types'
|
||||
import { initDatabase, insertMeasurement } from '../database/db'
|
||||
|
||||
type Props = {
|
||||
navigation: any
|
||||
}
|
||||
|
||||
export default function NewMeasurementScreen({ navigation }: Props) {
|
||||
const handleSubmit = async (m: Measurement) => {
|
||||
await initDatabase()
|
||||
await insertMeasurement(m)
|
||||
Alert.alert('Opgeslagen', 'Meting is opgeslagen', [
|
||||
{ text: 'OK', onPress: () => navigation.goBack() },
|
||||
])
|
||||
}
|
||||
|
||||
return <MeasurementForm onSubmit={handleSubmit} />
|
||||
}
|
||||
Loading…
Reference in a new issue