From 28d8afead2dd504dfc10fa729f5aec0fedf92126 Mon Sep 17 00:00:00 2001 From: saturnaliam Date: Tue, 18 Feb 2025 11:32:52 -0600 Subject: [PATCH] added another page for syncing (makes clearing data and saving cleaner) --- app/_layout.tsx | 1 + app/submit.tsx | 26 ++++++++++++++++++++++++++ app/summary.tsx | 8 ++------ 3 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 app/submit.tsx diff --git a/app/_layout.tsx b/app/_layout.tsx index 14ffcb4..6606b56 100644 --- a/app/_layout.tsx +++ b/app/_layout.tsx @@ -7,6 +7,7 @@ export default function RootLayout() { + ); } diff --git a/app/submit.tsx b/app/submit.tsx new file mode 100644 index 0000000..44cda35 --- /dev/null +++ b/app/submit.tsx @@ -0,0 +1,26 @@ +import { useState } from "react"; +import { ActivityIndicator } from "react-native-paper"; +import { addUnsyncedData, deleteMatchData, getMatchData } from "./api/data"; +import { View } from "react-native"; +import { router } from "expo-router"; + +export default function App() { + const [ animating, setAnimating ] = useState(true); + + getMatchData().then((data) => { + const deleted = deleteMatchData(); + const saved = addUnsyncedData(data); + + Promise.all([deleted, saved]).then(() => { + setAnimating(false); + router.navigate(""); + }) + }) + + + return ( + + + + ) +} \ No newline at end of file diff --git a/app/summary.tsx b/app/summary.tsx index c4d533d..2e88723 100644 --- a/app/summary.tsx +++ b/app/summary.tsx @@ -1,7 +1,7 @@ import { StatusBar } from 'expo-status-bar'; import { Keyboard, ScrollView, StyleSheet, View } from 'react-native'; import LabeledTextInput from './components/LabeledTextInput'; -import { addUnsyncedData, getMatchData, updateNotes } from './api/data'; +import { addUnsyncedData, deleteMatchData, getMatchData, updateNotes } from './api/data'; import PageHeader from './components/Header'; import SummaryTableView from './views/SummaryTableView'; import Checkbox from './components/Checkbox'; @@ -26,11 +26,7 @@ export default function App() { - { - getMatchData().then((data) => { - addUnsyncedData(data); - }).catch((err) => console.error(err)); - }} /> +