update project & fix default value add rainfall
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user