63 lines
2.2 KiB
TypeScript
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>);
|
|
}
|