save: directe uploadMeasurement push, verwijder syncStatus uit MeasurementForm
This commit is contained in:
parent
23db445366
commit
143572bc81
2 changed files with 2 additions and 3 deletions
|
|
@ -78,7 +78,6 @@ function toInt(s: string): number {
|
||||||
measuredAt: measurementDate.toISOString(),
|
measuredAt: measurementDate.toISOString(),
|
||||||
createdAt: isEdit && initialValues?.createdAt ? initialValues.createdAt : now,
|
createdAt: isEdit && initialValues?.createdAt ? initialValues.createdAt : now,
|
||||||
updatedAt: now,
|
updatedAt: now,
|
||||||
syncStatus: 'local',
|
|
||||||
}
|
}
|
||||||
onSubmit(m)
|
onSubmit(m)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { useFocusEffect } from '@react-navigation/native'
|
||||||
import MeasurementForm from '../components/MeasurementForm'
|
import MeasurementForm from '../components/MeasurementForm'
|
||||||
import { Measurement } from '../types'
|
import { Measurement } from '../types'
|
||||||
import { initDatabase, insertMeasurement, upsertMeasurement, getLatestMeasurement, getMeasurementByDate } from '../database/db'
|
import { initDatabase, insertMeasurement, upsertMeasurement, getLatestMeasurement, getMeasurementByDate } from '../database/db'
|
||||||
|
import { uploadMeasurement } from '../sync/syncService'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
navigation: any
|
navigation: any
|
||||||
|
|
@ -72,8 +73,7 @@ export default function NewMeasurementScreen({ navigation, route }: Props) {
|
||||||
|
|
||||||
const doSave = async (m: Measurement) => {
|
const doSave = async (m: Measurement) => {
|
||||||
try {
|
try {
|
||||||
const { syncAll } = await import('../sync/syncService')
|
await uploadMeasurement(m)
|
||||||
await syncAll()
|
|
||||||
Alert.alert('Opgeslagen & gesynct', 'Meting is opgeslagen en gesynchroniseerd', [
|
Alert.alert('Opgeslagen & gesynct', 'Meting is opgeslagen en gesynchroniseerd', [
|
||||||
{ text: 'OK', onPress: () => navigation.goBack() },
|
{ text: 'OK', onPress: () => navigation.goBack() },
|
||||||
])
|
])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue