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 {errorCatch, errorLabel, axiosPost} = useAxiosTools() const [date, setDate] = useState((new Date()).toSQLDate()) const [value, setValue] = useState(null) const handleSubmit = async (event: FormEvent) => { event.preventDefault() try { await axiosPost('/api/rainfalls', {date, value}) setDate((new Date()).toSQLDate()) setValue(null) reload(new Date()) } catch (error) { errorCatch(error) } } return

Ajout d'une mesure

{errorLabel()}
setDate(event.target.value)} autoFocus>Date setValue(Number(event.target.value))}>Mesure
} export default AddRainfall interface AddRainfallProps { reload: Dispatch> }