update project & fix default value add rainfall

This commit is contained in:
Romulus21
2023-12-23 20:51:53 +01:00
parent 857126ffb8
commit 7ff0470e48
4 changed files with 1052 additions and 1082 deletions

View File

@@ -7,14 +7,14 @@ const AddRainfall: FC<AddRainfallProps> = ({reload}) => {
const {errorCatch, errorLabel, axiosPost} = useAxiosTools()
const [date, setDate] = useState((new Date()).toSQLDate())
const [value, setValue] = useState(0)
const [value, setValue] = useState<null|number>(null)
const handleSubmit = async (event: FormEvent) => {
event.preventDefault()
try {
await axiosPost('/api/rainfalls', {date, value})
setDate((new Date()).toSQLDate())
setValue(0)
setValue(null)
reload(new Date())
} catch (error) {
errorCatch(error)