add Rainfalls Index page

This commit is contained in:
Romulus21
2023-09-14 23:20:29 +02:00
parent 42f03707d9
commit 4a733929ed
11 changed files with 177 additions and 26 deletions

View File

@@ -1,5 +1,6 @@
import {useState} from "react";
import axios from "axios";
import React from "react";
const useAxiosTools = () => {
@@ -8,8 +9,19 @@ const useAxiosTools = () => {
const axiosGet = axios.get
const axiosPost = axios.post
const axiosPut = axios.put
const axiosDelete = axios.delete
return {loading, setLoading, error, setError, axiosGet, axiosPost}
const errorCatch = (error: any) => {
setError(error.response.data.message || error.message)
}
const errorLabel = () => {
return error ? <div className="bg-red-600 rounded m-2 text-center text-white px-2 py-1 mx-auto">{error}</div>: null
}
return {loading, setLoading, error, setError, errorCatch, errorLabel, axiosGet, axiosPost, axiosPut, axiosDelete}
}
export default useAxiosTools