Resolve "Budget"
This commit is contained in:
parent
645b805aa7
commit
69610de100
17 changed files with 346 additions and 121 deletions
|
|
@ -1,20 +1,21 @@
|
|||
import { Query } from "expo-sqlite";
|
||||
import { useEffect, useState } from "react";
|
||||
import { executeQuery } from "../services/database";
|
||||
|
||||
const useFetch = () => {
|
||||
const useFetch = (query: Query) => {
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [data, setData] = useState<{[column: string]: any;}[]>([]);
|
||||
|
||||
const reFetch = () => {
|
||||
setIsLoading(true);
|
||||
executeQuery("SELECT e.guid AS expense_guid, c.guid AS category_guid, e.name AS expense_name, c.name AS category_name, e.datetime AS expense_datetime, e.amount AS expense_amount, c.color AS category_color, c.type AS category_type FROM expense e JOIN category c ON e.category_guid = c.guid;").then((result) => {
|
||||
executeQuery(query).then((result) => {
|
||||
if("rows" in result[0]) {
|
||||
setData(result[0]["rows"]);
|
||||
}
|
||||
}).catch((error: any) => {
|
||||
console.error("Fetching data from database has failed: ", error);
|
||||
}).finally(() => {
|
||||
}).then(() => {
|
||||
setIsLoading(false);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import colors from "../constants/colors";
|
|||
* @returns
|
||||
*/
|
||||
export function useThemeColor(colorName: keyof typeof colors.light & keyof typeof colors.dark): string {
|
||||
console.warn("useThemeColor is depreciated. Use useTheme().colors instead")
|
||||
console.log("useThemeColor is depreciated. Use useTheme().colors instead")
|
||||
const theme = useColorScheme() ?? "light";
|
||||
return colors[theme][colorName];
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue