import React, {Dispatch, FC, FormEvent, SetStateAction, useState} from "react" import useAxiosTools from "../../hooks/AxiosTools" import Field from "../Field" import Card from "../Card" const AddRainfall: FC = ({reload}) => { const {loading, setLoading, errorCatch, errorLabel, cleanErrors, axiosPost} = useAxiosTools() const [data, setData] = useState<{date: string, value: null|number}>({date: (new Date()).toSQLDate(), value: null}) const handleSubmit = async (event: FormEvent) => { event.preventDefault() cleanErrors() setLoading(true) try { await axiosPost('/api/rainfalls', data) setData({date: (new Date()).toSQLDate(), value: null}) reload(new Date()) } catch (error) { errorCatch(error) } finally { setLoading(false) } } return

Ajout d'une mesure

{errorLabel()}
setData({...data, date: event.target.value})} autoFocus> Date {!loading ? setData({...data, value: Number(event.target.value)})}> Mesure :
} } export default AddRainfall interface AddRainfallProps { reload: Dispatch> }