feat: edit expense
This commit is contained in:
parent
deda54152b
commit
5b71fa74b1
11 changed files with 273 additions and 41 deletions
|
|
@ -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;
|
||||
Reference in a new issue