This repository has been archived on 2026-04-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
interaktive-systeme/app/(tabs)/stats/index.tsx
2024-01-02 12:56:11 +01:00

63 lines
2.2 KiB
TypeScript

import { Query } from 'expo-sqlite';
import { StyleSheet, Text, View } from 'react-native';
import { addCategory, deleteDatabase, deleteExpenses, executeQuery, initDatabase } from '../../../services/database';
export default function Page() {
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'space-evenly',
alignItems: 'center',
},
text: {
fontSize: 40,
color: "yellow",
}
});
return (
<View style={styles.container}>
<Text style={styles.text} onPress={() => {
deleteExpenses().then(() => {
console.log("Expenses Deleted!");
})
}}>Reset Expenses</Text>
<Text style={styles.text} onPress={() => {
deleteDatabase();
console.log("Database Deleted!");
}}>Reset Database</Text>
<Text style={styles.text} onPress={() => {
initDatabase().then(() => {
console.log("Database Initialized!");
});
}}>Init Database</Text>
<Text style={styles.text} onPress={() => {
addCategory("Expense Category", "green", "expense").then(() => {
const getCategoryQuery: Query = {sql: "SELECT guid FROM category", args: []};
executeQuery(getCategoryQuery).then((result) => {
if("rows" in result[0]) {
console.log(result[0]["rows"]);
}
})
console.log("Category added with success!");
})
}}>Add new Category Expense</Text>
<Text style={styles.text} onPress={() => {
addCategory("Savings Category", "yellow", "saving").then(() => {
const getCategoryQuery: Query = {sql: "SELECT guid FROM category", args: []};
executeQuery(getCategoryQuery).then((result) => {
if("rows" in result[0]) {
console.log(result[0]["rows"]);
}
})
console.log("Category added with success!");
})
}}>Add new Category Savings</Text>
</View>);
}