Skip to content

Commit

Permalink
fix(component): fixed: page crashing when date input becomes empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Adarsh710 committed Feb 13, 2021
1 parent b79d1b3 commit f7835c9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/incidents/report/ReportIncident.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ const ReportIncident = () => {
const [error, setError] = useState<IncidentError | undefined>(undefined)

const onDateChange = (newDate: Date) => {
setIncident((prevState) => ({
...prevState,
date: newDate.toISOString(),
}))
setIncident((prevState) => {
if (newDate) {
return {
...prevState,
date: newDate.toISOString(),
}
}
return {
...prevState,
date: new Date().toISOString(),
}
})
}

const onTextInputChange = (text: string, name: string) => {
Expand Down

0 comments on commit f7835c9

Please sign in to comment.