add lint js

This commit is contained in:
Romulus21
2024-03-06 09:42:12 +01:00
parent 2de7c78344
commit 115d597a09
26 changed files with 479 additions and 163 deletions

View File

@@ -1,29 +1,31 @@
import {useState} from "react";
import axios from "axios";
import React from "react";
import {cleanErrorsForm, displayFormErrors} from "../utilities/form";
import {useState} from "react"
import axios, {AxiosError} from "axios"
import React from "react"
import {cleanErrorsForm, displayFormErrors, ValidationErrors} from "../utilities/form"
const useAxiosTools = () => {
const [loading, setLoading] = useState(false)
const [error, setError] = useState<string|null>(null)
const [error, setError] = useState<string|null|undefined>(null)
const axiosGet = axios.get
const axiosPost = axios.post
const axiosPut = axios.put
const axiosDelete = axios.delete
const errorCatch = (error: any) => {
if (error.response && error.response.status === 422) {
displayFormErrors(error)
} else {
setError(error.response?.data.message || error.message)
const errorCatch = (error: Error|AxiosError|unknown) => {
if (axios.isAxiosError(error)) {
(error.response?.status === 422)
? displayFormErrors(error)
: setError(error.response?.data.message || error.message)
} else if (error instanceof Error) {
setError(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 error ? <div className="m-2 mx-auto rounded bg-red-600 px-2 py-1 text-center text-white">{error}</div>: null
}
const cleanErrors = () => {