feat: edit expense

This commit is contained in:
Jakob Stornig 2024-01-05 15:26:09 +01:00
parent deda54152b
commit 5b71fa74b1
11 changed files with 273 additions and 41 deletions

View file

@ -6,12 +6,16 @@ const useFetch = (query: Query) => {
const [isLoading, setIsLoading] = useState(false);
const [data, setData] = useState<{[column: string]: any;}[]>([]);
const [isEmptyResult, setIsEmptyResult] = useState<boolean | undefined>(undefined);
const reFetch = () => {
setIsLoading(true);
executeQuery(query).then((result) => {
if("rows" in result[0]) {
setData(result[0]["rows"]);
if(result[0]["rows"].length == 0){
setIsEmptyResult(true);
}
}
}).catch((error: any) => {
console.error("Fetching data from database has failed: ", error);
@ -24,7 +28,7 @@ const useFetch = (query: Query) => {
reFetch();
}, [])
return {data, isLoading, reFetch};
return {data, isLoading, reFetch, isEmptyResult};
}
export default useFetch;